Skip to content

Commit 30eb9ed

Browse files
Merge pull request #123 from watson-developer-cloud/dev
Merge latest changes from dev
2 parents b1b2b8a + dc83091 commit 30eb9ed

File tree

31 files changed

+917
-161
lines changed

31 files changed

+917
-161
lines changed

README.md

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ APIs and SDKs that use cognitive computing to solve complex problems.
2828
* [Natural Language Classifier](#natural-language-classifier)
2929
* [Personality Insights](#personality-insights)
3030
* [Relationship Extraction](#relationship-extraction)
31+
* [Retrieve and Rank](#retrieve-and-rank)
3132
* [Speech to Text](#speech-to-text)
3233
* [Text to Speech](#text-to-speech)
3334
* [Tone Analyzer](#tone-analyzer)
@@ -52,13 +53,13 @@ Now, you are ready to see some [examples](https://github.com/watson-developer-cl
5253
<dependency>
5354
<groupId>com.ibm.watson.developer_cloud</groupId>
5455
<artifactId>java-sdk</artifactId>
55-
<version>2.0.0</version>
56+
<version>2.1.0</version>
5657
</dependency>
5758
```
5859
##### Gradle
5960

6061
```gradle
61-
'com.ibm.watson.developer_cloud:java-sdk:2.0.0'
62+
'com.ibm.watson.developer_cloud:java-sdk:2.1.0'
6263
```
6364

6465
## Usage
@@ -131,14 +132,26 @@ System.out.println(keywords);
131132
```
132133

133134
### Alchemy Data News
134-
[Alchemy Data News][alchemy_data_news] indexes 250k to 300k English language news and blog articles every day with historical search available for the past 60 days.
135-
Example: Get the volume data from the last 7 days using 12hs of time slice.
136-
135+
[Alchemy Data News][alchemy_data_news] indexes 250k to 300k English language news and
136+
blog articles every day with historical search available for the past 60 days.
137+
Example: Get 7 documents between Friday 28th August 2015 and Friday 4th September 2015.
138+
137139
```java
138140
AlchemyDataNews service = new AlchemyDataNews();
139141
service.setApiKey("<api_key>");
140142

141-
VolumeResult result = service.getVolume("now-7d", "now", "12h");
143+
Map<String, Object> params = new HashMap<String, Object>();
144+
145+
String[] fields =
146+
new String[] {"enriched.url.title", "enriched.url.url", "enriched.url.author",
147+
"enriched.url.publicationDate", "enriched.url.enrichedTitle.entities",
148+
"enriched.url.enrichedTitle.docSentiment"};
149+
params.put(AlchemyDataNews.RETURN, StringUtils.join(fields, ","));
150+
params.put(AlchemyDataNews.START, "1440720000");
151+
params.put(AlchemyDataNews.END, "1441407600");
152+
params.put(AlchemyDataNews.COUNT, 7);
153+
154+
DocumentsResult result = service.getNewsDocuments(params);
142155

143156
System.out.println(result);
144157
```
@@ -178,7 +191,7 @@ DocumentConversion service = new DocumentConversion();
178191
service.setUsernameAndPassword("<username>", "<password>");
179192

180193
File doc = new File("src/test/resources/document_conversion/word-document-heading-input.doc");
181-
Answers htmlToAnswers = service.convertDocumentToAnswer(doc, null);
194+
Answers htmlToAnswers = service.convertDocumentToAnswer(doc);
182195
System.out.println(htmlToAnswers);
183196
```
184197

@@ -257,6 +270,36 @@ String response = service.extract("IBM Watson Developer Cloud");
257270
System.out.println(response);
258271
```
259272

273+
274+
### Retrieve and Rank
275+
The [Retrieve and Rank][retrieve_and_rank] service helps users find the most
276+
relevant information for their query by using a combination of search and
277+
machine learning to find “signals” in the data.
278+
279+
280+
```java
281+
RetrieveAndRank service = new RetrieveAndRank();
282+
service.setUsernameAndPassword("<username>", "<password>");
283+
284+
// 1 create the Solr Cluster
285+
SolrClusterOptions options = new SolrClusterOptions("my-cluster-name", 1);
286+
SolrCluster cluster = service.createSolrCluster(options);
287+
System.out.println("Solr cluster: " + cluster);
288+
289+
// 2 wait until the Solr Cluster is available
290+
while (cluster.getStatus() == Status.NOT_AVAILABLE) {
291+
Thread.sleep(10000); // sleep 10 seconds
292+
cluster = service.getSolrCluster(cluster.getId());
293+
System.out.println("Solr cluster status: " + cluster.getStatus());
294+
}
295+
296+
// 3 list Solr Clusters
297+
System.out.println("Solr clusters: " + service.getSolrClusters());
298+
```
299+
300+
Retrieve and Rank is built on top of Apache Solr.
301+
Look at [this](https://github.com/watson-developer-cloud/java-sdk/tree/master/examples/retrieve-and-rank-solrj) example to learn how to use Solrj.
302+
260303
### Speech to Text
261304
Use the [Speech to Text][speech_to_text] service to recognize the text from a .wav file.
262305

@@ -411,7 +454,7 @@ Gradle:
411454

412455
```sh
413456
$ cd java-sdk
414-
$ gradle jar # build jar file (build/libs/watson-developer-cloud-2.0.0.jar)
457+
$ gradle jar # build jar file (build/libs/watson-developer-cloud-2.1.0.jar)
415458
$ gradle test # run tests
416459
```
417460

@@ -465,6 +508,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
465508
[dialog]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/dialog/
466509
[concept-insights]: https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/concept-insights/
467510
[visual_insights]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/visual-insights/
511+
[retrieve_and_rank]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/retrieve-rank/
468512

469513
[alchemy_language]: http://www.alchemyapi.com/products/alchemylanguage
470514
[sentiment_analysis]: http://www.alchemyapi.com/products/alchemylanguage/sentiment-analysis

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sourceCompatibility = 1.6
66
targetCompatibility = 1.6
77
group = 'com.ibm.watson.developercloud'
88
archivesBaseName = 'watson-developer-cloud'
9-
version = '2.0.0'
9+
version = '2.1.0'
1010

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

examples/java/com/ibm/watson/developer_cloud/document_conversion/v1/DocumentConversionExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ public static void main(String[] args) throws URISyntaxException, IOException,
3636
new File("src/test/resources/document_conversion/word-document-heading-input.doc");
3737

3838
System.out.println("Convert html document to Answers");
39-
final Answers htmlToAnswers = service.convertDocumentToAnswer(html, null);
39+
final Answers htmlToAnswers = service.convertDocumentToAnswer(html);
4040
System.out.println(htmlToAnswers);
4141

4242
System.out.println("Convert pdf document to Normalized HTML");
43-
final String normalizedHTML = service.convertDocumentToHTML(pdf, null);
43+
final String normalizedHTML = service.convertDocumentToHTML(pdf);
4444
System.out.println(normalizedHTML);
4545

4646
System.out.println("Convert html document to Normalized Text");
47-
final String normalizedText = service.convertDocumentToText(doc, null);
47+
final String normalizedText = service.convertDocumentToText(doc);
4848
System.out.println(normalizedText);
4949

5050
}

examples/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/CreateASolrClusterExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static void main(String[] args) throws InterruptedException {
2828
service.setUsernameAndPassword("<username>", "<password>");
2929

3030
// 2 create the Solr Cluster
31-
SolrClusterOptions options = new SolrClusterOptions("<cluster-name>", "1");
31+
SolrClusterOptions options = new SolrClusterOptions("<cluster-name>", 1);
3232
SolrCluster cluster = service.createSolrCluster(options);
3333
System.out.println("SolrCluster: " + cluster);
3434

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Retrieve and Rank and Solrj
2+
3+
This example shows how to use the [Retrieve and Rank](http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/retrieve-rank.html) service along with the [Solr client in Java (Solrj)](https://wiki.apache.org/solr/Solrj).
4+
5+
## Installation
6+
7+
To run the example you need to install the dependencies
8+
9+
$ mvn compile
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.ibm.watson.developer_cloud</groupId>
6+
<artifactId>retrieve-and-rank-solrj</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>retrieve-and-rank-solrj</name>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
</properties>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.apache.solr</groupId>
19+
<artifactId>solr-solrj</artifactId>
20+
<version>5.2.1</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.apache.httpcomponents</groupId>
24+
<artifactId>httpclient</artifactId>
25+
<version>4.3.6</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.ibm.watson.developer_cloud</groupId>
29+
<artifactId>java-sdk</artifactId>
30+
<version>2.0.0</version>
31+
</dependency>
32+
</dependencies>
33+
</project>

0 commit comments

Comments
 (0)