Write a python function for Named Entity Recognizer using NLTK


Topic: Write a python function for Named Entity Recognizer using NLTK

Solution

def ner_checker(texts):
    all_set = set()
    def nltk_ner_check(texts):
        for i, text in texts:
            for entity in nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(text))):
                if isinstance(entity, nltk.tree.Tree):
                    etext = " ".join([word for word, tag in entity.leaves()])
                    # label = entity.label()
                    all_set.add(etext)
    nltk_ner_check(texts=texts)
    return all_set



List all Python Programs