Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Jan 20, 2024
1 parent b2ebfca commit 82b7118
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/oaklib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,9 @@ def annotate(
if match_column:
writer = _get_writer(output_type, impl, StreamingCsvWriter)
writer.output = output
for row in impl.annotate_tabular_file(text_file, configuration=configuration, match_column=match_column):
for row in impl.annotate_tabular_file(
text_file, configuration=configuration, match_column=match_column
):
writer.emit(row)
else:
for ann in impl.annotate_file(text_file, configuration):
Expand Down
28 changes: 16 additions & 12 deletions src/oaklib/implementations/translator/translator_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
"""
import logging
from dataclasses import dataclass
from typing import Iterable, Mapping, Optional, Union, List
from typing import Iterable, List, Mapping, Optional, Union

import requests
import sssom_schema.datamodel.sssom_schema as sssom

from oaklib.datamodels.search import SearchConfiguration
from oaklib.datamodels.vocabulary import SEMAPV, SKOS_CLOSE_MATCH, SKOS_EXACT_MATCH, RDFS_LABEL, HAS_RELATED_SYNONYM
from oaklib.datamodels.vocabulary import (
HAS_RELATED_SYNONYM,
RDFS_LABEL,
SEMAPV,
SKOS_CLOSE_MATCH,
SKOS_EXACT_MATCH,
)
from oaklib.interfaces import SearchInterface
from oaklib.interfaces.basic_ontology_interface import LANGUAGE_TAG, ALIAS_MAP
from oaklib.interfaces.basic_ontology_interface import ALIAS_MAP, LANGUAGE_TAG
from oaklib.interfaces.mapping_provider_interface import MappingProviderInterface
from oaklib.types import CURIE

Expand Down Expand Up @@ -101,10 +107,12 @@ def inject_mapping_labels(self, mappings: Iterable[Mapping]) -> None:
return

def basic_search(
self, search_term: str, config: Optional[SearchConfiguration] = None
self, search_term: str, config: Optional[SearchConfiguration] = None
) -> Iterable[CURIE]:
r = requests.get(f"{NAME_NORMALIZER_ENDPOINT}/lookup",
params={"string": search_term, "autocomplete": "true"})
r = requests.get(
f"{NAME_NORMALIZER_ENDPOINT}/lookup",
params={"string": search_term, "autocomplete": "true"},
)
r.raise_for_status()
results = r.json()
for result in results:
Expand All @@ -117,17 +125,15 @@ def label(self, curie: CURIE, lang: Optional[LANGUAGE_TAG] = None) -> Optional[s
raise NotImplementedError
if self.property_cache.contains(curie, RDFS_LABEL):
return self.property_cache.get(curie, RDFS_LABEL)
r = requests.get(f"{NAME_NORMALIZER_ENDPOINT}/reverse_lookup",
params={"curies": curie})
r = requests.get(f"{NAME_NORMALIZER_ENDPOINT}/reverse_lookup", params={"curies": curie})
r.raise_for_status()
results = r.json()
if curie not in results:
return None
return results[curie]["preferred_name"]

def entity_aliases(self, curie: CURIE) -> List[str]:
r = requests.get(f"{NAME_NORMALIZER_ENDPOINT}/reverse_lookup",
params={"curies": curie})
r = requests.get(f"{NAME_NORMALIZER_ENDPOINT}/reverse_lookup", params={"curies": curie})
r.raise_for_status()
results = r.json()
if curie not in results:
Expand All @@ -136,5 +142,3 @@ def entity_aliases(self, curie: CURIE) -> List[str]:

def entity_alias_map(self, curie: CURIE) -> ALIAS_MAP:
return {HAS_RELATED_SYNONYM: self.entity_aliases(curie)}


2 changes: 1 addition & 1 deletion src/oaklib/interfaces/text_annotator_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from abc import ABC
from io import TextIOWrapper
from pathlib import Path
from typing import Iterable, Iterator, Optional, Dict
from typing import Dict, Iterable, Iterator, Optional

from oaklib.datamodels.lexical_index import LexicalIndex
from oaklib.datamodels.mapping_rules_datamodel import MappingRuleCollection
Expand Down

0 comments on commit 82b7118

Please sign in to comment.