Skip to content

Commit 254b241

Browse files
committed
✏️ refactored textual term_to_documents to term2documents
1 parent ff849c1 commit 254b241

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

ontolearner/base/textual.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ def _load_from_structure(self, path: Path) -> TextualData:
4141
# Load raw data from files
4242
terms_data = self._load_json(path / "terms.json")
4343
documents_data = self._load_jsonl(path / "documents.jsonl")
44-
term_to_documents_data = self._load_json(path / "terms2documents.json")
44+
term2documents_data = self._load_json(path / "terms2documents.json")
4545

4646
terms = [Term(**t) for t in terms_data]
4747
documents = [Document(**d) for d in documents_data]
4848

49-
term_to_documents = {}
50-
for term_name, doc_entries in term_to_documents_data.items():
51-
term_to_documents[term_name] = [
49+
term2documents = {}
50+
for term_name, doc_entries in term2documents_data.items():
51+
term2documents[term_name] = [
5252
DocumentReference(
5353
doc_id=entry["doc_id"],
5454
extraction_method=entry["extraction_method"]
@@ -59,7 +59,7 @@ def _load_from_structure(self, path: Path) -> TextualData:
5959
return TextualData(
6060
terms=terms,
6161
documents=documents,
62-
term_to_documents=term_to_documents
62+
term2documents=term2documents
6363
)
6464

6565
@staticmethod
@@ -88,7 +88,7 @@ def get_terms_by_document(self, doc_id: Union[int, str], split: str) -> List[Ter
8888
term_list = []
8989
doc_id_str = str(doc_id)
9090

91-
for term_name, doc_refs in self.data[split].term_to_documents.items():
91+
for term_name, doc_refs in self.data[split].term2documents.items():
9292
for doc_ref in doc_refs:
9393
if str(doc_ref.doc_id) == doc_id_str:
9494
# Find the full term data
@@ -116,13 +116,13 @@ def get_statistics(self, split: str) -> Dict[str, Any]:
116116

117117
# Count documents per term
118118
docs_per_term = {
119-
term.term: len(data.term_to_documents.get(term.term, []))
119+
term.term: len(data.term2documents.get(term.term, []))
120120
for term in data.terms
121121
}
122122

123123
# Get all unique document IDs that have terms
124124
docs_with_terms: Set[Union[int, str]] = set()
125-
for refs in data.term_to_documents.values():
125+
for refs in data.term2documents.values():
126126
for ref in refs:
127127
docs_with_terms.add(ref.doc_id)
128128

ontolearner/data_structure/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TextualData(BaseModel):
2727
"""Schema for textual data from a single split"""
2828
terms: List[Term] = []
2929
documents: List[Document] = []
30-
term_to_documents: Dict[str, List[DocumentReference]] = {}
30+
term2documents: Dict[str, List[DocumentReference]] = {}
3131

3232

3333
class TermTyping(BaseModel):

0 commit comments

Comments
 (0)