Skip to content

Commit

Permalink
API: Make iamsystem an optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ghisvail committed Apr 25, 2024
1 parent d65b368 commit 3cf0c5b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
10 changes: 7 additions & 3 deletions docs/cookbook/iamsystem.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# IAMSystem Matcher

+++
This section showcases an example using the IAMSystem matcher.

This tutorial will show an example of iamsystem matcher operation usage.
:::{note}
This section requires optional dependencies, use the following to install them:

+++
```console
pip install 'medkit-lib[iamsystem-matcher]'
```
:::

## Loading a text document

Expand Down
9 changes: 5 additions & 4 deletions medkit/text/ner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"SimstringMatcherRule",
"SimstringMatcherNormalization",
"UMLSMatcher",
"IAMSystemMatcher",
"MedkitKeyword",
"DateAttribute",
"DurationAttribute",
"RelativeDateAttribute",
Expand All @@ -26,12 +24,15 @@
RelativeDateDirection,
)
from medkit.text.ner.duckling_matcher import DucklingMatcher
from medkit.text.ner.iamsystem_matcher import IAMSystemMatcher, MedkitKeyword
from medkit.text.ner.regexp_matcher import RegexpMatcher, RegexpMatcherNormalization, RegexpMatcherRule, RegexpMetadata
from medkit.text.ner.simstring_matcher import SimstringMatcher, SimstringMatcherNormalization, SimstringMatcherRule
from medkit.text.ner.umls_matcher import UMLSMatcher

# quick_umls module
# iamsystem matcher
if modules_are_available(["iamsystem"]):
__all__ += ["iamsystem_matcher"]

# quickumls matcher
if modules_are_available(["packaging", "quickumls"]):
__all__ += ["quick_umls_matcher"]

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ dependencies = [
"anyascii",
"duptextfinder>=0.3.0",
"flashtext>=2.7",
"iamsystem>=0.6.0",
"intervaltree",
"numpy",
"pyaml",
Expand Down Expand Up @@ -75,6 +74,9 @@ hf-translator = [
hf-utils = [
"transformers>=4.21",
]
iamsystem-matcher = [
"iamsystem>=0.6.0",
]
metrics-diarization = [
"pyannote-core>=5.0",
"pyannote-metrics>=3.2.0",
Expand Down Expand Up @@ -143,6 +145,7 @@ all = [
hf-transcriber,\
hf-translator,\
hf-utils,\
iamsystem-matcher,\
metrics-diarization,\
metrics-text-classification,\
metrics-ner,metrics-transcription,\
Expand Down
4 changes: 0 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# must import iamsystem first
# workaround for failed test quickumls when importing torchaudio,
# iamsystem then quickumls
import iamsystem # noqa:F401
import pytest

from medkit.core.store import GlobalStore
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/text/ner/test_iamsystem_matcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import pytest

pytest.importorskip(modname="iamsystem", reason="iamsystem is not installed")

from iamsystem import Entity as Term
from iamsystem import Matcher

Expand Down

0 comments on commit 3cf0c5b

Please sign in to comment.