本文整理匯總了Python中watson_developer_cloud.ToneAnalyzerV3方法的典型用法代碼示例。如果您正苦於以下問題:Python watson_developer_cloud.ToneAnalyzerV3方法的具體用法?Python watson_developer_cloud.ToneAnalyzerV3怎麽用?Python watson_developer_cloud.ToneAnalyzerV3使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類watson_developer_cloud
的用法示例。
在下文中一共展示了watson_developer_cloud.ToneAnalyzerV3方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: analyze
# 需要導入模塊: import watson_developer_cloud [as 別名]
# 或者: from watson_developer_cloud import ToneAnalyzerV3 [as 別名]
def analyze(url):
alchemy_language = AlchemyLanguageV1(api_key=api_key_alc)
combined_operations = [ 'entity', 'keyword', 'title', 'concept', 'doc-emotion']
global data
data = alchemy_language.combined(url=url, extract=combined_operations)
tone_analyzer = ToneAnalyzerV3(username=toneUser,password=tonePass,version='2016-05-19')
global tone
text=webScrape.getText(url)
text = text.encode('ascii','ignore')
if len(text)>120000:
text = text[0:120000]
if text.count('\n')>750:
text = text[0:URLHelper.linSearch(text,'\n', 750)]
tone = tone_analyzer.tone(text=text)['document_tone']['tone_categories']
示例2: tone_analyzer_example
# 需要導入模塊: import watson_developer_cloud [as 別名]
# 或者: from watson_developer_cloud import ToneAnalyzerV3 [as 別名]
def tone_analyzer_example():
tone_analyzer = ToneAnalyzerV3(username=TONE_ANALYZER_USERNAME, password=TONE_ANALYZER_PASSWORD,
version='2016-05-19')
text = __read_text()
document_tone = tone_analyzer.tone(text=text)
dataframe = __create_dataframe(document_tone)
__save_csv(dataframe)
__create_heatmap(dataframe)