use only .content not _content and modified noembeddingphrase

This commit is contained in:
stuart committed 2025-12-15 14:12:05 +01:00
1 parent ead9946d0d
commit abedbd8205
2 files changed
+10 -11

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ class Lexeme(ABC):
@abstractmethod
def embedding(self) -> Embedding:
"""Embedding(s) associated with the lexeme."""
pass
raise NotImplementedError("Embeddings are not supported") #added to allow for NoEmbeddingPhrase
@classmethod
@abstractmethod
+9 -10
View File
@@ -3,21 +3,21 @@ from pydantic_core import core_schema
from .lexeme import Lexeme
from .embedding import Embedding
import numpy as np
class Phrase(Lexeme):
def __init__(self, id: int, content: str, embedding: Embedding):
self.id = id
self._content = content
self._embedding = embedding
self.content = content
self.embedding = embedding
@property
def content(self) -> str:
return self._content
return self.content
@property
def embedding(self) -> Embedding:
return self._embedding
return self.embedding
@classmethod
def from_dict(cls, data: dict) -> "Phrase":
@@ -28,15 +28,14 @@ class Phrase(Lexeme):
)
class NoEmbeddingPhrase():
class NoEmbeddingPhrase(Lexeme):
def __init__(self, id: int, content: str):
self.id = id
self._content = content
self.content = content
self.embedding=np.array([]) # Placeholder to avoid attribute errors
@property
def content(self) -> str:
return self._content
return self.content
@classmethod
def from_dict(cls, data: dict) -> "Phrase":