MCPcopy
hub / github.com/QData/TextAttack / flair_tag

Function flair_tag

textattack/shared/utils/strings.py:221–228  ·  view source on GitHub ↗

Tags a `Sentence` object using `flair` part-of-speech tagger.

(sentence, tag_type="upos-fast")

Source from the content-addressed store, hash-verified

219
220
221def flair_tag(sentence, tag_type="upos-fast"):
222 """Tags a `Sentence` object using `flair` part-of-speech tagger."""
223 global _flair_pos_tagger
224 if not _flair_pos_tagger:
225 from flair.models import SequenceTagger
226
227 _flair_pos_tagger = SequenceTagger.load(tag_type)
228 _flair_pos_tagger.predict(sentence, force_token_predictions=True)
229
230
231def zip_flair_result(pred, tag_type="upos-fast"):

Callers

nothing calls this directly

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected