-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3388 from flairNLP/bf/bio-entity-normalization
Entity Mention Linker
- Loading branch information
Showing
15 changed files
with
2,417 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,3 +108,4 @@ venv.bak/ | |
|
||
resources/taggers/ | ||
regression_train/ | ||
/doc_build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import inspect | ||
from typing import Iterable, Optional, Type, TypeVar | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
def get_non_abstract_subclasses(cls: Type[T]) -> Iterable[Type[T]]: | ||
for subclass in cls.__subclasses__(): | ||
yield from get_non_abstract_subclasses(subclass) | ||
if inspect.isabstract(subclass): | ||
continue | ||
yield subclass | ||
|
||
|
||
def get_state_subclass_by_name(cls: Type[T], cls_name: Optional[str]) -> Type[T]: | ||
for sub_cls in get_non_abstract_subclasses(cls): | ||
if sub_cls.__name__ == cls_name: | ||
return sub_cls | ||
raise ValueError(f"Could not find any class with name '{cls_name}'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.