Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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:
sentimentFromString <text> Detect the sentiment of a block of text.
sentimentFromFile <bucket> <filename> Detect the sentiment of text in a GCS file.
entitiesFromString <text> Detect the entities of a block of text.
entitiesFromFile <bucket> <filename> Detect the entities of text in a GCS file.
syntaxFromString <text> Detect the syntax of a block of text.
syntaxFromFile <bucket> <filename> Detect the syntax of text in a GCS file.

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 sentimentFromString "President Obama is speaking at the White House."
node analyze sentimentFromFile my-bucket file.txt
node analyze entitiesFromString "<p>President Obama is speaking at the White House.</p>" -t html
node analyze entitiesFromFile my-bucket file.txt
node analyze syntaxFromString "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