Skip to content

Commit

Permalink
pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredfrancis committed Apr 4, 2018
1 parent 26b1ed2 commit d354582
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/nlu/entity_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def train(self,train_sentences, model_name):


# Extract Labeles from BIO tagged sentence
def extract_entities(self,tagged_sentence):
def crf2json(self, tagged_sentence):
"""
Extract label-value pair from NER prediction output
:param tagged_sentence:
Expand All @@ -128,7 +128,7 @@ def extract_entities(self,tagged_sentence):
return labeled


def extract_labels(self,predicted_labels):
def extract_ner_labels(self, predicted_labels):
"""
Extract name of labels from NER
:param predicted_labels:
Expand All @@ -149,13 +149,13 @@ def predict(self,model_name, sentence):
:return:
"""
from app.nlu.tasks import pos_tagger

tokenized_sentence = word_tokenize(sentence)
tagged_token = pos_tagger(sentence)
tagger = pycrfsuite.Tagger()
tagger.open("{}/{}.model".format(app.config["MODELS_DIR"], model_name))
predicted_labels = tagger.tag(self.sent_to_features(tagged_token))
extracted_entities = self.extract_entities(
extracted_entities = self.crf2json(
zip(tokenized_sentence, predicted_labels))
return extracted_entities

Expand Down

0 comments on commit d354582

Please sign in to comment.