Download example.py from pateluday/tallie: direct link, hf CLI and curl.
- Browser
- Download file 783 Bytes
-
https://huggingface.co/pateluday/tallie/resolve/main/example.py
- Command line
-
hf download hf://pateluday/tallie/example.py
-
curl -L -o example.py https://huggingface.co/pateluday/tallie/resolve/main/example.py
783 Bytes
| """Minimal Tallie example. Run from inside the downloaded model folder: python example.py""" | |
| from pathlib import Path | |
| from tallie import Tallie | |
| here = Path(__file__).parent | |
| t = Tallie.load(here) | |
| comments = [ | |
| "Planet Money and EconTalk are the two podcasts I never skip.", | |
| "I tried 1Q84 twice and gave up, it's so slow.", | |
| "Honestly 99% Invisible is the best podcast out there.", | |
| "EconTalk changed how I think about economics.", | |
| ] | |
| for item in t.extract(comments): | |
| print(f"{item['text']:20s} type={item['type']:10s} opinion={item['polarity']}") | |
| t.index(comments) | |
| for q in ["podcasts people recommend", "books people disliked"]: | |
| print("\n" + q) | |
| for r in t.ask(q)["results"]: | |
| print(f" {r['item']:20s} {r['mentions']} mention(s) {r['polarity']}") | |