Download inference_example.py from Nerthus-Project/Old_English_Lemmatiser: direct link, hf CLI and curl.
- Browser
- Download file 683 Bytes
-
https://huggingface.co/Nerthus-Project/Old_English_Lemmatiser/resolve/main/inference_example.py
- Command line
-
hf download hf://Nerthus-Project/Old_English_Lemmatiser/inference_example.py
-
curl -L -o inference_example.py https://huggingface.co/Nerthus-Project/Old_English_Lemmatiser/resolve/main/inference_example.py
683 Bytes
| """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() | |