Skip to content

Commit

Permalink
- Update: lexical_index_to_sssom(): Added param for extended prefix map
Browse files Browse the repository at this point in the history
  • Loading branch information
joeflack4 committed Jan 19, 2024
1 parent 66998cd commit d19f284
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/oaklib/utilities/lexical/lexical_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def lexical_index_to_sssom(
ruleset: MappingRuleCollection = None,
meta: Optional[Dict[str, t.Any]] = None,
prefix_map: Union[None, Converter, t.Mapping[str, str]] = None,
extended_prefix_map: t.Iterable[Dict[str, t.Any]] = None,
subjects: Collection[CURIE] = None,
objects: Collection[CURIE] = None,
symmetric: bool = False,
Expand All @@ -265,6 +266,9 @@ def lexical_index_to_sssom(
:param ensure_strict_prefixes: If true, prefixes & mappings in SSSOM MappingSetDataFrame will be filtred.
:return: SSSOM MappingSetDataFrame object.
"""
if prefix_map and extended_prefix_map:
raise ValueError('Can only pass prefix_map or extended_prefix_map, but not both.')

mappings = []
logging.info("Converting lexical index to SSSOM")
if subjects:
Expand All @@ -275,6 +279,7 @@ def lexical_index_to_sssom(
symmetric = True
logging.info("Forcing symmetric comparison")
logging.info(f"Iterating over {len(lexical_index.groupings)} groupings")

for term, grouping in lexical_index.groupings.items():
# elements = set([r.element for r in grouping.relationships])
elementmap = defaultdict(list)
Expand Down Expand Up @@ -313,7 +318,9 @@ def lexical_index_to_sssom(

converter = curies.chain(
[
Converter.from_prefix_map((meta or {}).pop(CURIE_MAP, {})),
Converter.from_extended_prefix_map(extended_prefix_map) if extended_prefix_map \
else Converter.from_prefix_map(prefix_map) if prefix_map \
else Converter.from_prefix_map((meta or {}).pop(CURIE_MAP, {})),
ensure_converter(prefix_map, use_defaults=False),
oi.converter,
]
Expand Down

0 comments on commit d19f284

Please sign in to comment.