spaCy - Doc.noun_chunks 屬性
此 doc 屬性用於在特定文件中迭代基礎名詞短語。如果該文件已進行句法分析,則此屬性將產生基礎名詞短語跨度物件。
示例 1
Doc.noun_chunks 屬性的示例如下 -
import spacy
nlp_model = spacy.load("en_core_web_sm")
doc = nlp_model("The website is Tutorialspoint.com.")
chunks = list(doc.noun_chunks)
chunks[0].text
輸出
輸出如下 -
'The website'
示例 2
以下是 Doc.noun_chunks 屬性的示例 -
chunks[1].text
輸出
'Tutorialspoint.com'
spacy_doc_class_contextmanager_and_property.htm
廣告