| }, | }, | ||||
| ) | ) | ||||
| if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | ||||
| child_chunks = document_segment.child_chunks | |||||
| child_chunks = document_segment.get_child_chunks() | |||||
| if child_chunks: | if child_chunks: | ||||
| child_documents = [] | child_documents = [] | ||||
| for child_chunk in child_chunks: | for child_chunk in child_chunks: |
| else: | else: | ||||
| return [] | return [] | ||||
| def get_child_chunks(self): | |||||
| process_rule = self.document.dataset_process_rule | |||||
| if process_rule.mode == "hierarchical": | |||||
| rules = Rule(**process_rule.rules_dict) | |||||
| if rules.parent_mode: | |||||
| child_chunks = ( | |||||
| db.session.query(ChildChunk) | |||||
| .filter(ChildChunk.segment_id == self.id) | |||||
| .order_by(ChildChunk.position.asc()) | |||||
| .all() | |||||
| ) | |||||
| return child_chunks or [] | |||||
| else: | |||||
| return [] | |||||
| else: | |||||
| return [] | |||||
| @property | @property | ||||
| def sign_content(self): | def sign_content(self): | ||||
| return self.get_sign_content() | return self.get_sign_content() |
| }, | }, | ||||
| ) | ) | ||||
| if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | ||||
| child_chunks = segment.child_chunks | |||||
| child_chunks = segment.get_child_chunks() | |||||
| if child_chunks: | if child_chunks: | ||||
| child_documents = [] | child_documents = [] | ||||
| for child_chunk in child_chunks: | for child_chunk in child_chunks: |
| }, | }, | ||||
| ) | ) | ||||
| if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | ||||
| child_chunks = segment.child_chunks | |||||
| child_chunks = segment.get_child_chunks() | |||||
| if child_chunks: | if child_chunks: | ||||
| child_documents = [] | child_documents = [] | ||||
| for child_chunk in child_chunks: | for child_chunk in child_chunks: |
| index_processor = IndexProcessorFactory(dataset_document.doc_form).init_index_processor() | index_processor = IndexProcessorFactory(dataset_document.doc_form).init_index_processor() | ||||
| if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | ||||
| child_chunks = segment.child_chunks | |||||
| child_chunks = segment.get_child_chunks() | |||||
| if child_chunks: | if child_chunks: | ||||
| child_documents = [] | child_documents = [] | ||||
| for child_chunk in child_chunks: | for child_chunk in child_chunks: |
| ) | ) | ||||
| if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | if dataset_document.doc_form == IndexType.PARENT_CHILD_INDEX: | ||||
| child_chunks = segment.child_chunks | |||||
| child_chunks = segment.get_child_chunks() | |||||
| if child_chunks: | if child_chunks: | ||||
| child_documents = [] | child_documents = [] | ||||
| for child_chunk in child_chunks: | for child_chunk in child_chunks: |