How to get all noun phrases in Spacy

后端 未结 3 1132
轮回少年
轮回少年 2021-02-14 17:06

I am new to Spacy and I would like to extract \"all\" the noun phrases from a sentence. I\'m wondering how I can do it. I have the following code:

i         


        
3条回答
  •  甜味超标
    2021-02-14 17:32

    Please try this to get all nouns from a text:

    import spacy
    nlp = spacy.load("en_core_web_sm")
    text = ("We try to explicitly describe the geometry of the edges of the images.")
    doc = nlp(text)
    print([chunk.text for chunk in doc.noun_chunks])
    

提交回复
热议问题