You can download this code by clicking the button below.
This code is now available for download.
This function uses the spaCy library to analyze the input text and extract all noun phrases. It first loads the English model, then processes the text with this model, and finally extracts the noun phrases from the processed document.
Technology Stack : spaCy
Code Type : Function
Code Difficulty : Intermediate
import spacy
from spacy.lang.en import English
def find_noun_phrases(text):
# Load English tokenizer, tagger, parser, NER and word vectors
nlp = English()
# Process whole documents
doc = nlp(text)
# Extract noun phrases
noun_phrases = [chunk.text for chunk in doc.noun_chunks]
return noun_phrases