File size: 683 Bytes
eeea58f | 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 | """Runnable demo for the Old English lemmatiser.
Usage:
pip install -r requirements.txt
python inference_example.py
"""
from lemmatizer import OldEnglishLemmatizer
def main() -> None:
lem = OldEnglishLemmatizer.from_pretrained(".")
words = ["cyninges", "cwæð", "gōdan", "þurh", "cyning", "folce", "hālgan"]
print("word -> (lemma, POS)")
print("-" * 32)
for w, pred in zip(words, lem.lemmatize_batch(words)):
print(f"{w:12} -> {pred}")
print("\nText:")
for item in lem.lemmatize_text("se cyning cwæð to his folce"):
print(f" {item['word']:10} {item['lemma']:12} {item['pos']}")
if __name__ == "__main__":
main()
|