Skip to content

Commit 044d22c

Browse files
Fix to visual insights package name
1 parent 5460aca commit 044d22c

File tree

6 files changed

+109
-104
lines changed

6 files changed

+109
-104
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Java code wrappers to quickly get started with the various [Watson Developer Clo
3333
* [Text to Speech](#text-to-speech)
3434
* [Tone Analyzer](#tone-analyzer)
3535
* [Tradeoff Analytics](#tradeoff-analytics)
36+
* [Visual Insights](#visual-insights)
3637
* [Visual Recognition](#visual-recognition)
37-
* [Concept Insights](#concept-insights)
3838
* [Android](#android)
3939
* [Build + Test](#build--test)
4040
* [Eclipse and Intellij](#working-with-eclipse-and-intellij-idea)
@@ -466,6 +466,22 @@ Dilemma dilemma = service.dilemmas(problem);
466466
System.out.println(dilemma);
467467
```
468468

469+
### Visual Insights
470+
Use the [Visual Insights][visual_insights] to get insight into the themes present in a collection of images based on their visual appearance/content.
471+
472+
473+
```java
474+
import com.ibm.watson.developer_cloud.visual_insights.v1.VisualInsights;
475+
import com.ibm.watson.developer_cloud.visual_insights.v1.model.Classifiers;
476+
477+
VisualInsights service = new VisualInsights();
478+
service.setUsernameAndPassword("<username>", "<password>");
479+
480+
Classifiers classifiers = service.getClassifiers();
481+
482+
System.out.println(classifiers);
483+
```
484+
469485
### Visual Recognition
470486
Use the [Visual Recognition][visual_recognition] service to recognize the
471487
following picture.
@@ -562,6 +578,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
562578
[tone-analyzer]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/tone-analyzer/
563579
[dialog]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/dialog/
564580
[concept-insights]: https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/concept-insights/
581+
[visual_insights]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/visual-insights/
565582

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

examples/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsightsExample.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
1-
/*
2-
* *
3-
* * Copyright 2015 IBM Corp. All Rights Reserved.
4-
* *
5-
* * Licensed under the Apache License, Version 2.0 (the "License");
6-
* * you may not use this file except in compliance with the License.
7-
* * You may obtain a copy of the License at
8-
* *
9-
* * http://www.apache.org/licenses/LICENSE-2.0
10-
* *
11-
* * Unless required by applicable law or agreed to in writing, software
12-
* * distributed under the License is distributed on an "AS IS" BASIS,
13-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* * See the License for the specific language governing permissions and
15-
* * limitations under the License.
16-
*
17-
*/
181
package com.ibm.watson.developer_cloud.visual_insights.v1;
192

203

214
import java.io.FileNotFoundException;
225
import java.net.URISyntaxException;
23-
import java.util.HashMap;
24-
import java.util.Map;
6+
7+
import com.ibm.watson.developer_cloud.visual_insights.v1.model.Classifiers;
258

269

2710
public class VisualInsightsExample {

src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ private URI buildRequestURI(HttpRequestBase request) {
122122
requestURL = getEndPoint() + request.getURI();
123123
return new URI(requestURL);
124124
} catch (URISyntaxException e) {
125-
log.log(Level.SEVERE, requestURL
126-
+ " could not be parsed as a URI reference");
125+
log.log(Level.SEVERE, requestURL + " could not be parsed as a URI reference");
127126
throw new RuntimeException(e);
128127
}
129128
}

src/main/java/com/ibm/watson/developer_cloud/visual_Insights/v1/VisualInsights.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
package com.ibm.watson.developer_cloud.visual_insights.v1;
1617

17-
package com.ibm.watson.developer_cloud.visual_Insights.v1;
18+
import java.io.File;
19+
import java.util.HashMap;
20+
import java.util.Map;
1821

19-
import com.ibm.watson.developer_cloud.service.Request;
20-
import com.ibm.watson.developer_cloud.service.WatsonService;
21-
import com.ibm.watson.developer_cloud.visual_Insights.v1.model.Classifiers;
22-
import com.ibm.watson.developer_cloud.visual_Insights.v1.model.Summary;
2322
import org.apache.http.entity.mime.MultipartEntity;
2423
import org.apache.http.entity.mime.content.FileBody;
2524

26-
import java.io.File;
27-
import java.util.HashMap;
28-
import java.util.Map;
25+
import com.ibm.watson.developer_cloud.service.Request;
26+
import com.ibm.watson.developer_cloud.service.WatsonService;
27+
import com.ibm.watson.developer_cloud.visual_insights.v1.model.Classifiers;
28+
import com.ibm.watson.developer_cloud.visual_insights.v1.model.Summary;
2929

3030

3131
/**
32-
* The IBM Watson Visual Insights gives insight into the themes present in a collection of images based on their visual appearance / content.
32+
* The IBM Watson Visual Insights gives insight into the themes present in a collection of images based on their visual appearance / content.
3333
*
3434
* @author Nizar Alseddeg (nmalsedd@us.ibm.com)
3535
* @version v1
@@ -39,7 +39,9 @@
3939
*/
4040
public class VisualInsights extends WatsonService {
4141

42-
/**
42+
private static final String FILE = "file";
43+
44+
/**
4345
* The CLASSIFIERS_PATH. (value is "/classifiers")
4446
*/
4547
private static final String CLASSIFIERS_PATH = "/v1/classifiers";
@@ -61,6 +63,13 @@ public class VisualInsights extends WatsonService {
6163
*/
6264
private static final String URL = "https://gateway.watsonplatform.net/visual-insights-experimental/api";
6365

66+
/**
67+
* Instantiates a new visual insights service.
68+
*/
69+
public VisualInsights() {
70+
setEndPoint(URL);
71+
}
72+
6473
/**
6574
* Returns a summary of the collection's visual classifiers
6675
*
@@ -102,7 +111,7 @@ public Summary getSummary(final File imagesFile) {
102111
"imagesFile can not be null or empty");
103112

104113
MultipartEntity reqEntity = new MultipartEntity();
105-
reqEntity.addPart("file", new FileBody(imagesFile));
114+
reqEntity.addPart(FILE, new FileBody(imagesFile));
106115
Request request = Request.Post(SUMMARY_PATH)
107116
.withEntity(reqEntity);
108117

src/main/java/com/ibm/watson/developer_cloud/visual_Insights/v1/model/Classifiers.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
17-
package com.ibm.watson.developer_cloud.visual_Insights.v1.model;
18-
19-
import com.ibm.watson.developer_cloud.service.model.GenericModel;
16+
package com.ibm.watson.developer_cloud.visual_insights.v1.model;
2017

2118
import java.util.ArrayList;
2219
import java.util.List;
2320

21+
import com.ibm.watson.developer_cloud.service.model.GenericModel;
22+
2423
/**
2524
* The Class Classifiers.
2625
*/

src/main/java/com/ibm/watson/developer_cloud/visual_Insights/v1/model/Summary.java

Lines changed: 65 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -13,89 +13,87 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
package com.ibm.watson.developer_cloud.visual_insights.v1.model;
1617

17-
package com.ibm.watson.developer_cloud.visual_Insights.v1.model;
18+
import java.util.List;
1819

1920
import com.ibm.watson.developer_cloud.service.model.GenericModel;
2021

21-
import java.util.ArrayList;
22-
import java.util.List;
23-
2422
/**
2523
* The Class Summary.
2624
*/
27-
public class Summary extends GenericModel{
25+
public class Summary extends GenericModel {
2826

29-
/** The summary. */
30-
private List<SummaryItem> summary = new ArrayList<SummaryItem>();
27+
/** The summary. */
28+
private List<SummaryItem> summary;
3129

32-
/**
33-
* Gets the summary.
34-
*
35-
* @return the summary
36-
*/
37-
public List<SummaryItem> getSummary() {
38-
return summary;
39-
}
30+
/**
31+
* Gets the summary.
32+
*
33+
* @return the summary
34+
*/
35+
public List<SummaryItem> getSummary() {
36+
return summary;
37+
}
4038

41-
/**
42-
* Sets the summary.
43-
*
44-
* @param summary
45-
* the new summary
46-
*/
47-
public void setSummary(List<SummaryItem> summary) {
48-
this.summary = summary;
49-
}
39+
/**
40+
* Sets the summary.
41+
*
42+
* @param summary
43+
* the new summary
44+
*/
45+
public void setSummary(List<SummaryItem> summary) {
46+
this.summary = summary;
47+
}
5048

51-
/**
52-
* The object that holds the name and score.
53-
*/
54-
public static class SummaryItem extends GenericModel{
49+
/**
50+
* The object that holds the name and score.
51+
*/
52+
public static class SummaryItem extends GenericModel {
5553

56-
/** The name. */
57-
private String name;
54+
/** The name. */
55+
private String name;
5856

59-
/** The score. */
60-
private double score;
57+
/** The score. */
58+
private Double score;
6159

62-
/**
63-
* Gets the name.
64-
*
65-
* @return the name
66-
*/
67-
public String getName() {
68-
return name;
69-
}
60+
/**
61+
* Gets the name.
62+
*
63+
* @return the name
64+
*/
65+
public String getName() {
66+
return name;
67+
}
7068

71-
/**
72-
* Sets the name.
73-
*
74-
* @param name
75-
* the new name
76-
*/
77-
public void setName(String name) {
78-
this.name = name;
79-
}
69+
/**
70+
* Sets the name.
71+
*
72+
* @param name
73+
* the new name
74+
*/
75+
public void setName(String name) {
76+
this.name = name;
77+
}
8078

81-
/**
82-
* Gets the score.
83-
*
84-
* @return the score
85-
*/
86-
public double getScore() {
87-
return score;
88-
}
79+
/**
80+
* Gets the score.
81+
*
82+
* @return the score
83+
*/
84+
public Double getScore() {
85+
return score;
86+
}
8987

90-
/**
91-
* Sets the score.
92-
*
93-
* @param score
94-
* the new score
95-
*/
96-
public void setScore(double score) {
97-
this.score = score;
98-
}
88+
/**
89+
* Sets the score.
90+
*
91+
* @param score
92+
* the new score
93+
*/
94+
public void setScore(Double score) {
95+
this.score = score;
96+
}
9997

100-
}
98+
}
10199
}

0 commit comments

Comments
 (0)