Python| TextBlob.noun_phrases() 方法
借助TextBlob.noun_phrases()
方法,我们可以使用TextBlob.noun_phrases()
方法获取句子的名词短语。
Syntax : TextBlob.noun_phrases()
Return : Return list of noun values.
示例 #1:
在这个例子中,我们可以说通过使用TextBlob.noun_phrases()
方法,我们可以获得名词词列表。
# import TextBlob
from textblob import TextBlob
gfg = TextBlob("Python is a high-level language.")
# using TextBlob.noun_phrases method
gfg = gfg.noun_phrases
print(gfg)
输出 :
[‘python’, ‘high-level language’]
示例 #2:
# import TextBlob
from textblob import TextBlob
gfg = TextBlob("Sandeep Jain An IIT Roorkee alumnus and founder of GeeksforGeeks. He loves to solve programming problems in most efficient ways.")
# using TextBlob.noun_phrases method
gfg = gfg.noun_phrases
print(gfg)
输出 :
[‘sandeep jain’, ‘iit roorkee’, ‘geeksforgeeks’, ‘efficient ways’]