Skip to content

Commit 7af79ba

Browse files
committed
Fix mixing READMEs #1466.
Also includes samples (borrowed from https://github.com/GoogleCloudPlatform/java-docs-samples and slightly modified). Small fixes in GA libraries reames (removing "unstable" notions).
1 parent 591dbb3 commit 7af79ba

9 files changed

Lines changed: 517 additions & 18 deletions

File tree

google-cloud-datastore/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ Java idiomatic client for [Google Cloud Datastore](https://cloud.google.com/data
1212
- [Homepage](https://googlecloudplatform.github.io/google-cloud-java/)
1313
- [API Documentation](https://googlecloudplatform.github.io/google-cloud-java/apidocs/index.html?com/google/cloud/datastore/package-summary.html)
1414

15-
> Note: This client is a work-in-progress, and may occasionally
16-
> make backwards-incompatible changes.
17-
1815
Quickstart
1916
----------
2017
If you are using Maven, add this to your pom.xml file
@@ -170,9 +167,7 @@ Versioning
170167

171168
This library follows [Semantic Versioning](http://semver.org/).
172169

173-
It is currently in major version zero (``0.y.z``), which means that anything
174-
may change at any time and the public API should not be considered
175-
stable.
170+
It is currently in major version one (``1.y.z``), which means that the public API should not be considered stable.
176171

177172
Contributing
178173
------------
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2017 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+
17+
/*
18+
* EDITING INSTRUCTIONS
19+
* This file is referenced in READMEs. Any change to this file should be reflected in
20+
* the project's READMEs.
21+
*/
22+
23+
package com.google.cloud.examples.language.snippets;
24+
25+
import com.google.cloud.language.spi.v1.LanguageServiceClient;
26+
27+
import com.google.cloud.language.v1.Document;
28+
import com.google.cloud.language.v1.Document.Type;
29+
import com.google.cloud.language.v1.Sentiment;
30+
31+
/**
32+
* A snippet for Google Cloud Speech API showing how to analyze text message sentiment.
33+
*/
34+
public class AnalyzeSentiment {
35+
36+
public static void main(String... args) throws Exception {
37+
// Instantiates a client
38+
LanguageServiceClient language = LanguageServiceClient.create();
39+
40+
// The text to analyze
41+
String[] texts = {"I love this!", "I hate this!"};
42+
for (String text : texts) {
43+
Document doc = Document.newBuilder().setContent(text).setType(Type.PLAIN_TEXT).build();
44+
// Detects the sentiment of the text
45+
Sentiment sentiment = language.analyzeSentiment(doc).getDocumentSentiment();
46+
47+
System.out.printf("Text: \"%s\"%n", text);
48+
System.out.printf(
49+
"Sentiment: score = %s, magnitude = %s%n",
50+
sentiment.getScore(), sentiment.getMagnitude());
51+
}
52+
}
53+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright 2017 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+
17+
/*
18+
* EDITING INSTRUCTIONS
19+
* This file is referenced in READMEs. Any change to this file should be reflected in
20+
* the project's READMEs.
21+
*/
22+
23+
package com.google.cloud.examples.speech.snippets;
24+
25+
import com.google.cloud.speech.spi.v1.SpeechClient;
26+
import com.google.cloud.speech.v1.RecognitionAudio;
27+
import com.google.cloud.speech.v1.RecognitionConfig;
28+
import com.google.cloud.speech.v1.RecognitionConfig.AudioEncoding;
29+
import com.google.cloud.speech.v1.RecognizeResponse;
30+
import com.google.cloud.speech.v1.SpeechRecognitionAlternative;
31+
import com.google.cloud.speech.v1.SpeechRecognitionResult;
32+
import com.google.protobuf.ByteString;
33+
import java.nio.file.Files;
34+
import java.nio.file.Path;
35+
import java.nio.file.Paths;
36+
import java.util.List;
37+
38+
/**
39+
* A snippet for Google Natural Language API showing how to convert houman speech from an audio file
40+
* into a text form.
41+
*/
42+
public class RecognizeSpeech {
43+
public static void main(String... args) throws Exception {
44+
// Instantiates a client
45+
SpeechClient speech = SpeechClient.create();
46+
47+
// The path to the audio file to transcribe
48+
String fileName = "your/speech/audio/file.raw"; // for example "./resources/audio.raw";
49+
50+
// Reads the audio file into memory
51+
Path path = Paths.get(fileName);
52+
byte[] data = Files.readAllBytes(path);
53+
ByteString audioBytes = ByteString.copyFrom(data);
54+
55+
// Builds the sync recognize request
56+
RecognitionConfig config = RecognitionConfig.newBuilder()
57+
.setEncoding(AudioEncoding.LINEAR16)
58+
.setSampleRateHertz(16000)
59+
.setLanguageCode("en-US")
60+
.build();
61+
RecognitionAudio audio = RecognitionAudio.newBuilder()
62+
.setContent(audioBytes)
63+
.build();
64+
65+
// Performs speech recognition on the audio file
66+
RecognizeResponse response = speech.recognize(config, audio);
67+
List<SpeechRecognitionResult> results = response.getResultsList();
68+
69+
for (SpeechRecognitionResult result: results) {
70+
List<SpeechRecognitionAlternative> alternatives = result.getAlternativesList();
71+
for (SpeechRecognitionAlternative alternative: alternatives) {
72+
System.out.printf("Transcription: %s%n", alternative.getTranscript());
73+
}
74+
}
75+
speech.close();
76+
}
77+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2017 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+
17+
/*
18+
* EDITING INSTRUCTIONS
19+
* This file is referenced in READMEs. Any change to this file should be reflected in
20+
* the project's READMEs.
21+
*/
22+
23+
package com.google.cloud.examples.vision.snippets;
24+
import com.google.cloud.vision.spi.v1.ImageAnnotatorClient;
25+
import com.google.cloud.vision.v1.AnnotateImageRequest;
26+
import com.google.cloud.vision.v1.AnnotateImageResponse;
27+
import com.google.cloud.vision.v1.BatchAnnotateImagesResponse;
28+
import com.google.cloud.vision.v1.EntityAnnotation;
29+
import com.google.cloud.vision.v1.Feature;
30+
import com.google.cloud.vision.v1.Feature.Type;
31+
import com.google.cloud.vision.v1.Image;
32+
import com.google.protobuf.ByteString;
33+
import com.google.protobuf.Descriptors.FieldDescriptor;
34+
import java.nio.file.Files;
35+
import java.nio.file.Path;
36+
import java.nio.file.Paths;
37+
import java.util.ArrayList;
38+
import java.util.List;
39+
import java.util.Map;
40+
41+
/**
42+
* A snippet for Google Cloud Vision API demonstrating how to determine what is shown on a picture.
43+
*/
44+
public class AnnotateImage {
45+
public static void main(String... args) throws Exception {
46+
// Instantiates a client
47+
ImageAnnotatorClient vision = ImageAnnotatorClient.create();
48+
49+
// The path to the image file to annotate
50+
String fileName = "your/image/path.jpg"; // for example "./resources/wakeupcat.jpg";
51+
52+
// Reads the image file into memory
53+
Path path = Paths.get(fileName);
54+
byte[] data = Files.readAllBytes(path);
55+
ByteString imgBytes = ByteString.copyFrom(data);
56+
57+
// Builds the image annotation request
58+
List<AnnotateImageRequest> requests = new ArrayList<>();
59+
Image img = Image.newBuilder().setContent(imgBytes).build();
60+
Feature feat = Feature.newBuilder().setType(Type.LABEL_DETECTION).build();
61+
AnnotateImageRequest request = AnnotateImageRequest.newBuilder()
62+
.addFeatures(feat)
63+
.setImage(img)
64+
.build();
65+
requests.add(request);
66+
67+
// Performs label detection on the image file
68+
BatchAnnotateImagesResponse response = vision.batchAnnotateImages(requests);
69+
List<AnnotateImageResponse> responses = response.getResponsesList();
70+
71+
for (AnnotateImageResponse res : responses) {
72+
if (res.hasError()) {
73+
System.out.printf("Error: %s\n", res.getError().getMessage());
74+
return;
75+
}
76+
77+
for (EntityAnnotation annotation : res.getLabelAnnotationsList()) {
78+
for (Map.Entry<FieldDescriptor, Object> entry : annotation.getAllFields().entrySet()) {
79+
System.out.printf("%s : %s\n", entry.getKey(), entry.getValue());
80+
}
81+
}
82+
}
83+
}
84+
}

google-cloud-language/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Google Cloud Java Client for Natural Language
2+
======================================
3+
4+
Java idiomatic client for [Google Cloud Natural Language](https://cloud.google.com/natural-language/).
5+
6+
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/google-cloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/google-cloud-java)
7+
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/google-cloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/google-cloud-java?branch=master)
8+
[![Maven](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-language.svg)](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-language.svg)
9+
[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/google-cloud-java)
10+
[![Dependency Status](https://www.versioneye.com/user/projects/58fe4c8d6ac171426c414772/badge.svg?style=flat)](https://www.versioneye.com/user/projects/58fe4c8d6ac171426c414772)
11+
12+
- [Homepage](https://googlecloudplatform.github.io/google-cloud-java/)
13+
- [API Documentation][language-api]
14+
15+
> Note: This client is a work-in-progress, and may occasionally
16+
> make backwards-incompatible changes.
17+
18+
Quickstart
19+
----------
20+
If you are using Maven, add this to your pom.xml file
21+
```xml
22+
<dependency>
23+
<groupId>com.google.cloud</groupId>
24+
<artifactId>google-cloud-language</artifactId>
25+
<version>0.17.1-beta</version>
26+
</dependency>
27+
```
28+
If you are using Gradle, add this to your dependencies
29+
```Groovy
30+
compile 'com.google.cloud:google-cloud-language:0.17.1-beta'
31+
```
32+
If you are using SBT, add this to your dependencies
33+
```Scala
34+
libraryDependencies += "com.google.cloud" % "google-cloud-language" % "0.17.1-beta"
35+
```
36+
37+
Authentication
38+
--------------
39+
40+
See the [Authentication](https://github.com/GoogleCloudPlatform/google-cloud-java#authentication) section in the base directory's README.
41+
42+
About Google Cloud Natural Language
43+
----------------------------
44+
45+
Google [Cloud Natural Language API][cloud-language-docs] provides natural language understanding technologies to developers, including sentiment analysis, entity analysis, and syntax analysis. This API is part of the larger Cloud Machine Learning API family.
46+
47+
See the ``google-cloud`` API [natural language documentation][language-api] to learn how to use this Cloud Natural Language API Client Library.
48+
49+
Getting Started
50+
---------------
51+
#### Prerequisites
52+
You will need a [Google Developers Console](https://console.developers.google.com/) project with the Natural Language API enabled. [Follow these instructions](https://cloud.google.com/docs/authentication#preparation) to get your project set up. You will also need to set up the local development environment by [installing the Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands in command line: `gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.
53+
54+
#### Installation and setup
55+
You'll need to obtain the `google-cloud-language` library. See the [Quickstart](#quickstart) section to add `google-cloud-language` as a dependency in your code.
56+
57+
#### Complete source code
58+
59+
In [AnalyzeSentiment.java](../google-cloud-examples/src/main/java/com/google/cloud/examples/language/snippets/AnalyzeSentiment.java) we put a quick start example, which shows how you can use Google Natural Language API to automatically analize a sentiment of a text message.
60+
61+
Troubleshooting
62+
---------------
63+
64+
To get help, follow the instructions in the [shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
65+
66+
Java Versions
67+
-------------
68+
69+
Java 7 or above is required for using this client.
70+
71+
Versioning
72+
----------
73+
74+
This library follows [Semantic Versioning](http://semver.org/).
75+
76+
It is currently in major version zero (``0.y.z``), which means that anything may change at any time and the public API should not be considered stable.
77+
78+
Contributing
79+
------------
80+
81+
Contributions to this library are always welcome and highly encouraged.
82+
83+
See `google-cloud`'s [CONTRIBUTING] documentation and the [shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
84+
85+
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
86+
87+
License
88+
-------
89+
90+
Apache 2.0 - See [LICENSE] for more information.
91+
92+
93+
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/CONTRIBUTING.md
94+
[code-of-conduct]:https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
95+
[LICENSE]: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/LICENSE
96+
[cloud-platform]: https://cloud.google.com/
97+
[cloud-language-docs]: https://cloud.google.com/natural-language/docs
98+
[language-api]: https://googlecloudplatform.github.io/google-cloud-java/apidocs/index.html?com/google/cloud/language/spi/v1/package-summary.html

google-cloud-logging/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ Java idiomatic client for [Stackdriver Logging][stackdriver-logging].
1212
- [Homepage](https://googlecloudplatform.github.io/google-cloud-java/)
1313
- [API Documentation](https://googlecloudplatform.github.io/google-cloud-java/apidocs)
1414

15-
> Note: This client is a work-in-progress, and may occasionally
16-
> make backwards-incompatible changes.
17-
1815
Quickstart
1916
----------
2017

@@ -184,9 +181,7 @@ Versioning
184181

185182
This library follows [Semantic Versioning](http://semver.org/).
186183

187-
It is currently in major version zero (``0.y.z``), which means that anything
188-
may change at any time and the public API should not be considered
189-
stable.
184+
It is currently in major version one (``1.y.z``), which means that the public API should not be considered stable.
190185

191186
Contributing
192187
------------

0 commit comments

Comments
 (0)