-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sample for Natural Language 1.1 launch #352
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add NL 1.0 changes to this PR
Also - per @gguuss, these changes may not be in production for everyone yet. Holding off on them for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is suspect, any reason the 0th result is not getting returned?
language/analyze.js
Outdated
@@ -32,7 +32,7 @@ function analyzeSentimentOfText (text) { | |||
// Detects the sentiment of the document | |||
document.detectSentiment() | |||
.then((results) => { | |||
const sentiment = results[0]; | |||
const sentiment = results[1].documentSentiment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it just that the first result is missing sentiment? I'm seeing that not all the entities returned have sentiment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, also IMO it's ok to publish if this doesn't affect the v1 sample.
const entities = results[0].entities; | ||
|
||
console.log(`Entities and sentiments:`) | ||
entities.forEach((entity) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget the mentions in entity sentiment:
from Python:
for entity in result.entities:
print('Mentions: ')
print(u'Name: "{}"'.format(entity.name))
for mention in entity.mentions:
print(u' Begin Offset : {}'.format(mention.text.begin_offset))
print(u' Content : {}'.format(mention.text.content))
print(u' Magnitude : {}'.format(mention.sentiment.magnitude))
print(u' Sentiment : {}'.format(mention.sentiment.score))
print(u' Type : {}'.format(mention.type))
print(u'Salience: {}'.format(entity.salience))
print(u'Sentiment: {}\n'.format(entity.sentiment))
* Fix NL tests * Add analyzeEntitySentiment sample * Fix failing tests * Add NL 1.0 features * Update dependencies
* Fix NL tests * Add analyzeEntitySentiment sample * Fix failing tests * Add NL 1.0 features * Update dependencies
No description provided.