Refactoring the EmailObject build process
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from ..object import KnowledgeObject
|
||||
from ..object import KnowledgeObject, ObjectRelationStore
|
||||
from ..data import ChunkList, ChunkListWriter
|
||||
from ..object import ObjectType
|
||||
from .. import KnowledgeStore
|
||||
@@ -49,9 +49,16 @@ class DocumentObjectBuilder:
|
||||
self.text = text
|
||||
return self
|
||||
|
||||
def build(self) -> DocumentObject:
|
||||
def build(self, relation_store: ObjectRelationStore) -> DocumentObject:
|
||||
chunk_list = KnowledgeStore().get_chunk_list_writer().create_chunk_list_from_text(
|
||||
self.text,
|
||||
1024 * 4,
|
||||
)
|
||||
return DocumentObject(self.meta, self.tags, chunk_list)
|
||||
doc = DocumentObject(self.meta, self.tags, chunk_list)
|
||||
doc_id = doc.calculate_id()
|
||||
|
||||
# Add relation to store
|
||||
for chunk_id in chunk_list.chunk_list:
|
||||
relation_store.add_relation(chunk_id, doc_id)
|
||||
|
||||
return doc
|
||||
|
||||
Reference in New Issue
Block a user