GeezerVison is showing github.com — Merge branch 'master' into language-script · boy12371/java-docs-samples@f8829ae
File treeExpand file treeCollapse file tree Open diff view settings datastore/cloud-client/src/test/java/com/example/datastore main/java/com/example/language test/java/com/example/language
pubsub/cloud-client/src/test/java/com/example/pubsub storage/cloud-client/src/test/java/com/example/storage src/test/java/com/example/translate
src/main/java/com/google/cloud/vision/samples/text
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: datastore/cloud-client/src/test/java/com/example/datastore/QuickstartSampleIT.java -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -69,4 +69,3 @@ public void testQuickstart() throws Exception { | 69 | 69 | assertThat(got).contains("Saved sampletask1: Buy milk"); | 70 | 70 | } | 71 | 71 | } | 72 | | -// [END datastore_quickstart] |
Collapse file Copy file name to clipboard +30Lines changed: 30 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# Getting Started with Google Cloud Natural Language API and the Google Cloud Client libraries | | 2 | + | | 3 | +[Google Cloud Natural Language API][language] provides natural language | | 4 | +understanding technologies to developers, including sentiment analysis, entity | | 5 | +recognition, and syntax analysis. This API is part of the larger collection of | | 6 | +Cloud Machine Learning APIs. | | 7 | + | | 8 | +These sample Java applications demonstrate how to access the Cloud Natural | | 9 | +Language API using the [Google Cloud Client Library for Java][google-cloud-java]. | | 10 | + | | 11 | +[language]: https://cloud.google.com/natural-language/docs/ | | 12 | +[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java | | 13 | + | | 14 | +## Quickstart | | 15 | + | | 16 | +Install [Maven](http://maven.apache.org/). | | 17 | + | | 18 | +Build your project with: | | 19 | + | | 20 | + mvn clean package -DskipTests | | 21 | + | | 22 | +You can then run a given `ClassName` via: | | 23 | + | | 24 | + mvn exec:java -Dexec.mainClass=com.example.language.ClassName \ | | 25 | + -DpropertyName=propertyValue \ | | 26 | + -Dexec.args="arg1 'arg 2' arg3" | | 27 | + | | 28 | +### Analyze a string for sentiment (using the quickstart sample) | | 29 | + | | 30 | + mvn exec:java -Dexec.mainClass=com.example.language.QuickstartSample |
Collapse file Copy file name to clipboard +57Lines changed: 57 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!-- | | 2 | + Copyright 2016 Google Inc. All Rights Reserved. | | 3 | +
| | 4 | + Licensed under the Apache License, Version 2.0 (the "License"); | | 5 | + you may not use this file except in compliance with the License. | | 6 | + You may obtain a copy of the License at | | 7 | +
| | 8 | + http://www.apache.org/licenses/LICENSE-2.0 | | 9 | +
| | 10 | + Unless required by applicable law or agreed to in writing, software | | 11 | + distributed under the License is distributed on an "AS IS" BASIS, | | 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 13 | + See the License for the specific language governing permissions and | | 14 | + limitations under the License. | | 15 | +--> | | 16 | +<project> | | 17 | + <modelVersion>4.0.0</modelVersion> | | 18 | + <groupId>com.example.language</groupId> | | 19 | + <artifactId>language-google-cloud-samples</artifactId> | | 20 | + <packaging>jar</packaging> | | 21 | + | | 22 | + <!-- Parent defines config for testing & linting. --> | | 23 | + <parent> | | 24 | + <artifactId>doc-samples</artifactId> | | 25 | + <groupId>com.google.cloud</groupId> | | 26 | + <version>1.0.0</version> | | 27 | + <relativePath>../..</relativePath> | | 28 | + </parent> | | 29 | + | | 30 | + <properties> | | 31 | + <maven.compiler.target>1.8</maven.compiler.target> | | 32 | + <maven.compiler.source>1.8</maven.compiler.source> | | 33 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | | 34 | + </properties> | | 35 | + | | 36 | + <dependencies> | | 37 | + <dependency> | | 38 | + <groupId>com.google.cloud</groupId> | | 39 | + <artifactId>google-cloud-language</artifactId> | | 40 | + <version>0.7.0</version> | | 41 | + </dependency> | | 42 | + | | 43 | + <!-- Test dependencies --> | | 44 | + <dependency> | | 45 | + <groupId>junit</groupId> | | 46 | + <artifactId>junit</artifactId> | | 47 | + <version>4.12</version> | | 48 | + <scope>test</scope> | | 49 | + </dependency> | | 50 | + <dependency> | | 51 | + <groupId>com.google.truth</groupId> | | 52 | + <artifactId>truth</artifactId> | | 53 | + <version>0.30</version> | | 54 | + <scope>test</scope> | | 55 | + </dependency> | | 56 | + </dependencies> | | 57 | +</project> |
Collapse file Copy file name to clipboard +44Lines changed: 44 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/* | | 2 | + Copyright 2016, Google, Inc. | | 3 | +
| | 4 | + Licensed under the Apache License, Version 2.0 (the "License"); | | 5 | + you may not use this file except in compliance with the License. | | 6 | + You may obtain a copy of the License at | | 7 | +
| | 8 | + http://www.apache.org/licenses/LICENSE-2.0 | | 9 | +
| | 10 | + Unless required by applicable law or agreed to in writing, software | | 11 | + distributed under the License is distributed on an "AS IS" BASIS, | | 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 13 | + See the License for the specific language governing permissions and | | 14 | + limitations under the License. | | 15 | +*/ | | 16 | + | | 17 | +package com.example.language; | | 18 | + | | 19 | +// [START language_quickstart] | | 20 | +// Imports the Google Cloud client library | | 21 | +import com.google.cloud.language.spi.v1.LanguageServiceClient; | | 22 | + | | 23 | +import com.google.cloud.language.v1.Document; | | 24 | +import com.google.cloud.language.v1.Document.Type; | | 25 | +import com.google.cloud.language.v1.Sentiment; | | 26 | + | | 27 | +public class QuickstartSample { | | 28 | + public static void main(String... args) throws Exception { | | 29 | + // Instantiates a client | | 30 | + LanguageServiceClient language = LanguageServiceClient.create(); | | 31 | + | | 32 | + // The text to analyze | | 33 | + String text = "Hello, world!"; | | 34 | + Document doc = Document.newBuilder() | | 35 | + .setContent(text).setType(Type.PLAIN_TEXT).build(); | | 36 | + | | 37 | + // Detects the sentiment of the text | | 38 | + Sentiment sentiment = language.analyzeSentiment(doc).getDocumentSentiment(); | | 39 | + | | 40 | + System.out.printf("Text: %s%n", text); | | 41 | + System.out.printf("Sentiment: %s, %s%n", sentiment.getScore(), sentiment.getMagnitude()); | | 42 | + } | | 43 | +} | | 44 | +// [END language_quickstart] |
Collapse file Copy file name to clipboard +61Lines changed: 61 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/* | | 2 | + Copyright 2016, Google, Inc. | | 3 | +
| | 4 | + Licensed under the Apache License, Version 2.0 (the "License"); | | 5 | + you may not use this file except in compliance with the License. | | 6 | + You may obtain a copy of the License at | | 7 | +
| | 8 | + http://www.apache.org/licenses/LICENSE-2.0 | | 9 | +
| | 10 | + Unless required by applicable law or agreed to in writing, software | | 11 | + distributed under the License is distributed on an "AS IS" BASIS, | | 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | | 13 | + See the License for the specific language governing permissions and | | 14 | + limitations under the License. | | 15 | +*/ | | 16 | + | | 17 | +package com.example.language; | | 18 | + | | 19 | +import static com.google.common.truth.Truth.assertThat; | | 20 | + | | 21 | +import org.junit.After; | | 22 | +import org.junit.Before; | | 23 | +import org.junit.Test; | | 24 | +import org.junit.runner.RunWith; | | 25 | +import org.junit.runners.JUnit4; | | 26 | + | | 27 | +import java.io.ByteArrayOutputStream; | | 28 | +import java.io.PrintStream; | | 29 | + | | 30 | +/** | | 31 | + * Tests for quickstart sample. | | 32 | + */ | | 33 | +@RunWith(JUnit4.class) | | 34 | +@SuppressWarnings("checkstyle:abbreviationaswordinname") | | 35 | +public class QuickstartSampleIT { | | 36 | + private ByteArrayOutputStream bout; | | 37 | + private PrintStream out; | | 38 | + | | 39 | + @Before | | 40 | + public void setUp() { | | 41 | + bout = new ByteArrayOutputStream(); | | 42 | + out = new PrintStream(bout); | | 43 | + System.setOut(out); | | 44 | + } | | 45 | + | | 46 | + @After | | 47 | + public void tearDown() { | | 48 | + System.setOut(null); | | 49 | + } | | 50 | + | | 51 | + @Test | | 52 | + public void testQuickstart() throws Exception { | | 53 | + // Act | | 54 | + QuickstartSample.main(); | | 55 | + | | 56 | + // Assert | | 57 | + String got = bout.toString(); | | 58 | + assertThat(got).contains("Text: Hello, world!"); | | 59 | + assertThat(got).contains("Sentiment: "); | | 60 | + } | | 61 | +} |
Collapse file Copy file name to clipboardExpand all lines: pubsub/cloud-client/src/test/java/com/example/pubsub/QuickstartSampleIT.java -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -66,4 +66,3 @@ public void testQuickstart() throws Exception { | 66 | 66 | assertThat(got).contains("Topic my-new-topic created."); | 67 | 67 | } | 68 | 68 | } | 69 | | -// [END datastore_quickstart] |
Collapse file Copy file name to clipboardExpand all lines: storage/cloud-client/src/test/java/com/example/storage/QuickstartSampleIT.java -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,4 +67,3 @@ public void testQuickstart() throws Exception { | 67 | 67 | assertThat(got).contains(String.format("Bucket %s created.", bucketName)); | 68 | 68 | } | 69 | 69 | } | 70 | | -// [END datastore_quickstart] |
Collapse file Copy file name to clipboardExpand all lines: translate/cloud-client/README.md +2-3Lines changed: 2 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | [Google Translate API][translate] provides a simple programmatic interface for translating an | 4 | 4 | arbitrary string into any supported language. | 5 | | -These sample Java applications demonstrate how to access the Cloud Storage API using | | 5 | +These sample Java applications demonstrate how to access the Google Translate API using | 6 | 6 | the [Google Cloud Client Library for Java][google-cloud-java]. | 7 | 7 |
| 8 | 8 | [translate]: https://cloud.google.com/translate/ | @@ -24,5 +24,4 @@ You can then run a given `ClassName` via: | 24 | 24 |
| 25 | 25 | ### Translate a string (using the quickstart sample) | 26 | 26 |
| 27 | | - mvn exec:java -Dexec.mainClass=com.example.translate.QuickstartSample \ | 28 | | - -Dexec.args="YOUR_API_KEY" | | 27 | + mvn exec:java -Dexec.mainClass=com.example.translate.QuickstartSample |
Collapse file Copy file name to clipboardExpand all lines: translate/cloud-client/src/test/java/com/example/translate/QuickstartSampleIT.java -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,4 +59,3 @@ public void testQuickstart() throws Exception { | 59 | 59 | assertThat(got).contains("Translation: "); | 60 | 60 | } | 61 | 61 | } | 62 | | -// [END datastore_quickstart] |
Collapse file Copy file name to clipboardExpand all lines: vision/text/pom.xml -6Lines changed: 0 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 50 | 50 | <artifactId>guava</artifactId> | 51 | 51 | <version>20.0</version> | 52 | 52 | </dependency> | 53 | | - <dependency> | 54 | | - <groupId>com.google.auto.value</groupId> | 55 | | - <artifactId>auto-value</artifactId> | 56 | | - <version>1.3</version> | 57 | | - <scope>provided</scope> | 58 | | - </dependency> | 59 | 53 | <dependency> | 60 | 54 | <groupId>org.apache.opennlp</groupId> | 61 | 55 | <artifactId>opennlp-tools</artifactId> | |
|