Skip to content

Conversation

@ryanmats
Copy link
Contributor

@ryanmats ryanmats commented Nov 9, 2017

Ready for review. High priority to merge soon because of a launch.

@ryanmats ryanmats requested a review from bshaffer November 9, 2017 01:31
Copy link
Contributor

@bshaffer bshaffer left a 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.

{
// 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);
Copy link
Contributor

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.

/**
* 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.');
Copy link
Contributor

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
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra line

*
* @param string $text The text to analyze.
* @param string $projectId (optional) Your Google Cloud Project ID
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra line


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.');
Copy link
Contributor

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
Copy link
Contributor

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!

Copy link
Contributor

@bshaffer bshaffer left a 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.'
Copy link
Contributor

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.

->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>
Copy link
Contributor

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.

@bshaffer
Copy link
Contributor

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!

@ryanmats ryanmats merged commit 6584b3c into master Nov 13, 2017
@bshaffer bshaffer deleted the nl-classify-text branch November 14, 2017 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants