-
Notifications
You must be signed in to change notification settings - Fork 1k
Updated existing Language samples and added entity_sentiment samples #431
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
Conversation
bshaffer
left a comment
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.
Some really basic stuff. Really the only requirement I have is to remove the unneeded dependencies.
Another main concern I have is whether we can simplify the output. The sample contains 30 lines of printing the response. This makes the real meat of the sample, the API call, harder to locate. If we can cut down so that printing the response is only ~10 lines, this is optimal.
If it's really important to show "mentions" in the output, as well as the other properties, then I'm ok with keeping the verbose printing. As long as we have a good reason.
language/api/composer.json
Outdated
| "symfony/console": "^3.0", | ||
| "google/cloud-storage": "^1.0", | ||
| "symfony/yaml": "^3.2" | ||
| "symfony/yaml": "^3.2", |
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.
We can remove this, since you've gotten rid of the Yaml calls below.
language/api/composer.json
Outdated
| "symfony/yaml": "^3.2", | ||
| "google/gax": "^0.21.2", | ||
| "grpc/grpc": "^v1.1.0", | ||
| "google/protobuf": "^v3.3.0", |
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.
The dependency google/gax is managed by google/proto-client, and the dependencies grpc/grpc and google/protobuf are maintained by google/gax. So, we can remove these three dependencies. The only new one we need is google/proto-client.
| if (array_key_exists('wikipedia_url', $entity['metadata'])) { | ||
| printf('Wikipedia URL: %s' . PHP_EOL, $entity['metadata']['wikipedia_url']); | ||
| } | ||
| if (array_key_exists('mid', $entity['metadata'])) { |
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.
We don't need to print every single possible property - maybe we should exclude this one? What do the other languages do? As a base line, for simplicity, we could leave out all "optional" properties.
| printf('Entity Magnitude: %s' . PHP_EOL, $entity->getSentiment()->getMagnitude()); | ||
| printf('Entity Score: %s' . PHP_EOL, $entity->getSentiment()->getScore()); | ||
| printf('Mentions: ' . PHP_EOL); | ||
| foreach ($entity->getMentions() as $mention) { |
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.
dumb question - what is a mention? For simplicity, can we exclude printing them out every time, or do the other languages do this also?
|
You will need to run |
|
thanks Brent. Yeah - I noticed the Travis dependency error. Running into a small roadblock reverting back to PHP 5.6 with phpenv but hopefully I'll be able to fix it soon! |
No description provided.