該服務使應用程序經過社交媒體,企業數據或是其餘的數據信息得到個性化的看法。該服務利用語言學的分析方法,經過來自諸如郵件、短信、博客和論壇帖子中的數據,推斷出一些個體固有的性格特徵,包括「Big Five」(注:大五類性格特徵分析,一種心理學上的人格劃分系統),需求,價值。html
經過對複雜社交媒體信息的潛在分析,該服務能夠描述出一幅大體的反映用戶性格特徵的用戶畫像。基於這些結果,這個服務還能夠推斷出消費習慣,經過帶有時間戳的JSON數據,能夠得到消費的時間行爲。json
關於本服務描述的性格特徵模型詳見個性化模型segmentfault
關於消費模型,詳見消費偏好api
在bluemix上建立該服務實例,而且得到用戶名和密碼,具體參見詳見Watson使用指南。數組
得到帳戶信息(Get profile)app
爲輸入文本的做者生成一個個性化的帳戶。本服務能夠得到的最大內容是20MB,能夠分析阿拉伯語,英語,日語,或是西班牙語。ide
參數:ui
text (string型,最大20MB)code
content_type (string型,text/plain(默認)適用純文本、text/html適用網頁、application/json適用JSON數據,使用html或是純文本時徐添加對數據格式的描述「charset」,例如:content_type=text/plain;charset=utf-8)htm
content_language (string型, 支持語言ar(阿拉伯語)、en(默認,英語)、es(西班牙語)、ja(日語))
accept (string型,響應類型:application/json、text/csv)
、accept_language(string型,響應語言:ar (阿拉伯)、de (德)、en (英, 默認)、es (西)、fr (法)、it (意)、ja (日)、ko (韓)、pt-br (巴西,葡萄牙)、zh-cn (簡體中文)、zh-tw (繁體中文)
raw_scores (bool型, 在標準百分數上是否返回原始得分,設置爲false只返回標準百分數)
consumption_preferences (bool型,是否返回消費偏好,設置爲false,不返回)
csv_headers (bool型,是否返回一個csv響應)
profile(text, content_type='text/plain', content_language=None, accept='application/json', accept_language=None, raw_scores=False, consumption_preferences=False, csv_headers=False) personality_insights = PersonalityInsightsV3( version='2016-10-20', username='{username}', password='{password}') with open(join(dirname(__file__), './profile.json')) as profile_json: profile = personality_insights.profile( profile_json.read(), content_type='application/json', raw_scores=True, consumption_preferences=True) print(json.dumps(profile, indent=2))
返回結果
參數:
word_count (int型,必須,輸入文本中的單詞數)
processed_language (string型,必須,處理文本語言)
personality (對象,必須,大五類人格特徵的數組)
trait_id (string型,必須,惟一標識代表結果類型)
name (string型,必須,性格特徵)
category (string型,必須,性格類型)
percentile (number型,必須,性格特徵得分)
raw_scorce (number型, 原始得分)
children (對象,詳細信息)
needs (對象,必須,需求信息的數組,數組詳細內容同大五類)
values (對象,必須,價值信息的數組,詳細內容同大五類)
behavior (對象,有時間信息的詳細行爲)
trait_id (string型,必須,惟一標識代表結果類型)
name (string型,必須,性格特徵)
category (string型,必須,特徵類型)
percentage (number型,必須,輸入數據的時間百分比)
consumption_preferences (對象,消費偏好)
consumption_preference_category_id (string型,必須,類別惟一標識)
name (string型,必須,類別名)
consumption_preferences (對象,必須,消費偏好詳細信息)
consumption_preference_id (string型,必須,惟一標識)
name(string型,偏好名稱)
score (number型,偏好得分:0.0(不喜歡)、0.5(通常)、1.0(喜歡))
warnings (對象,必須,警告信息)
warning_id (string型,必須,惟一標識ID)
message (string型,必須,警告信息)
word_count_message (string型)
"word_count": 15223, "processed_language": "en", "personality": [ { "trait_id": "big5_openness", "name": "Openness", "category": "personality", "percentile": 0.8011555009553, "raw_score": 0.77565404255038, "children": [ { "trait_id": "facet_adventurousness", "name": "Adventurousness", "category": "personality", "percentile": 0.89755869047319, "raw_score": 0.54990704031219 }, . . . ] }, { "trait_id": "big5_conscientiousness", "name": "Conscientiousness", "category": "personality", "percentile": 0.81001753184176, "raw_score": 0.66899984888815, "children": [ { "trait_id": "facet_achievement_striving", "name": "Achievement striving", "category": "personality", "percentile": 0.84613299226628, "raw_score": 0.74240118454888 }, . . . ] }, { "trait_id": "big5_extraversion", "name": "Extraversion", "category": "personality", "percentile": 0.64980796071382, "raw_score": 0.56817738781166, "children": [ { "trait_id": "facet_activity_level", "name": "Activity level", "category": "personality", "percentile": 0.88220584913965, "raw_score": 0.60106995926143 }, . . . ] }, { "trait_id": "big5_agreeableness", "name": "Agreeableness", "category": "personality", "percentile": 0.94786124793821, "raw_score": 0.80677815631809, "children": [ { "trait_id": "facet_altruism", "name": "Altruism", "category": "personality", "percentile": 0.99241983824205, "raw_score": 0.79028406290747 }, . . . ] }, { "trait_id": "big5_neuroticism", "name": "Emotional range", "category": "personality", "percentile": 0.5008224041628, "raw_score": 0.46748200007024, "children": [ { "trait_id": "facet_anger", "name": "Fiery", "category": "personality", "percentile": 0.17640022058508, "raw_score": 0.48490315691802 }, . . . ] } ], "needs": [ { "trait_id": "need_challenge", "name": "Challenge", "category": "needs", "percentile": 0.67362332054511, "raw_score": 0.75196348037675 }, { "trait_id": "need_closeness", "name": "Closeness", "category": "needs", "percentile": 0.83802834041813, "raw_score": 0.83714327329724 }, . . . ], "values": [ { "trait_id": "value_conservation", "name": "Conservation", "category": "values", "percentile": 0.89268222856139, "raw_score": 0.72135308187423 }, { "trait_id": "value_openness_to_change", "name": "Openness to change", "category": "values", "percentile": 0.85759916388086, "raw_score": 0.82551308431323 }, . . . ], "behavior": [ { "trait_id": "behavior_sunday", "name": "Sunday", "category": "behavior", "percentage": 0.21392532795156 }, { "trait_id": "behavior_monday", "name": "Monday", "category": "behavior", "percentage": 0.42583249243189 }, . . . { "trait_id": "behavior_0000", "name": "0:00 am", "category": "behavior", "percentage": 0.4561049445005 }, { "trait_id": "behavior_0100", "name": "1:00 am", "category": "behavior", "percentage": 0.12209889001009 }, . . . ], "consumption_preferences": [ { "consumption_preference_category_id": "consumption_preferences_shopping", "name": "Purchasing Preferences", "consumption_preferences": [ { "consumption_preference_id": "consumption_preferences_automobile_ownership_cost", "name": "Prefers automobile ownership cost", "score": 0 }, . . . ] }, { "consumption_preference_category_id": "consumption_preferences_health_and_activity", "name": "Health & Activity Preferences", "consumption_preferences": [ { "consumption_preference_id": "consumption_preferences_eat_out", "name": "Prefers to eat out", "score": 1 }, . . . ] }, { "consumption_preference_category_id": "consumption_preferences_environmental_concern", "name": "Environmental Concern Preferences", "consumption_preferences": [ { "consumption_preference_id": "consumption_preferences_concerned_environment", "name": "Likely to be concerned about the environment", "score": 0 } ] }, { "consumption_preference_category_id": "consumption_preferences_entrepreneurship", "name": "Entreprenuership Preferences", "consumption_preferences": [ { "consumption_preference_id": "consumption_preferences_start_business", "name": "Likely to start a business in next few years", "score": 1 } ] }, { "consumption_preference_category_id": "consumption_preferences_movie", "name": "Movie Preferences", "consumption_preferences": [ { "consumption_preference_id": "consumption_preferences_movie_romance", "name": "Likely to like romance movies", "score": 1 }, . . . ] }, { "consumption_preference_category_id": "consumption_preferences_music", "name": "Music Preferences", "consumption_preferences": [ { "consumption_preference_id": "consumption_preferences_music_rap", "name": "Likely to like rap music", "score": 1 }, . . . ] }, { "consumption_preference_category_id": "consumption_preferences_reading", "name": "Reading Preferences", "consumption_preferences": [ { "consumption_preference_id": "consumption_preferences_read_frequency", "name": "Reading frequency", "score": 0 }, . . . ] }, { "consumption_preference_category_id": "consumption_preferences_volunteering", "name": "Volunteering Preferences", "consumption_preferences": [ { "consumption_preference_id": "consumption_preferences_volunteer", "name": "Have volunteering experience", "score": 0 } ] } ], "warnings": [] }
文檔原文地址:http://www.ibm.com/watson/dev...
該服務使用語言學的分析方式檢測情感語調,社交傾向和書面寫做風格
在bluemix上建立該服務實例,而且得到用戶名和密碼,具體參見詳見Watson使用指南。
import json from watson_developer_cloud import ToneAnalyzerV3 tone_analyzer = ToneAnalyzerV3( username='YOUR SERVICE USERNAME', password='YOUR SERVICE PASSWORD', version='2016-05-19')
語調分析(Analyzer tone)
分析一段文本的語調。語調包括社交態度,感情,語言。每一類都有衍生的更多內容。
參數:
text (query型,GET必須,待分析文檔,至少三個單詞)
body (body型,POST必須,JSON或純文本,待分析文檔)
Content-Type (header型,POST必須,待分析文檔類型)
version (query型, 必須,版本號,當前最新:2016-05-19)
tone (query型,語調分類標籤)
sentences (query型,過濾句子層次)
import json from watson_developer_cloud import ToneAnalyzerV3 tone_analyzer = ToneAnalyzerV3( username='YOUR SERVICE USERNAME', password='YOUR SERVICE PASSWORD', version='2016-05-19 ') print(json.dumps(tone_analyzer.tone(text='A word is dead when it is said, some say. Emily Dickinson'), indent=2))
返回結果
參數:
document_tone (所有文檔的語調分析)
tone_categories(語調類別:感情,語言,社交態度)
tones (具體信息。感情:anger、disgust、fear、joy、sadness;語言:analytical、confident、tentative(試探性);社交態度:openness、conscientiousness(責任)、extraversion(外向)、agreeableness、emotion_range)
score (語調得分)
tone_id (語調惟一標識)
category_id (語調類別)
category_name (類別名)
sentences_tone (句子層次語調分析)
sentence_id (句子惟一編號)
text (正在分析的文本)
input_from (句子中第一個字母的序號)
input_to (句子中最後一個字母的序號)
{ "document_tone": { "tone_categories": [ { "tones": [ { "score": 0.25482, "tone_id": "anger", "tone_name": "Anger" }, { "score": 0.345816, "tone_id": "disgust", "tone_name": "Disgust" }, { "score": 0.121116, "tone_id": "fear", "tone_name": "Fear" }, { "score": 0.078903, "tone_id": "joy", "tone_name": "Joy" }, { "score": 0.199345, "tone_id": "sadness", "tone_name": "Sadness" } ], "category_id": "emotion_tone", "category_name": "Emotion Tone" }, { "tones": [ { "score": 0.999, "tone_id": "analytical", "tone_name": "Analytical" }, { "score": 0.999, "tone_id": "confident", "tone_name": "Confident" }, { "score": 0.694, "tone_id": "tentative", "tone_name": "Tentative" } ], "category_id": "language_tone", "category_name": "Language Tone" }, { "tones": [ { "score": 0.271, "tone_id": "openness_big5", "tone_name": "Openness" }, { "score": 0.11, "tone_id": "conscientiousness_big5", "tone_name": "Conscientiousness" }, { "score": 0.844, "tone_id": "extraversion_big5", "tone_name": "Extraversion" }, { "score": 0.257, "tone_id": "agreeableness_big5", "tone_name": "Agreeableness" }, { "score": 0.497, "tone_id": "emotional_range_big5", "tone_name": "Emotional Range" } ], "category_id": "social_tone", "category_name": "Social Tone" } ] } }