概述
智能语义理解(Intelligent Semantic Understanding)依托阿里巴巴在深度学习、自然语言处理方向上的技术积累,为客户提供文本相似度和机器阅读理解等优质算法技术。其中文本相似度可以计算两段短文本之间的相似度,并给出相似度评分;机器阅读理解能针对某几个问题,从若干篇文章中分别寻找问题答案。智能语义理解技术可以应用于问答系统、信息检索、新闻推荐等场景。下面主要介绍该产品的开通及使用。
Step By Step
1、开通服务
2、开通后控制台概览
3、操作步骤,可以在控制台快速查看创建项目,然后查看进程
4、使用SDK进行相关操作
- 4.1 pom.xml
<dependencies>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-iqa</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.4.9</version>
</dependency>
</dependencies>
- 4.2 code sample
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.iqa.model.v20190813.*;
import com.aliyuncs.profile.DefaultProfile;
public class demo1 {
public static void main(String[] args) throws ClientException {
DefaultProfile profile = DefaultProfile.getProfile(
"cn-hangzhou",
"LTAIOZZgYX******",
"v7CjUJCMk7j9aKduMAQLjy********");
IAcsClient client = new DefaultAcsClient(profile);
// 调用ListProjects获取项目列表
ListProjectsRequest request = new ListProjectsRequest();
request.setProjectType("faq");
ListProjectsResponse response = client.getAcsResponse(request);
System.out.println("项目数量: " + response.getTotalCount());
// // 调用CreateProject创建一个项目
// CreateProjectRequest createProjectRequest = new CreateProjectRequest();
// createProjectRequest.setModelId("general");
// createProjectRequest.setProjectName("FaqProjectDemo1");
// createProjectRequest.setProjectType("faq");
// CreateProjectResponse createProjectResponse = client.getAcsResponse(createProjectRequest);
// System.out.println(createProjectResponse.getProjectId());
String projectId = "nynauj21********";// 使用创建项目获取的ProjectId
//
// // 调用UploadDictionary上传自定义词表,支持多次调用增量导入,此操作是用来对导入的document增加分词功能,可以不操作
// UploadDictionaryRequest uploadDictionaryRequest = new UploadDictionaryRequest();
// uploadDictionaryRequest.setDictionaryFileUrl("http://iqa-console.oss-cn-hangzhou.aliyuncs.com/example/iqa_example_shorttext.xlsx?spm=a2c4g.11186623.2.14.5d7b727d7qG2oF&Expires=2179036688&OSSAccessKeyId=LTAI2WA8174xk3ii&Signature=967zD%2BonZHoVbSZqkmxx8KVcEeI%3D");
// uploadDictionaryRequest.setProjectId(projectId);
// UploadDictionaryResponse uploadDictionaryResponse = client.getAcsResponse(uploadDictionaryRequest);
// System.out.println(uploadDictionaryResponse.getTotalCount());
// UploadDocumentRequest uploadDocumentRequest = new UploadDocumentRequest();
// uploadDocumentRequest.setDocumentFileUrl("http://iqa-console.oss-cn-hangzhou.aliyuncs.com/example/iqa_example_shorttext.xlsx?spm=a2c4g.11186623.2.14.5d7b727dtesby4&Expires=2179036688&OSSAccessKeyId=LTAI2WA8174xk3ii&Signature=967zD%2BonZHoVbSZqkmxx8KVcEeI%3D");
// uploadDocumentRequest.setProjectId(projectId);
// UploadDocumentResponse uploadDocumentResponse = client.getAcsResponse(uploadDocumentRequest);
// System.out.println(uploadDocumentResponse.getFileDataCount());
// // 调用DeployService发布一个项目
// DeployServiceRequest deployServiceRequest = new DeployServiceRequest();
// deployServiceRequest.setProjectId(projectId);
// DeployServiceResponse deployServiceResponse = client.getAcsResponse(deployServiceRequest);
// System.out.println(deployServiceResponse.getRequestId());
GetPredictResultRequest getPredictResultRequest = new GetPredictResultRequest();
getPredictResultRequest.setProjectId(projectId);
getPredictResultRequest.setQuestion("充话费");
getPredictResultRequest.setTopK(3);
GetPredictResultResponse getPredictResultResponse = client.getAcsResponse(getPredictResultRequest);
for (GetPredictResultResponse.PredictResult predictResult:getPredictResultResponse.getPredictResults()
) {
System.out.println("Question: " + predictResult.getQuestion() + " Answer: " + predictResult.getAnswer() + " Score: " + predictResult.getScore());
}
}
}
- 4.3 result
项目数量: 3
Question: 积分怎么充话费 Answer: Score: 0.9948719
Question: 积分充话费的方式 Answer: Score: 0.9937389
Question: 我怎么用积分充话费 Answer: Score: 0.47255847
5、Demo相关解释
- 5.1 [UploadDictionary]作用:
帮助分词,业务的一些专有词,默认分词分不出来的情况下需要用上传到自定义词表。
- 5.2 上传数据格式参考及解释。
- 5.3 用户答疑钉钉群号:23162166。(可在文件位置获取产品简介文档,对理解产品有很大帮助)