Skip to content

Commit

Permalink
Upgrade curies pkg and use new passthrough option
Browse files Browse the repository at this point in the history
Closes #173
  • Loading branch information
dalito committed Oct 30, 2023
1 parent eca38e3 commit 0456057
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ classifiers = [

dependencies = [
"base32-crockford >= 0.3.0",
"curies >= 0.5.6",
"curies >= 0.6.6",
"networkx >= 2.8",
"openpyxl >= 3.0.9",
"ontospy >= 2.1.0",
Expand Down
43 changes: 26 additions & 17 deletions src/voc4cat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def to_graph(self):

def to_excel(self, wb: Workbook):
ws = wb["Concept Scheme"]
ws["B2"] = config.curies_converter.compress(self.uri) or self.uri
ws["B2"] = config.curies_converter.compress(self.uri, passthrough=True)
ws["B3"] = self.title
ws["B4"] = self.description
ws["B5"] = self.created.isoformat()
Expand Down Expand Up @@ -365,8 +365,8 @@ def to_excel(self, wb: Workbook, row_no_features: int, row_no_concepts: int):

first_row_exported = False
for lang in chain(fully_translated, partially_translated):
ws[f"A{row_no_concepts}"] = (
config.curies_converter.compress(self.uri) or self.uri
ws[f"A{row_no_concepts}"] = config.curies_converter.compress(
self.uri, passthrough=True
)
ws[f"B{row_no_concepts}"] = pref_labels.get(lang, "")
ws[f"C{row_no_concepts}"] = lang
Expand All @@ -382,45 +382,51 @@ def to_excel(self, wb: Workbook, row_no_features: int, row_no_concepts: int):
ws[f"F{row_no_concepts}"] = ",\n".join(self.alt_labels)
ws[f"G{row_no_concepts}"] = ",\n".join(
[
(config.curies_converter.compress(uri) or uri)
config.curies_converter.compress(uri, passthrough=True)
for uri in self.children
]
)
ws[f"I{row_no_concepts}"] = (
(
config.curies_converter.compress(self.source_vocab)
or self.source_vocab
)
config.curies_converter.compress(self.source_vocab, passthrough=True)
if self.source_vocab
else None
)
row_no_concepts += 1

ws = wb["Additional Concept Features"]

ws[f"A{row_no_features}"] = (
config.curies_converter.compress(self.uri) or self.uri
ws[f"A{row_no_features}"] = config.curies_converter.compress(
self.uri, passthrough=True
)
ws[f"B{row_no_features}"] = ",\n".join(
[
(config.curies_converter.compress(uri) or uri)
config.curies_converter.compress(uri, passthrough=True)
for uri in self.related_match
]
)
ws[f"C{row_no_features}"] = ",\n".join(
[(config.curies_converter.compress(uri) or uri) for uri in self.close_match]
[
config.curies_converter.compress(uri, passthrough=True)
for uri in self.close_match
]
)
ws[f"D{row_no_features}"] = ",\n".join(
[(config.curies_converter.compress(uri) or uri) for uri in self.exact_match]
[
config.curies_converter.compress(uri, passthrough=True)
for uri in self.exact_match
]
)
ws[f"E{row_no_features}"] = ",\n".join(
[
(config.curies_converter.compress(uri) or uri)
config.curies_converter.compress(uri, passthrough=True)
for uri in self.narrow_match
]
)
ws[f"F{row_no_features}"] = ",\n".join(
[(config.curies_converter.compress(uri) or uri) for uri in self.broad_match]
[
config.curies_converter.compress(uri, passthrough=True)
for uri in self.broad_match
]
)

return row_no_concepts
Expand Down Expand Up @@ -461,11 +467,14 @@ def to_graph(self):

def to_excel(self, wb: Workbook, row_no: int):
ws = wb["Collections"]
ws[f"A{row_no}"] = config.curies_converter.compress(self.uri) or self.uri
ws[f"A{row_no}"] = config.curies_converter.compress(self.uri, passthrough=True)
ws[f"B{row_no}"] = self.pref_label
ws[f"C{row_no}"] = self.definition
ws[f"D{row_no}"] = ",\n".join(
[(config.curies_converter.compress(uri) or uri) for uri in self.members]
[
config.curies_converter.compress(uri, passthrough=True)
for uri in self.members
]
)
ws[f"E{row_no}"] = self.provenance

Expand Down

0 comments on commit 0456057

Please sign in to comment.