philippotiger's picture
Upload run.py with huggingface_hub
760d152 verified
raw
history blame contribute delete
882 Bytes
"""
Usage:
python run.py # interactive mode, paste your text
python run.py "your tip text here" # pass text directly as argument
cat tips.txt | python run.py # pipe from a file
"""
import sys
import json
from inference_local import extract
def main():
# ── Mode 1: argument passed directly ──
if len(sys.argv) > 1:
text = " ".join(sys.argv[1:])
# ── Mode 2: piped from stdin (cat file | python run.py) ──
elif not sys.stdin.isatty():
text = sys.stdin.read()
# ── Mode 3: interactive, paste and press Ctrl+D ──
else:
print("Paste your prediction text below.")
print("Press Ctrl+D (Mac) when done:\n")
text = sys.stdin.read()
result = extract(text)
print(json.dumps(result, indent=2, ensure_ascii=False))
if __name__ == "__main__":
main()