helper/main.py

28 lines
837 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
import sys
from src.myontology import MyOntology
from src.nlp import NLP
from src.parse_tree.parse_tree import ParseTree
from src.syntax import Syntax
def _main(wav_file: str):
# text: str = Speech().run_recognition(wav_file)
text: str = 'У меня кредит в другом банке. Можно ли его перевести в ваш банк? '
print(f'Text: {text}')
parse_tree: ParseTree = Syntax().get_parse_tree(text)
print(f'Parse tree:\n{parse_tree}')
terms = NLP().get_terms(parse_tree)
print(f'Extracted terms:\n{", ".join(terms)}')
result: str = MyOntology().get_event_description(terms)
print(f'Result:\n{result}')
if __name__ == '__main__':
if len(sys.argv) < 2:
print(f'Usage: {sys.argv[0]} FILE')
exit(1)
_main(sys.argv[1])