You can download this code by clicking the button below.
This code is now available for download.
This function uses the spaCy library to extract noun phrases from a text. It takes a text and a spaCy nlp object as input and returns a list of all noun phrases.
Technology Stack : spaCy
Code Type : The type of code
Code Difficulty : Intermediate
def extract_noun_phrases(text, nlp):
doc = nlp(text)
noun_phrases = [token.text for token in doc if token.pos_ == "NOUN" or token.dep_ == "compound"]
return noun_phrases