Skip to content
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

Bring Language sample up to standard. #190

Merged
merged 2 commits into from
Aug 28, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 30 additions & 53 deletions language/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,73 +13,50 @@ Learning API.

* [Setup](#setup)
* [Samples](#samples)
* [analyze.js](#analyze)
* [Analyze](#analyze)

## Setup

1. Please follow the [Set Up Your Project][quickstart] steps in the Quickstart
doc to create a project and enable the Cloud Natural Language API.
1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
1. Install dependencies:

npm install

[quickstart]: https://cloud.google.com/natural-language/docs/getting-started#set_up_your_project
[prereq]: ../README.md#prerequisities
[run]: ../README.md#how-to-run-a-sample

## Samples

### Analyze

View the [source code][analyze_code].

__Run the sample:__

Usage: `node analyze <sentiment|entities|syntax> <text>`

For example, the following command returns all entities found in the text:

Example:

node analyze entities "President Obama is speaking at the White House."

{
"entities": [
{
"name": "Obama",
"type": "PERSON",
"metadata": {
"wikipedia_url": "http://en.wikipedia.org/wiki/Barack_Obama"
},
"salience": 0.84503114,
"mentions": [
{
"text": {
"content": "Obama",
"beginOffset": 10
}
}
]
},
{
"name": "White House",
"type": "LOCATION",
"metadata": {
"wikipedia_url": "http://en.wikipedia.org/wiki/White_House"
},
"salience": 0.15496887,
"mentions": [
{
"text": {
"content": "White House",
"beginOffset": 35
}
}
]
}
],
"language": "en"
}
View the [documentation][analyze_docs] or the [source code][analyze_code].

__Usage:__ `node analyze --help`

```
Commands:
sentiment <text> Detect the sentiment of a block of text.
sentimentFromFile <bucket> <filename> Detect the sentiment of text in a GCS file.
entities <text> Detect the entities of a block of text.
entitiesFromFile <bucket> <filename> Detect the entities of text in a GCS file.
syntax <text> Detect the syntax of a block of text.
syntaxFromFile <bucket> <filename> Detect the syntax of a block of text.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in description?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.


Options:
--language, -l The language of the text. [string]
--type, -t Type of text. [string] [choices: "text", "html"] [default: "text"]
--help Show help [boolean]

Examples:
node analyze sentiment "President Obama is speaking at the White House."
node analyze sentimentFromFile my-bucket file.txt
node analyze entities "<p>President Obama is speaking at the White House.</p> -t html"
node analyze entitiesFromFile my-bucket file.txt
node analyze syntax "President Obama is speaking at the White House."
node analyze syntaxFromFile my-bucket es_file.txt -l es

For more information, see https://cloud.google.com/natural-language/docs
```

[analyze_docs]: https://cloud.google.com/natural-language/docs
[analyze_code]: analyze.js
Loading