def simple_NER(text): test = textblob(text) result = [] for i, word in enumerate(test.tags): position = i if word[0].find("AG") > -1 or word[0].find("GmbH") > -1: named_entity = word[0] prev_words = test.tags[:position] prev_words.reverse() for k in prev_words: if k[1] in ["NN", "NNP", "JJ"]: named_entity = k[0] + " " + named_entity else: result.append(named_entity) break return result
def stanford_ner(text): blob = textblob(text) st = NERTagger(r'C:\Users\Andreas\Downloads\stanford-ner-2014-10-26\stanford-ner-2014-10-26\classifiers\hgc_175m_600.crf.ser.gz', r'C:\Users\Andreas\Downloads\stanford-ner-2014-10-26\stanford-ner-2014-10-26\stanford-ner.jar', 'ISO-8859-1') return st.tag(blob.words)