Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.6 kB · 48 lines
Python
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849"""Type lines as the player and see the discourse acts Jev produces.
python -m sidecar.repl python -m sidecar.repl "Trip, you are so controlling"
Talks to Jev directly, so the server does not need to be running."""import sys
from .classify import Utterance, classifyfrom .config import load_settingsfrom .jev_client import JevClient, JevError
def show(text, client, settings): try: result = classify(Utterance(text=text), client, settings) except JevError as error: print(" error: %s" % error) return for act in result.acts: params = ", ".join(p for p in act.param_names if p) print(" %-24s id=%-3d char=%-2d params=(%d, %d, %d) %s p %.2f" % ( act.name, act.da_id, act.char_id, act.param1, act.param2, act.param3, "[" + params + "]" if params else "", act.probability)) top = result.answers["act"] ranked = sorted(top.probabilities.items(), key=lambda kv: -kv[1])[:3] print(" act distribution: " + " ".join("%s %.2f" % kv for kv in ranked))
def main(): settings = load_settings() client = JevClient.from_settings(settings) if len(sys.argv) > 1: return show(" ".join(sys.argv[1:]), client, settings) print("Say something to Trip and Grace. Blank line or Ctrl+C quits.") while True: try: text = input("> ").strip() except (EOFError, KeyboardInterrupt): return if not text: return show(text, client, settings)
if __name__ == "__main__": main()