From 1af80df02814d1272d4f61f76ae5503a1578c5e0 Mon Sep 17 00:00:00 2001 From: Dominik Strzako Date: Sun, 16 May 2021 20:09:54 +0200 Subject: [PATCH] second version (hopefully working correctly) --- Makiety.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Makiety.py b/Makiety.py index fa9bfc8..efc6145 100644 --- a/Makiety.py +++ b/Makiety.py @@ -30,6 +30,7 @@ class ML_NLU: def __init__(self, acts, arguments): self.acts = acts self.arguments = arguments + self.model = self.setup() def nolabel2o(self, line, i): return 'O' if line[i] == 'NoLabel' else line[i] @@ -66,9 +67,9 @@ class ML_NLU: else: fields = ['id', 'form', 'frame', 'slot'] - with open('Janet_test.conllu', encoding='utf-8') as trainfile: + with open('Janet.conllu', encoding='utf-8') as trainfile: trainset = list(parse_incr(trainfile, fields=fields, field_parsers={'slot': self.nolabel2o})) - with open('Janet_test.conllu', encoding='utf-8') as testfile: + with open('Janet.conllu', encoding='utf-8') as testfile: testset = list(parse_incr(testfile, fields=fields, field_parsers={'slot': self.nolabel2o})) tabulate(trainset[0], tablefmt='html') @@ -102,10 +103,8 @@ class ML_NLU: def test_nlu(self, utterance): - model = self.setup() - if utterance: - return tabulate(self.predict(model, 'doktor lekarza rodzinnego najlepiej dzisiaj w godzinach popołudniowych dziś '.split()), tablefmt='html') + return tabulate(self.predict(self.model, 'doktor lekarza rodzinnego najlepiej dzisiaj w godzinach popołudniowych dziś '.split()), tablefmt='html') else: return 'Critical Error'