This sample demonstrates the use of the Google Cloud Natural Language API for entity recognition.
This sample requires you to have Java8.
Note The Natural Language client is not supported by App Engine Standard.
This sample uses the Apache Maven build system. Before getting started, be sure to download and install it. When you use Maven as described here, it will automatically download the needed client libraries.
To build the sample, we use Maven.
mvn clean compile assembly:single
We can then run the assembled JAR file with the java
command. The variable $COMMAND takes
three values entities
, sentiment
, or syntax
.
java -cp target/language-entities-1.0-jar-with-dependencies.jar \
com.google.cloud.language.samples.Analyze \
<entities | sentiment | syntax> \
<text | GCS path>
Analyze entities
java -cp target/language-entities-1.0-jar-with-dependencies.jar \
com.google.cloud.language.samples.Analyze \
entities \
"The quick brown fox jumped over the lazy dog."
Analyze sentiment
java -cp target/language-entities-1.0-jar-with-dependencies.jar \
com.google.cloud.language.samples.Analyze \
sentiment \
"The quick brown fox jumped over the lazy dog."
Analyze syntax
java -cp target/language-entities-1.0-jar-with-dependencies.jar \
com.google.cloud.language.samples.Analyze \
syntax \
"The quick brown fox jumped over the lazy dog."
Included with the sample are demo.sh
and demo.bat
which show additional
examples of usage.
Run demo from *nix or OSX
demo.sh
Run demo from Windows
demo
Analyze sentiment beta
java -cp target/language-entities-1.0-jar-with-dependencies.jar \
com.google.cloud.language.samples.AnalyzeBeta \
sentiment \
"Der schnelle braune Fuchs sprang über den faulen Hund."
Analyze entity sentiment Beta
java -cp target/language-entities-1.0-jar-with-dependencies.jar \
com.google.cloud.language.samples.AnalyzeBeta entities-sentiment \
"There's nothing better than searching for ice cream on Google."
Run beta demo from *nix or OSX
demo-beta.sh