summaryrefslogtreecommitdiff
path: root/__main__.py
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-11-20 11:55:10 +0100
committerBotond Hende <nettingman@gmail.com>2024-11-20 11:55:10 +0100
commit528d65c6bd9954cfd96de57de05498dc4c563e0f (patch)
treec1f8f92f6c0311170e71aead67e6e3531458be2c /__main__.py
parent6f3acbf0bec6bf012c5f52aee2f18059918104d9 (diff)
moved input to another package
Diffstat (limited to '__main__.py')
-rw-r--r--__main__.py32
1 files changed, 13 insertions, 19 deletions
diff --git a/__main__.py b/__main__.py
index 008ceb4..4677b7c 100644
--- a/__main__.py
+++ b/__main__.py
@@ -7,6 +7,7 @@ from .modules.config import load_config
from .modules.hassil.recognize import recognize
from .modules.hassil.util import merge_dict
from .modules.hassil.intents import Intents, TextSlotList
+from .modules.input_handlers.stdin_input import get_input_stdin
from .modules.intents import *
@@ -37,25 +38,18 @@ def main():
intents = Intents.from_dict(input_dict)
- try:
- for line in sys.stdin:
- line = line.strip()
- if not line:
- continue
-
- result = recognize(line, intents, slot_lists=slot_lists)
- if result is not None:
- result_dict = {
- "intent": result.intent.name,
- **{e.name: e.value for e in result.entities_list},
- }
- print(result_dict)
- handler = getattr(globals()[result_dict["domain"]], result_dict["intent"])
- handler(result_dict, config)
- else:
- print("<no match>")
- except KeyboardInterrupt:
- pass
+ for input_text in get_input_stdin():
+ result = recognize(input_text, intents, slot_lists=slot_lists)
+ if result is not None:
+ result_dict = {
+ "intent": result.intent.name,
+ **{e.name: e.value for e in result.entities_list},
+ }
+ print(result_dict)
+ handler = getattr(globals()[result_dict["domain"]], result_dict["intent"])
+ handler(result_dict, config)
+ else:
+ print("<no match>")
if __name__ == '__main__':
main() \ No newline at end of file