Untitled

mail@pastecode.io avatarunknown
plain_text
a month ago
281 B
1
Indexable
Never
def noun_extraction(text):
    # function to test if something is a noun
    is_noun = lambda pos: pos[:2] == 'NN'
    # do the nlp stuff
    tokenized = nltk.word_tokenize(text)
    nouns = [word for (word, pos) in nltk.pos_tag(tokenized) if is_noun(pos)]

    return nouns