Skip to content

Commit

Permalink
Merge pull request #439 from jgroehm/main
Browse files Browse the repository at this point in the history
encoding="utf-8"
  • Loading branch information
dakinggg authored Aug 4, 2022
2 parents dfbecc8 + 0d27bb1 commit 57fe1b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions scispacy/candidate_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,12 @@ def nmslib_knn_with_zero_vectors(
neighbors.append([])
distances.append([])
# interleave `neighbors` and Nones in `extended_neighbors`
extended_neighbors[empty_vectors_boolean_flags] = numpy.array(neighbors)[:-1]
extended_distances[empty_vectors_boolean_flags] = numpy.array(distances)[:-1]
extended_neighbors[empty_vectors_boolean_flags] = numpy.array(
neighbors, dtype="object"
)[:-1]
extended_distances[empty_vectors_boolean_flags] = numpy.array(
distances, dtype="object"
)[:-1]

return extended_neighbors, extended_distances

Expand Down
8 changes: 4 additions & 4 deletions scispacy/umls_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def read_umls_file_headers(meta_path: str, filename: str) -> List[str]:
a list of column names
"""
file_descriptors = f"{meta_path}/MRFILES.RRF" # to get column names
with open(file_descriptors) as fin:
with open(file_descriptors, encoding="utf-8") as fin:
for line in fin:
splits = line.split("|")
found_filename = splits[0]
Expand Down Expand Up @@ -59,7 +59,7 @@ def read_umls_concepts(meta_path: str, concept_details: Dict, source: str = None
"""
concepts_filename = "MRCONSO.RRF"
headers = read_umls_file_headers(meta_path, concepts_filename)
with open(f"{meta_path}/{concepts_filename}") as fin:
with open(f"{meta_path}/{concepts_filename}", encoding="utf-8") as fin:
for line in fin:
splits = line.strip().split("|")
assert len(headers) == len(splits), (headers, splits)
Expand Down Expand Up @@ -114,7 +114,7 @@ def read_umls_types(meta_path: str, concept_details: Dict):
"""
types_filename = "MRSTY.RRF"
headers = read_umls_file_headers(meta_path, types_filename)
with open(f"{meta_path}/{types_filename}") as fin:
with open(f"{meta_path}/{types_filename}", encoding="utf-8") as fin:
for line in fin:
splits = line.strip().split("|")
assert len(headers) == len(splits)
Expand Down Expand Up @@ -142,7 +142,7 @@ def read_umls_definitions(meta_path: str, concept_details: Dict):
"""
definitions_filename = "MRDEF.RRF"
headers = read_umls_file_headers(meta_path, definitions_filename)
with open(f"{meta_path}/{definitions_filename}") as fin:
with open(f"{meta_path}/{definitions_filename}", encoding="utf-8") as fin:
headers = read_umls_file_headers(meta_path, definitions_filename)
for line in fin:
splits = line.strip().split("|")
Expand Down

0 comments on commit 57fe1b3

Please sign in to comment.