summaryrefslogtreecommitdiff
path: root/__main__.py
diff options
context:
space:
mode:
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