-
Notifications
You must be signed in to change notification settings - Fork 1k
NL classifyText samples and client library version update #479
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.
This looks great! Some minor changes, and we need to add the new commands to the README.
language/api/src/classify_text.php
Outdated
| { | ||
| // Make sure we have enough words (20+) to call classifyText | ||
| if (str_word_count($text) < 20) { | ||
| printf('20+ words are required to call classifyText.' . PHP_EOL); |
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.
Should be 20+ words are required to classify text.
language/api/src/classify_text.php
Outdated
| /** | ||
| * Find the entities in text. The text needs to be 20+ words to call classifyText. | ||
| * ``` | ||
| * classify_text('The first two gubernatorial elections since President Donald Trump took office went in favor of Democratic candidates in Virginia and New Jersey.'); |
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 wrap this:
/**
* //...
* classify_text(
* 'The first two gubernatorial elections since President Donald Trump ' .
* 'took office went in favor of Democratic candidates in Virginia and ' .
* 'New Jersey.'
* );
* //...
*/| * | ||
| * @param string $cloud_storage_uri Your Cloud Storage bucket URI | ||
| * @param string $projectId (optional) Your Google Cloud Project ID | ||
| * |
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.
remove extra line
language/api/src/classify_text.php
Outdated
| * | ||
| * @param string $text The text to analyze. | ||
| * @param string $projectId (optional) Your Google Cloud Project ID | ||
| * |
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.
remove extra line
language/api/test/languageTest.php
Outdated
|
|
||
| public function testClassifyText() | ||
| { | ||
| $output = $this->runCommand('classify', 'The first two gubernatorial elections since President Donald Trump took office went in favor of Democratic candidates in Virginia and New Jersey.'); |
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.
wrap this one as well
| /** | ||
| * For instructions on how to run the full sample: | ||
| * | ||
| * @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/language/README.md |
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 link is wrong, it should be language/api/README.md. Please update for all samples!
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.
This looks great! Just one more thing... Since we're already making these changes, it'd be great to consolidate the quickstart.php example with the API example and move these into php-docs-samples/language (meaning the link to the README you fixed earlier would actually need to be reverted 😛 ).
Then we'd need to update the paths to the other language samples on devsite, but this would be easy to do since it'd all happen at once.
|
|
||
| To run the Analyze Entity Sentiment sample: | ||
|
|
||
| $ php language.php entity-sentiment 'New York is great. New York is good.' |
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.
Looks like we need to add entity-sentiment and classify to the list of Available commands up top, e.g:
Available commands:
all Analyze syntax, sentiment and entities in text.
classify Classify text into categories.
entities Analyze entities in text.
entity-sentiment Analyze entity sentiment in text.
help Displays help for a command
list Lists commands
sentiment Analyze sentiment in text.
syntax Analyze syntax in text.
language/api/language.php
Outdated
| ->setHelp(<<<EOF | ||
| The <info>%command.name%</info> command classifies text into categories using the Google Cloud Natural Language API. | ||
| <info>php %command.full_name% Text to analyze.</info> |
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.
Probably should be Text to classify.
|
This is all ready to go! Let's coordinate with the docs change (so the docs don't link to the moved files) and then we can merge these suckers! |
Ready for review. High priority to merge soon because of a launch.