IBM Watson 音调分析器
IBM Watson Tone Analyser
正在尝试使示例代码正常工作。我正在使用 Java 7.
我在这一行遇到错误
service.setUsernameAndPassword("<username>", "<password>");
通知要求我搜索 "service" 的存储库。这不应该是这种情况,因为服务是在上面的行中定义的。有谁知道这里可能出了什么问题?
import com.ibm.watson.developer_cloud.tone_analyzer.v3.*;
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis;
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions;
public class test {
ToneAnalyzer service = new ToneAnalyzer("2017-09-21");
service.setUsernameAndPassword("<username>", "<password>");
String text =
"I know the times are difficult! Our sales have been "
+ "disappointing for the past three quarters for our data analytics "
+ "product suite. We have a competitive data analytics product "
+ "suite in the industry. But we need to do our job selling it! "
+ "We need to acknowledge and fix our sales challenges. "
+ "We can’t blame the economy for our lack of execution! "
+ "We are missing critical sales opportunities. "
+ "Our product is in no way inferior to the competitor products. "
+ "Our clients are hungry for analytical tools to improve their "
+ "business outcomes. Economy has nothing to do with it.";
// Call the service and get the tone
ToneOptions toneOptions = new ToneOptions.Builder()
.html(text)
.build();
ToneAnalysis tone = service.tone(toneOptions).execute();
System.out.println(tone);
}
我也收到一个关于 System.out.println 的错误,说它找不到符号 "tone"。
pom 文件:
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>java-sdk</artifactId>
<version>6.1.0</version>
</dependency>
service.setUsernameAndPassword("<username>", "<password>");
这是一个调用语句,应该在一个方法中。
可能你想像这样重写你 class:
import com.ibm.watson.developer_cloud.tone_analyzer.v3.*;
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis;
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions;
public class Test {
public static void main(String...s) {
ToneAnalyzer service = new ToneAnalyzer("2017-09-21");
service.setUsernameAndPassword("<username>", "<password>");
String text =
"I know the times are difficult! Our sales have been "
+ "disappointing for the past three quarters for our data analytics "
+ "product suite. We have a competitive data analytics product "
+ "suite in the industry. But we need to do our job selling it! "
+ "We need to acknowledge and fix our sales challenges. "
+ "We can’t blame the economy for our lack of execution! "
+ "We are missing critical sales opportunities. "
+ "Our product is in no way inferior to the competitor products. "
+ "Our clients are hungry for analytical tools to improve their "
+ "business outcomes. Economy has nothing to do with it.";
// Call the service and get the tone
ToneOptions toneOptions = new ToneOptions.Builder()
.html(text)
.build();
ToneAnalysis tone = service.tone(toneOptions).execute();
System.out.println(tone);
}
}
PS:class名字以大写字母开头是很好的编码标准
正在尝试使示例代码正常工作。我正在使用 Java 7.
我在这一行遇到错误
service.setUsernameAndPassword("<username>", "<password>");
通知要求我搜索 "service" 的存储库。这不应该是这种情况,因为服务是在上面的行中定义的。有谁知道这里可能出了什么问题?
import com.ibm.watson.developer_cloud.tone_analyzer.v3.*;
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis;
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions;
public class test {
ToneAnalyzer service = new ToneAnalyzer("2017-09-21");
service.setUsernameAndPassword("<username>", "<password>");
String text =
"I know the times are difficult! Our sales have been "
+ "disappointing for the past three quarters for our data analytics "
+ "product suite. We have a competitive data analytics product "
+ "suite in the industry. But we need to do our job selling it! "
+ "We need to acknowledge and fix our sales challenges. "
+ "We can’t blame the economy for our lack of execution! "
+ "We are missing critical sales opportunities. "
+ "Our product is in no way inferior to the competitor products. "
+ "Our clients are hungry for analytical tools to improve their "
+ "business outcomes. Economy has nothing to do with it.";
// Call the service and get the tone
ToneOptions toneOptions = new ToneOptions.Builder()
.html(text)
.build();
ToneAnalysis tone = service.tone(toneOptions).execute();
System.out.println(tone);
}
我也收到一个关于 System.out.println 的错误,说它找不到符号 "tone"。
pom 文件:
<dependency>
<groupId>com.ibm.watson.developer_cloud</groupId>
<artifactId>java-sdk</artifactId>
<version>6.1.0</version>
</dependency>
service.setUsernameAndPassword("<username>", "<password>");
这是一个调用语句,应该在一个方法中。
可能你想像这样重写你 class:
import com.ibm.watson.developer_cloud.tone_analyzer.v3.*;
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis;
import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions;
public class Test {
public static void main(String...s) {
ToneAnalyzer service = new ToneAnalyzer("2017-09-21");
service.setUsernameAndPassword("<username>", "<password>");
String text =
"I know the times are difficult! Our sales have been "
+ "disappointing for the past three quarters for our data analytics "
+ "product suite. We have a competitive data analytics product "
+ "suite in the industry. But we need to do our job selling it! "
+ "We need to acknowledge and fix our sales challenges. "
+ "We can’t blame the economy for our lack of execution! "
+ "We are missing critical sales opportunities. "
+ "Our product is in no way inferior to the competitor products. "
+ "Our clients are hungry for analytical tools to improve their "
+ "business outcomes. Economy has nothing to do with it.";
// Call the service and get the tone
ToneOptions toneOptions = new ToneOptions.Builder()
.html(text)
.build();
ToneAnalysis tone = service.tone(toneOptions).execute();
System.out.println(tone);
}
}
PS:class名字以大写字母开头是很好的编码标准