helper/src/main.py

34 lines
878 B
Python
Raw Normal View History

2022-01-13 20:23:35 +04:00
#!/usr/bin/env python3
import sys
2022-01-14 16:58:50 +04:00
import warnings
2022-01-13 20:23:35 +04:00
2022-01-24 17:04:54 +04:00
from src.nlp import NLP
2022-01-25 09:53:33 +04:00
from src.ontology import Ontology
2022-01-14 17:07:18 +04:00
from syntax import Syntax
2022-01-13 20:23:35 +04:00
2022-01-14 16:58:50 +04:00
if not sys.warnoptions:
warnings.simplefilter("ignore")
2022-01-13 20:23:35 +04:00
def _main():
if len(sys.argv) < 2:
2022-01-14 16:58:50 +04:00
print(f'Usage: {sys.argv[0]} FILE')
2022-01-13 20:23:35 +04:00
exit(1)
2022-01-24 17:04:54 +04:00
# wav_file = sys.argv[1]
# speech_server = 'http://vosk.athene.tech'
2022-01-25 14:12:45 +04:00
# text = Speech().run_recognition(wav_file, speech_server)
2022-01-24 17:04:54 +04:00
text = 'не могу оплатить из-за ограничений карты'
2022-01-14 16:58:50 +04:00
print(f'Text: {text}')
2022-01-14 17:11:12 +04:00
syntax_server = 'http://syntaxnet.athene.tech'
2022-01-25 14:12:45 +04:00
parse_tree = Syntax().get_parse_tree(text, syntax_server)
2022-01-14 17:43:40 +04:00
print(f'Parse tree:\n{parse_tree}')
2022-01-25 14:12:45 +04:00
nouns = NLP().get_nouns(parse_tree)
2022-01-24 17:04:54 +04:00
print(f'Nouns:\n{nouns}')
2022-01-25 09:53:33 +04:00
onto = Ontology()
2022-01-25 14:12:45 +04:00
print(f'Test: {onto.get_event()}')
2022-01-13 20:23:35 +04:00
if __name__ == '__main__':
2022-01-14 16:58:50 +04:00
_main()