System_Dialogowy_Janet/Code/Janet.py

43 lines
1.0 KiB
Python
Raw Normal View History

2021-05-27 15:11:28 +02:00
import jsgf
from Modules.NLG_module import NLG
from Modules.DP_module import DP
2021-05-30 13:31:34 +02:00
from Modules.DST_module import Rules_DST
2021-05-27 15:11:28 +02:00
from Modules.Book_NLU_module import Book_NLU
from Modules.ML_NLU_module import ML_NLU
import random
import torch
random.seed(42)
torch.manual_seed(42)
if torch.cuda.is_available():
torch.cuda.manual_seed(0)
torch.cuda.manual_seed_all(0)
torch.backends.cudnn.enabled = False
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True
class Janet:
def __init__(self):
2021-05-30 13:31:34 +02:00
self.nlg = NLG()
self.dp = DP()
self.dst = Rules_DST()
self.nlu = Book_NLU(jsgf.parse_grammar_file('book.jsgf'))
self.nlu_v2 = ML_NLU()
2021-05-27 15:11:28 +02:00
def process(self, command):
2021-05-30 13:31:34 +02:00
act = self.nlu_v2.test_nlu(command)
return self.dp.predict(self.dst.update(act))
#return self.nlg.change_to_text(dest_act)
2021-05-27 15:11:28 +02:00
def main():
janet = Janet()
while(1):
print('\n')
text = input("Wpisz tekst: ")
2021-05-30 13:31:34 +02:00
print(janet.process(text))
2021-05-27 15:11:28 +02:00
if __name__ == "__main__":
main()