fix
This commit is contained in:
parent
38a1d614cf
commit
d9e04453f9
17
NLU.py
17
NLU.py
|
@ -46,8 +46,12 @@ class NLU:
|
|||
# Else add original token text
|
||||
else:
|
||||
output_string += token.text + token.whitespace_
|
||||
cleaned_query = output_string.split(" <COREF_SEP_TOKEN> ", 1)[1]
|
||||
return cleaned_query
|
||||
if len(output_string.split(" <COREF_SEP_TOKEN> ", 1)) > 1:
|
||||
cleaned_query = output_string.split(" <COREF_SEP_TOKEN> ", 1)[1]
|
||||
return cleaned_query
|
||||
else:
|
||||
cleaned_query = output_string.split(" <COREF_SEP_TOKEN> ", 1)[0]
|
||||
return cleaned_query
|
||||
|
||||
def _intentpredictor(self):
|
||||
pred = self.intent_classifier(self.to_process)[0]
|
||||
|
@ -89,9 +93,10 @@ class NLU:
|
|||
self.to_process = self._resolve_coref(history_consec)
|
||||
|
||||
intent, score = self._intentpredictor()
|
||||
if intent == 'CHITCHAT':
|
||||
self.to_process = utterance
|
||||
|
||||
if score > 0.5:
|
||||
if intent == 'CHITCHAT':
|
||||
self.to_process = utterance
|
||||
entities = self._entityextractor()
|
||||
offense = self._offensepredictor()
|
||||
if intent in ['FINDPAPER', 'FINDDATASET', 'SUMMARIZEPAPER'] and len(entities) == 0:
|
||||
|
@ -104,6 +109,8 @@ class NLU:
|
|||
entities = self._entityextractor()
|
||||
offense = self._offensepredictor()
|
||||
if score > 0.5 or not self._ambigpredictor():
|
||||
if intent == 'CHITCHAT':
|
||||
self.to_process = utterance
|
||||
if intent in ['FINDPAPER', 'FINDDATASET', 'SUMMARIZEPAPER'] and len(entities) == 0:
|
||||
return {"modified_query": self.to_process, "intent": intent, "entities": entities, "is_offensive": offense, "is_clear": False}
|
||||
return {"modified_query": self.to_process, "intent": intent, "entities": entities, "is_offensive": offense,
|
||||
|
@ -114,6 +121,8 @@ class NLU:
|
|||
else:
|
||||
entities = self._entityextractor()
|
||||
offense = self._offensepredictor()
|
||||
if intent == 'CHITCHAT':
|
||||
self.to_process = utterance
|
||||
if intent in ['FINDPAPER', 'FINDDATASET', 'SUMMARIZEPAPER'] and len(entities) == 0:
|
||||
return {"modified_query": self.to_process, "intent": intent, "entities": entities, "is_offensive": offense, "is_clear": False}
|
||||
return {"modified_query": self.to_process, "intent": intent, "entities": entities, "is_offensive": offense, "is_clear": True}
|
||||
|
|
Loading…
Reference in New Issue