Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Project specific

/.idea/
example-output/
example-phi-build/

Expand Down Expand Up @@ -233,4 +234,4 @@ fabric.properties
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
.idea/caches/build_file_checksums.ser
6 changes: 3 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,6 @@ valid-metaclass-classmethod-first-arg=mcs

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=StandardError,
Exception,
BaseException
overgeneral-exceptions=builtins.StandardError,
builtins.Exception,
builtins.BaseException
2 changes: 1 addition & 1 deletion ctakesclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Public API"""

__version__ = "2.0.0"
__version__ = "2.1.0"

from . import client
from . import filesystem
Expand Down
14 changes: 12 additions & 2 deletions ctakesclient/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,19 @@ def _resource_file(filename: str) -> str:
return os.path.join(os.path.dirname(__file__), "resources", filename)


def covid_symptoms_path() -> str:
"""Returns the path to a bsv file of covid symptoms"""
return _resource_file("covid_symptoms.bsv")


def covid_symptoms() -> List[BsvConcept]:
"""Returns a list of known covid symptoms"""
return list_bsv_concept(_resource_file("covid_symptoms.bsv"))
return list_bsv_concept(covid_symptoms_path())


def umls_semantic_groups_path() -> str:
"""Returns the path to a bsv file of UMLS semantic groups"""
return _resource_file("SemGroups_2018.bsv")


def umls_semantic_groups() -> List[BsvSemanticType]:
Expand All @@ -229,4 +239,4 @@ def umls_semantic_groups() -> List[BsvSemanticType]:

See https://lhncbc.nlm.nih.gov/ii/tools/MetaMap/documentation/SemanticTypesAndGroups.html
"""
return list_bsv_semantics(_resource_file("SemGroups_2018.bsv"))
return list_bsv_semantics(umls_semantic_groups_path())
2 changes: 1 addition & 1 deletion ctakesclient/text2fhir.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _nlp_polarity(polarity: Polarity) -> Extension:


def _nlp_derivation_span(docref_id, span: Span) -> Extension:
return _nlp_derivation(docref_id=docref_id, offset=span.begin, length=(span.end - span.begin))
return _nlp_derivation(docref_id=docref_id, offset=span.begin, length=span.end - span.begin)


def _nlp_derivation(docref_id, offset=None, length=None) -> Extension:
Expand Down
2 changes: 1 addition & 1 deletion ctakesclient/typesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def parse_polarity(polarity) -> Polarity:
elif polarity == 0:
return Polarity.pos
else:
raise Exception(f"polarity unknown: {polarity}")
raise ValueError(f"polarity unknown: {polarity}")

@staticmethod
def parse_mention(mention: str) -> UmlsTypeMention:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_filesystem.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
"""Tests for the filesystem module"""

import os
import unittest

import ddt

from ctakesclient import filesystem
from tests.test_resources import PathResource


@ddt.ddt
class TestCovidSymptomsBSV(unittest.TestCase):
"""Test case for files loaded from bsv"""

@ddt.data(
filesystem.covid_symptoms_path,
filesystem.umls_semantic_groups_path,
)
def test_path_methods(self, method):
"""Verify we hand out a bsv path correctly"""
path = method()
self.assertIsInstance(path, str)
self.assertTrue(path.endswith(".bsv"))
self.assertTrue(os.path.isabs(path))
self.assertTrue(os.path.isfile(path))

def test_covid_symptom_concepts(self):
"""
Symptoms of COVID-19
Expand Down