Skip to content
Snippets Groups Projects
Unverified Commit 2236ae82 authored by aaa123git's avatar aaa123git Committed by GitHub
Browse files

fix bug. replace 'id' with 'ID' (#198)

parent a067adb8
Branches
No related tags found
No related merge requests found
import os import os
import re
import zipfile import zipfile
import json import json
import torch import torch
...@@ -66,6 +67,8 @@ class BERTNLU(NLU): ...@@ -66,6 +67,8 @@ class BERTNLU(NLU):
print("BERTNLU loaded") print("BERTNLU loaded")
def predict(self, utterance, context=list()): def predict(self, utterance, context=list()):
# Note: spacy cannot tokenize 'id' or 'Id' correctly.
utterance = re.sub(r'\b(id|Id)\b', 'ID', utterance)
# tokenization first, very important! # tokenization first, very important!
ori_word_seq = [token.text for token in self.nlp(unidecode(utterance)) if token.text.strip()] ori_word_seq = [token.text for token in self.nlp(unidecode(utterance)) if token.text.strip()]
# print(ori_word_seq) # print(ori_word_seq)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment