@overrides
def infer(self, instance, *args, **kwargs):
instance = instance.strip()
if not len(instance):
return dict()
return self.predict_slots(instance.lower())
After Change
@overrides
def infer(self, instance, *args, **kwargs):
instance = instance.strip().lower()
if not all([ord(c) < 128 for c in instance]):
print("Non ASCII symbols in the string, returning empty slots", file=sys.stderr)
return {}
tokens = tokenize_reg(instance)
if len(tokens) > 0:
return self.predict_slots(tokens)
else:
return {}
def interact(self):
s = input("Type in the message you want to tag: ")
prediction = self.predict_slots(s)
print(prediction)