second version (hopefully working correctly)
This commit is contained in:
parent
9554c3d812
commit
1af80df028
@ -30,6 +30,7 @@ class ML_NLU:
|
|||||||
def __init__(self, acts, arguments):
|
def __init__(self, acts, arguments):
|
||||||
self.acts = acts
|
self.acts = acts
|
||||||
self.arguments = arguments
|
self.arguments = arguments
|
||||||
|
self.model = self.setup()
|
||||||
|
|
||||||
def nolabel2o(self, line, i):
|
def nolabel2o(self, line, i):
|
||||||
return 'O' if line[i] == 'NoLabel' else line[i]
|
return 'O' if line[i] == 'NoLabel' else line[i]
|
||||||
@ -66,9 +67,9 @@ class ML_NLU:
|
|||||||
else:
|
else:
|
||||||
fields = ['id', 'form', 'frame', 'slot']
|
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}))
|
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}))
|
testset = list(parse_incr(testfile, fields=fields, field_parsers={'slot': self.nolabel2o}))
|
||||||
|
|
||||||
tabulate(trainset[0], tablefmt='html')
|
tabulate(trainset[0], tablefmt='html')
|
||||||
@ -102,10 +103,8 @@ class ML_NLU:
|
|||||||
|
|
||||||
def test_nlu(self, utterance):
|
def test_nlu(self, utterance):
|
||||||
|
|
||||||
model = self.setup()
|
|
||||||
|
|
||||||
if utterance:
|
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:
|
else:
|
||||||
return 'Critical Error'
|
return 'Critical Error'
|
||||||
|
Loading…
Reference in New Issue
Block a user