-
Notifications
You must be signed in to change notification settings - Fork 1k
Add gcs example to language #177
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
| <info>php %command.full_name% Text to analyze.</info> | ||
| <info>php %command.full_name% gs://my_bucket/file_with_text.txt</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.
underscores are invalid in GCS buckets!!
| $text = implode(" ", $input->getArgument('text')); | ||
| $result = analyze_entities($text); | ||
| $content = implode(' ', (array) $input->getArgument('content')); | ||
| if (preg_match('/gs:\/\/([a-z|0-9|\.|-]+)\/(\S+)/', $content, $matches)) { |
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.
Add a comment explaining the regexp.
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.
Repeat for similar code below.
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.
done!
|
|
||
| /** | ||
| * Command line utility to transcribe. | ||
| * Command line utility for the Natural Language APIs. |
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.
Small nit: Is this really a utility? I'd call it command line sample or somthing
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.
It is both a utility and a sample. I do not think we need to change this.
| * Command line utility for the Natural Language APIs. | ||
| * | ||
| * Usage: php speech.php transcribe | ||
| * Usage: php language.php entities |
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 usage is not complete because there is argument. Remove it, or make it complete.
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.
done.
| 'content', | ||
| InputArgument::IS_ARRAY | InputArgument::REQUIRED, | ||
| 'Text to analyze' | ||
| 'Text or path to Cloud Storage file' |
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.
I feel little bit weird to use the same argument for the text and the gs path.
I think it's simpler if you make the text argument OPTIONAL (actually it's conditionally required), and add an option --gs-path or something?
If the text contains the sub-text "gs://your-bucket/your-object", does it match the regex?
For example, can you analyze the following text?
To analyze the text stored in cloud storage, specify the gs path like gs://your-bucket/your-object as the argument.
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.
Good catch on the regex! This is now fixed.
As for the --gcs-path, I experimented with this but I found it to be cumbersome. I think the current approach works better.
| <info>php %command.full_name% Text to analyze.</info> | ||
| <info>php %command.full_name% gs://my-bucket/file_with_text.txt</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.
The sub-command everything sounds a bit weird.
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.
What do you suggest? analyze-all?
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.
yeah it sounds much better
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.
ok, done
| if (!self::$hasCredentials) { | ||
| $this->markTestSkipped('No application credentials were found.'); | ||
| } | ||
| if (!$gcsFile = getenv('GOOGLE_LANGUAGE_GCS_FILE')) { |
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.
Did you add the envvar on travis and jenkins?
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.
yes
0dac7f9 to
696ac34
Compare
- Renames command classes for consistency
696ac34 to
d328a8d
Compare
|
@tmatsuo PTAL |
Updates CLI to accept
gs://path to language file