Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ def load_models(self, loc=None):
loc = os.path.join(os.path.expanduser('~'), '.ner_model')
self.model = load_model(os.path.join(loc,"model.h5"))
# loading word2Idx
np.load.__defaults__=(None, True, True, 'ASCII')
self.word2Idx = np.load(os.path.join(loc,"word2Idx.npy")).item()
# loading idx2Label
self.idx2Label = np.load(os.path.join(loc,"idx2Label.npy")).item()
np.load.__defaults__=(None, False, True, 'ASCII')

def getCasing(self,word, caseLookup):
casing = 'other'
Expand Down Expand Up @@ -93,4 +95,4 @@ def predict(self,Sentence):
pred = self.model.predict([tokens, casing,char], verbose=False)[0]
pred = pred.argmax(axis=-1)
pred = [self.idx2Label[x].strip() for x in pred]
return list(zip(words,pred))
return list(zip(words,pred))