Skip to content

Commit c70998e

Browse files
Merge pull request #116 from watson-developer-cloud/dev
v2.0.0
2 parents a60589a + bf42cd3 commit c70998e

File tree

342 files changed

+26526
-28453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

342 files changed

+26526
-28453
lines changed

.gitattributes

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Handle line endings automatically for files detected as text
2+
# and leave all files detected as binary untouched.
3+
* text=auto
4+
5+
#
6+
# The above will handle all files NOT found below
7+
#
8+
# These files are text and should be normalized (Convert crlf => lf)
9+
*.css text
10+
*.df text
11+
*.htm text
12+
*.html text
13+
*.java text
14+
*.js text
15+
*.json text
16+
*.jsp text
17+
*.jspf text
18+
*.properties text
19+
*.sh text
20+
*.svg text
21+
*.tld text
22+
*.txt text
23+
*.xml text
24+
25+
# These files are binary and should be left untouched
26+
# (binary is a macro for -text -diff)
27+
*.class binary
28+
*.dll binary
29+
*.ear binary
30+
*.gif binary
31+
*.ico binary
32+
*.jar binary
33+
*.jpg binary
34+
*.jpeg binary
35+
*.png binary
36+
*.so binary
37+
*.war binary

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ script:
66
jdk:
77
- oraclejdk8
88
- oraclejdk7
9-
- openjdk6
10-
119
cache:
1210
directories:
1311
- $HOME/.m2/repository
1412
before_install:
1513
- openssl aes-256-cbc -K $encrypted_a973fe4f8e79_key -iv $encrypted_a973fe4f8e79_iv
1614
-in config.properties.enc -out src/test/resources/config.properties -d
15+
after_success:
16+
- codecov

CONTRIBUTING.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ please ask a question on [dW Answers][dw] or [Stack Overflow][stackoverflow].
88
If you encounter an issue with the Java SDK, you are welcome to submit a [bug report](https://github.com/watson-developer-cloud/java-sdk/issues).
99
Before that, please search for similar issues. It's possible somebody has encountered this issue already.
1010

11-
## Pull Requests
11+
# Pull Requests
1212

1313
If you want to contribute to the repository, here's a quick guide:
1414
1. Fork the repository
@@ -20,6 +20,33 @@ If you want to contribute to the repository, here's a quick guide:
2020
4. Commit your changes
2121
5. Push to your fork and submit a pull request to the **dev** branch
2222

23+
# Developer's Certificate of Origin 1.1
24+
25+
By making a contribution to this project, I certify that:
26+
27+
(a) The contribution was created in whole or in part by me and I
28+
have the right to submit it under the open source license
29+
indicated in the file; or
30+
31+
(b) The contribution is based upon previous work that, to the best
32+
of my knowledge, is covered under an appropriate open source
33+
license and I have the right under that license to submit that
34+
work with modifications, whether created in whole or in part
35+
by me, under the same open source license (unless I am
36+
permitted to submit under a different license), as indicated
37+
in the file; or
38+
39+
(c) The contribution was provided directly to me by some other
40+
person who certified (a), (b) or (c) and I have not modified
41+
it.
42+
43+
(d) I understand and agree that this project and the contribution
44+
are public and that a record of the contribution (including all
45+
personal information I submit with it, including my sign-off) is
46+
maintained indefinitely and may be redistributed consistent with
47+
this project or the open source license(s) involved.
48+
49+
2350
## Additional Resources
2451
+ [General GitHub documentation](https://help.github.com/)
2552
+ [GitHub pull request documentation](https://help.github.com/send-pull-requests/)

README.md

Lines changed: 8 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@ APIs and SDKs that use cognitive computing to solve complex problems.
1919
* [Alchemy Language](#alchemy-language)
2020
* [Alchemy Vision](#alchemy-vision)
2121
* [Alchemy Data News](#alchemy-data-news)
22-
* [Concept Expansion](#concept-expansion)
2322
* [Concept Insights](#concept-insights)
2423
* [Dialog](#dialog)
2524
* [Document Conversion](#document-conversion)
2625
* [Language Identification](#language-identification)
2726
* [Language Translation](#language-translation)
2827
* [Machine Translation](#machine-translation)
29-
* [Message Resonance](#message-resonance)
3028
* [Natural Language Classifier](#natural-language-classifier)
3129
* [Personality Insights](#personality-insights)
32-
* [Question and Answer](#question-and-answer)
3330
* [Relationship Extraction](#relationship-extraction)
3431
* [Speech to Text](#speech-to-text)
3532
* [Text to Speech](#text-to-speech)
@@ -55,13 +52,13 @@ Now, you are ready to see some [examples](https://github.com/watson-developer-cl
5552
<dependency>
5653
<groupId>com.ibm.watson.developer_cloud</groupId>
5754
<artifactId>java-wrapper</artifactId>
58-
<version>1.1.1</version>
55+
<version>2.0.0</version>
5956
</dependency>
6057
```
6158
##### Gradle
6259

6360
```gradle
64-
'com.ibm.watson.developer_cloud:java-wrapper:1.1.1'
61+
'com.ibm.watson.developer_cloud:java-wrapper:2.0.0'
6562
```
6663

6764
## Usage
@@ -146,32 +143,6 @@ VolumeResult result = service.getVolume("now-7d", "now", "12h");
146143
System.out.println(result);
147144
```
148145

149-
### Concept Expansion
150-
Map euphemisms or colloquial terms to more commonly understood phrases using
151-
the [Concept Expansion][concept_expansion] service.
152-
Example: Create a job, wait for it to finish, and then retrieve results.
153-
154-
```java
155-
ConceptExpansion service = new ConceptExpansion();
156-
service.setUsernameAndPassword("<username>", "<password>");
157-
158-
String[] seeds = new String[]{"motrin", "tylenol", "aspirin"};
159-
String label = "medicine";
160-
service.setDataset(ConceptExpansionDataset.MT_SAMPLES);
161-
Job job = service.createJob(label, seeds);
162-
163-
while (service.getJobStatus(job) == Job.Status.AWAITING_WORK
164-
|| service.getJobStatus(job) == Job.Status.IN_FLIGHT) {
165-
try {
166-
Thread.sleep(4000);
167-
} catch (InterruptedException e) {
168-
e.printStackTrace();
169-
}
170-
}
171-
172-
System.out.println(service.getJobResult(job));
173-
```
174-
175146
### Concept Insights
176147
Use the Concept Insights service to identify words in the text that
177148
correspond to concepts in a Wikipedia graph.
@@ -223,19 +194,6 @@ TranslationResult translationResult = service.translate("hello", "en", "es");
223194
System.out.println(translationResult);
224195
```
225196

226-
### Message Resonance
227-
Send a word and Watson responds with the resonance scoring for the word, allowing you to enhance the effectiveness of your language for the intended audience.
228-
Example: Get resonance information for individual words in a sentence from the [Message Resonance][message_resonance] service.
229-
230-
```java
231-
MessageResonance service = new MessageResonance();
232-
service.setUsernameAndPassword("<username>", "<password>");
233-
234-
service.setDataset(MessageResonanceDataset.BIG_DATA);
235-
Message message = service.getResonance("IBM Watson Developer Cloud");
236-
System.out.println(message);
237-
```
238-
239197
### Natural Language Classifier
240198
Use [Natural Language Classifier](http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/nl-classifier/) service to create a classifier instance by providing a set of representative strings and a set of one or more correct classes for each as training. Then use the trained classifier to classify your new question for best matching answers or to retrieve next actions for your application.
241199

@@ -284,18 +242,6 @@ System.out.println(profile);
284242
authentication errors, remember that the Personality Insights service is not
285243
a free service.
286244

287-
### Question and Answer
288-
Ask a healthcare-related question of the [Question and Answer][question_and_answer] service.
289-
290-
```java
291-
QuestionAndAnswer service = new QuestionAndAnswer();
292-
service.setUsernameAndPassword("<username>", "<password>");
293-
294-
service.setDataset(QuestionAndAnswerDataset.HEALTHCARE);
295-
WatsonAnswer watsonAnswers = service.ask("What is HIV?");
296-
297-
System.out.println(watsonAnswers);
298-
```
299245

300246
### Relationship Extraction
301247
Analyze an English news article and get the relationships between sentence
@@ -320,7 +266,7 @@ service.setUsernameAndPassword("<username>", "<password>");
320266

321267
File audio = new File("src/test/resources/sample1.wav");
322268

323-
SpeechResults transcript = service.recognize(audio, "audio/l16; rate=44100");
269+
SpeechResults transcript = service.recognize(audio, HttpMediaType.AUDIO_WAV);
324270
System.out.println(transcript);
325271
```
326272

@@ -443,11 +389,9 @@ System.out.println(recognizedImage);
443389
```
444390

445391
## Android
392+
he library supports Android 2.3 and above. For Java, the minimum requirement is 1.7.
393+
It depends on [OkHttp][] and [gson][].
446394

447-
The library works well on Android. It depends on
448-
[Apache HttpClient][] (including the [HttpMime][] module) and [json-java][].
449-
Android SDK already comes with these two libraries so you don't need to include
450-
them when using the library there.
451395

452396
## Running in Bluemix
453397
When running in Bluemix, the library will automatically get the credentials from `VCAP_SERVICES`.
@@ -467,7 +411,7 @@ Gradle:
467411

468412
```sh
469413
$ cd java-sdk
470-
$ gradle jar # build jar file (build/libs/watson-developer-cloud-1.1.1.jar)
414+
$ gradle jar # build jar file (build/libs/watson-developer-cloud-2.0.0.jar)
471415
$ gradle test # run tests
472416
```
473417

@@ -507,13 +451,9 @@ available in [LICENSE](LICENSE).
507451
## Contributing
508452
See [CONTRIBUTING.md](CONTRIBUTING.md).
509453

510-
511-
[question_and_answer]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/qaapi/
512-
[message_resonance]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/mrapi/
513454
[personality_insights]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/personality-insights/
514455
[language_identification]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/lidapi/
515456
[machine_translation]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/mtapi/
516-
[concept_expansion]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/glimpseapi/
517457
[document_conversion]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/document-conversion/
518458
[relationship_extraction]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/sireapi/
519459
[language_translation]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/language-translation/
@@ -532,11 +472,9 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
532472
[alchemy_data_news]: http://www.alchemyapi.com/products/alchemydata-news
533473

534474
[wdc]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/
535-
[vcap_environment]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/getting_started/index.html#EnvVars
536475
[bluemix]: https://console.ng.bluemix.net
537476
[Gradle]: http://www.gradle.org/
538-
[Apache HttpClient]: http://hc.apache.org/httpcomponents-client-ga/
539-
[HttpMime]: http://hc.apache.org/httpcomponents-client-ga/httpmime
540-
[json-java]: http://json.org/java/
477+
[OkHttp]: http://square.github.io/okhttp/
478+
[gson]: https://github.com/google/gson
541479
[apache_maven]: http://maven.apache.org/
542480
[releases]: https://github.com/watson-developer-cloud/java-sdk/releases

build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ sourceCompatibility = 1.6
66
targetCompatibility = 1.6
77
group = 'com.ibm.watson.developercloud'
88
archivesBaseName = 'watson-developer-cloud'
9-
version = '1.1.0'
9+
version = '2.0.0'
1010

1111
description = 'Client library to use the IBM Watson Services and AlchemyAPI'
1212

1313
repositories {
1414
mavenCentral()
1515
}
1616
dependencies {
17-
compile group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.0.3'
17+
compile group: 'com.squareup.okhttp', name: 'okhttp', version:'2.5.0'
1818
compile group: 'com.google.code.gson', name: 'gson', version:'2.3.1'
19-
compile group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.0.3'
20-
compile group: 'org.apache.commons', name: 'commons-csv', version:'1.2'
2119
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.3.2'
2220
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.10.19'
2321
testCompile group: 'org.mock-server', name: 'mockserver-netty', version:'3.9.17'

config.properties.enc

-16 Bytes
Binary file not shown.

config.properties.example

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
# AlchemyAPI key
44
alchemy.alchemy=
5-
concept_expansion.password=
6-
concept_expansion.url=
7-
concept_expansion.username=
5+
86
dialog.dialog_id=
97
dialog.password=
108
dialog.url=

examples/java/com/ibm/watson/developer_cloud/alchemy_data_news/v1/AlchemyDataNewsExample.java

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package com.ibm.watson.developer_cloud.alchemy_data_news.v1;
15+
16+
17+
import java.io.FileNotFoundException;
18+
import java.net.URISyntaxException;
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
22+
import org.apache.commons.lang3.StringUtils;
23+
24+
import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyDataNews;
25+
import com.ibm.watson.developer_cloud.alchemy.v1.model.DocumentsResult;
26+
27+
28+
/**
29+
* Getting 7 documents between Friday 28th August 2015 and Friday 4th September 2015 using the
30+
* {@link AlchemyDataNews} API.
31+
*
32+
*/
33+
public class GetNewsDocumentExample {
34+
35+
public static void main(String[] args) throws URISyntaxException, FileNotFoundException {
36+
final AlchemyDataNews service = new AlchemyDataNews();
37+
service.setApiKey("<api_key>");
38+
39+
final Map<String, Object> params = new HashMap<String, Object>();
40+
41+
final String[] fields =
42+
new String[] {"enriched.url.title", "enriched.url.url", "enriched.url.author",
43+
"enriched.url.publicationDate", "enriched.url.enrichedTitle.entities",
44+
"enriched.url.enrichedTitle.docSentiment"};
45+
params.put(AlchemyDataNews.RETURN, StringUtils.join(fields, ","));
46+
params.put(AlchemyDataNews.START, "1440720000");
47+
params.put(AlchemyDataNews.END, "1441407600");
48+
params.put(AlchemyDataNews.COUNT, 7);
49+
50+
final DocumentsResult result = service.getNewsDocuments(params);
51+
52+
System.out.println(result);
53+
}
54+
55+
}

0 commit comments

Comments
 (0)