Spaces:
Paused
Paused
File size: 607 Bytes
845e414 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
from typing import Callable, Dict, List, Tuple, Union
from toolbox.named_entity_recognization.pyltp_ner import pyltp_ner
language_to_engines = {
"chinese": ["pyltp"]
}
engine_to_tagger: Dict[str, Callable] = {
"pyltp": pyltp_ner
}
def ner(text: str, language: str, engine: str):
ner_tagger = engine_to_tagger.get(engine)
if ner_tagger is None:
raise AssertionError(f"engine {engine} not supported.")
words, postags, ner_tags = ner_tagger(text, language)
return words, postags, ner_tags
if __name__ == "__main__":
pass
|