ibm watson cognitive - Tone analyser only returns analysis for 1 sentence -


when using tone analyser, able retrieve 1 result. example, if use following input text.

string m_stringtoanalyse = "the world rocks ! love !! bananas awesome! old king cole merry old soul!";

the results return analysis document level , sentence_id = 0, ie. "the world rocks !". analysis next 3 sentences not returned.

any idea doing wrong or missing out anything? case when running provided sample code well.

string m_stringtoanalyse = "this service enables people discover , understand, , revise impact of tone in content. uses linguistic analysis detect , interpret emotional, social, , language cues found in text.";

running tone analysis using sample code on sample sentence provided above return results document , first sentence only.

i have tried versions "2016-02-19" "2017-03-15" same results.

i believe if want sentence sentence analysis need send every separate sentence json object. return analysis in array id=sentence_num.

here example of 1 did using multiple youtube comments (using python):

def get_comments(video):     #get comments youtube api using requests      url = 'https://www.googleapis.com/youtube/v3/commentthreads?part=snippet&maxresults=100&videoid='+ video +'&key=' + youtube_credentials['api_key']      r = requests.get(url)     comment_dict = list()      # item in comments, add object list text of comment      item in r.json()['items']:         the_comment = {"text": item['snippet']['toplevelcomment']['snippet']['textoriginal']}         comment_dict.append(the_comment)      # return list json sentiment_analysis function     return json.dumps(comment_dict)  def sentiment_analysis(words):      # load watson credentials using python sdk      tone_analyzer = toneanalyzerv3(     username=watson_credentials['username'], password=watson_credentials['password'], version='2016-02-11')      # tone, based on json object passed sentiment_analysis     return_sentiment = json.dumps(tone_analyzer.tone(text=words), indent=2)     return_sentiment = json.loads(return_sentiment) 

afterwards can whatever want json object. note else looking @ if want analysis of many objects, can add sentences=false in tone_analyzer.tone function.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -