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 20, 2024
1 parent 66998cd commit c8f8bd3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 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 Down Expand Up @@ -313,7 +317,11 @@ 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 c8f8bd3

Please sign in to comment.