當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Python TextBlob.noun_phrases()用法及代碼示例


借助TextBlob.noun_phrases()方法,我們可以通過使用獲得句子的名詞短語TextBlob.noun_phrases()方法。

用法: TextBlob.noun_phrases()
返回: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’]



相關用法


注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python | TextBlob.noun_phrases() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。