改动:注掉了line 172行,原因:jdk1.7版本好像编译java doc时会报错。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<groupId>ai.olamigroupId>
<artifactId>olami-java-client-sdkartifactId>
<version>1.0.1version>
<packaging>pompackaging>
<name>OLAMI Java Client SDKname>
<url>http://olami.aiurl>
<description>OLAMI APIs Java client library and samplesdescription>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<jdk.version>1.7jdk.version>
properties>
<licenses>
<license>
<name>The Apache Software License, Version 2.0name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txturl>
license>
licenses>
<developers>
<developer>
<name>olaminame>
<email>[email protected]email>
developer>
developers>
<scm>
<connection>scm:[email protected]:olami-developers/olami-java-client-sdk.gitconnection>
<developerConnection>scm:[email protected]:olami-developers/olami-java-client-sdk.gitdeveloperConnection>
<url>https://github.com/olami-developers/olami-java-client-sdkurl>
scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junitgroupId>
<artifactId>junitartifactId>
<version>3.8.1version>
<scope>testscope>
dependency>
<dependency>
<groupId>com.google.code.gsongroupId>
<artifactId>gsonartifactId>
<version>2.8.0version>
dependency>
dependencies>
dependencyManagement>
<modules>
<module>libmodule>
modules>
<profiles>
<profile>
<id>allid>
<modules>
<module>examples/text-input-examplemodule>
<module>examples/speech-input-examplemodule>
<module>examples/dump-nli-results-examplemodule>
<module>examples/async-text-chatbot-examplemodule>
modules>
profile>
<profile>
<id>release-sign-bintrayid>
<distributionManagement>
<repository>
<id>bintray-olami-developers-api-clientid>
<name>olami-developers-api-clientname>
<url>https://api.bintray.com/maven/olami-developers/api-client/olami-java-client-sdk/;publish=1url>
repository>
distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-source-pluginartifactId>
<version>3.0.1version>
<executions>
<execution>
<id>attach-sourcesid>
<goals>
<goal>jar-no-forkgoal>
goals>
execution>
executions>
plugin>
plugins>
build>
profile>
profiles>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<version>3.6.1version>
<configuration>
<source>1.7source>
<target>1.7target>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-antrun-pluginartifactId>
<version>1.8version>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-jar-pluginartifactId>
<version>3.0.2version>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-assembly-pluginartifactId>
<version>3.0.0version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependenciesdescriptorRef>
descriptorRefs>
<appendAssemblyId>falseappendAssemblyId>
configuration>
plugin>
plugins>
pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-antrun-pluginartifactId>
<executions>
<execution>
<phase>cleanphase>
<configuration>
<tasks>
<delete dir="bin"/>
tasks>
configuration>
<goals>
<goal>rungoal>
goals>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-javadoc-pluginartifactId>
<version>2.10.4version>
<configuration>
<excludePackageNames>org.*excludePackageNames>
<encoding>${chartset.UTF8}encoding>
<aggregate>trueaggregate>
<charset>${chartset.UTF8}charset>
<docencoding>${chartset.UTF8}docencoding>
configuration>
<executions>
<execution>
<id>attach-javadocsid>
<goals>
<goal>jargoal>
goals>
execution>
executions>
plugin>
plugins>
build>
project>
改动:maven的pom.xml中jdk.version由1.8改为1.7,在jdk1.7环境编译。
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<groupId>ai.olami.examplegroupId>
<artifactId>async-text-chatbot-exampleartifactId>
<version>20170708version>
<packaging>jarpackaging>
<name>OLAMI Java Client Examples: Async Text Chatbotname>
<url>http://olami.aiurl>
<parent>
<groupId>ai.olamigroupId>
<artifactId>olami-java-client-sdkartifactId>
<version>1.0.1version>
<relativePath>../../pom.xmlrelativePath>
parent>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<jdk.version>1.7jdk.version>
properties>
<dependencies>
<dependency>
<groupId>junitgroupId>
<artifactId>junitartifactId>
dependency>
<dependency>
<groupId>ai.olamigroupId>
<artifactId>olami-java-clientartifactId>
<version>${project.parent.version}version>
dependency>
<dependency>
<groupId>ai.olami.examplegroupId>
<artifactId>dump-nli-results-exampleartifactId>
<version>20170708version>
dependency>
dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-jar-pluginartifactId>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-assembly-pluginartifactId>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-antrun-pluginartifactId>
<executions>
<execution>
<phase>installphase>
<configuration>
<tasks>
<copy todir="../../bin/examples/${project.artifactId}">
<fileset dir="${project.build.directory}">
<include name="*${project.artifactId}.jar"/>
fileset>
copy>
tasks>
configuration>
<goals>
<goal>rungoal>
goals>
execution>
executions>
plugin>
plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<version>3.6.1version>
<configuration>
<source>1.7source>
<target>1.7target>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-assembly-pluginartifactId>
<configuration>
<finalName>${project.artifactId}finalName>
<archive>
<manifest>
<mainClass>ai.olami.example.AsyncTextChatbotExamplemainClass>
manifest>
archive>
configuration>
<executions>
<execution>
<id>make-assemblyid>
<phase>packagephase>
<goals>
<goal>singlegoal>
goals>
execution>
executions>
plugin>
plugins>
pluginManagement>
build>
project>
改动:sample里有一个AsyncTextChatbotExample是依赖于jdk1.8的CompletableFuture的,这里保证sample原有功能,将代码修改成同步的了。
/*
Copyright 2017, VIA Technologies, Inc. & OLAMI Team.
http://olami.ai
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ai.olami.example;
import java.util.Scanner;
import ai.olami.cloudService.APIConfiguration;
import ai.olami.cloudService.APIResponse;
import ai.olami.cloudService.TextRecognizer;
import ai.olami.nli.NLIResult;
public class AsyncTextChatbotExample {
// * Replace your APP KEY with this variable.
private static String appKey = "*****your-app-key*****";
// * Replace your APP SECRET with this variable.
private static String appSecret = "*****your-app-secret*****";
// * Replace the localize option you want with this variable.
// * - Use LOCALIZE_OPTION_SIMPLIFIED_CHINESE for China
// * - Use LOCALIZE_OPTION_TRADITIONAL_CHINESE for Taiwan
private static int localizeOption = APIConfiguration.LOCALIZE_OPTION_SIMPLIFIED_CHINESE;
// private static int localizeOption = APIConfiguration.LOCALIZE_OPTION_TRADITIONAL_CHINESE;
public static void main(String[] args) throws Exception {
if (args.length == 3) {
initByInputArgs(args);
} else if (args.length > 0) {
printUsageAndExit();
}
// * Step 1: Configure your key and localize option.
APIConfiguration config = new APIConfiguration(appKey, appSecret, localizeOption);
// * Step 2: Create the text recognizer.
TextRecognizer recoginzer = new TextRecognizer(config);
System.out.format("\nTell me your name: ");
Scanner reader = new Scanner(System.in);
boolean fristTalk = true;
while (reader.hasNext()) {
if (fristTalk) {
String userName = reader.nextLine();
if (userName.isEmpty()) {
userName = " YOU ";
}
// Setup end user information.
recoginzer.setEndUserIdentifier(userName);
fristTalk = false;
System.out.format("\nHi! %s\n", userName);
System.out.format("\nType to say something or 'bye' to exit:\n");
}
String whatUserSays = reader.nextLine();
if (whatUserSays.toLowerCase().equals("bye")) {
System.out.format("\n[ OLAMI Robot ] Says: Bye!\n\n");
reader.close();
break;
} else {
System.out.format("\n[ %s ] Says: %s\n",
recoginzer.getEndUserIdentifier(),
whatUserSays);
}
// * Send text
APIResponse wsResponse = recoginzer.requestNLI(whatUserSays);
//System.out.println("\nOriginal Response : " + wsResponse.toString());
//System.out.println("\n---------- dump ----------\n");
//System.out.println(jsonDump.toJson(wsResponse));
//System.out.println("\n--------------------------\n");
// Check request status.
if (wsResponse.ok() && wsResponse.hasData()) {
NLIResult[] nliResults = wsResponse.getData().getNLIResults();
// Get the reply content.
if (nliResults[0].hasDescObject()) {
String reply = nliResults[0].getDescObject().getReplyAnswer();
if (reply.isEmpty()) {
System.out.format("\n[ OLAMI Robot ] Says: ...\n");
} else {
// Show the reply.
System.out.format(
"\n[ OLAMI Robot ] Says: %s", reply);
// Show IDS data.
if (nliResults[0].isFromIDS()
&& nliResults[0].hasDataObjects()) {
System.out.println("\n");
DumpIDSDataExample.dumpIDSData(nliResults[0]);
System.out.println("\n");
}
}
System.out.format(" (Say 'bye' to exit)\n");
}
}
}
}
private static void printUsageAndExit() {
System.out.println("\n Usage:");
System.out.println("\t args[0]: your_app_key");
System.out.println("\t args[1]: your_app_secret");
System.out.println("\t args[2]: localize_option=[0|1]");
System.out.println("\n");
System.exit(0);
}
private static void initByInputArgs(String[] args) {
appKey = args[0];
appSecret = args[1];
localizeOption = Integer.parseInt(args[2]);
}
}