Skip to content

Commit

Permalink
add non_suppressed to main func (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanhkim authored Mar 30, 2024
1 parent 29b1e46 commit 021fe76
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/export_umls_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
import argparse
from scispacy import umls_utils

def main(meta_path: str, output_path: str, lang: str = None, source: str = None):
def main(
meta_path: str,
output_path: str,
lang: str = None,
source: str = None,
non_suppressed: bool = True,
):

concept_details = {} # dictionary of concept_id -> {
# 'concept_id': str,
Expand All @@ -18,7 +24,7 @@ def main(meta_path: str, output_path: str, lang: str = None, source: str = None)
# }

print('Reading concepts ... ')
umls_utils.read_umls_concepts(meta_path, concept_details, lang, source)
umls_utils.read_umls_concepts(meta_path, concept_details, source, lang, non_suppressed)

print('Reading types ... ')
umls_utils.read_umls_types(meta_path, concept_details)
Expand Down Expand Up @@ -78,8 +84,7 @@ def main(meta_path: str, output_path: str, lang: str = None, source: str = None)
del concept['is_from_preferred_source']

print('Exporting to the a jsonl file {} ...'.format(output_path))
with open(output_path, 'w') as fout:

with open(output_path, 'w', encoding='utf-8') as fout:
for value in concept_details.values():
fout.write(json.dumps(value) + "\n")
print('DONE.')
Expand Down Expand Up @@ -109,7 +114,7 @@ def main(meta_path: str, output_path: str, lang: str = None, source: str = None)
parser.add_argument(
'--non_suppressed',
default=True,
help="Whether to include non supressed terms."
help="Whether to include non-suppressed terms."
)
args = parser.parse_args()
main(args.meta_path, args.output_path, args.lang, args.source, args.non_suppressed)

0 comments on commit 021fe76

Please sign in to comment.