更新时间:2020-10-01 00:13
事件抽取(英文)服务适用于对英文新闻事件抽取,包含如下事件类别:‘Personnel.Nominate’, ‘Contact.Phone-Write’, ‘Business.Declare-Bankruptcy’, ‘Justice.Release-Parole’, ‘Justice.Extradite’, ‘Personnel.Start-Position’, ‘Justice.Fine’, ‘Transaction.Transfer-Money’, ‘Personnel.End-Position’, ‘Justice.Acquit’, ‘Life.Injure’, ‘Conflict.Attack’, ‘Justice.Arrest-Jail’, ‘Justice.Pardon’, ‘Justice.Charge-Indict’, ‘Conflict.Demonstrate’, ‘Contact.Meet’, ‘Business.End-Org’, ‘Life.Be-Born’, ‘Personnel.Elect’, ‘Justice.Trial-Hearing’, ‘Life.Divorce’, ‘Justice.Sue’, ‘Justice.Appeal’, ‘Business.Merge-Org’, ‘Life.Die’, ‘Business.Start-Org’, ‘Justice.Convict’, ‘Movement.Transport’, ‘Life.Marry’,’Justice.Sentence’, ‘Justice.Execute’, ‘Transaction.Transfer-Ownership’ 。
Java代码示例
DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou","your-access-id-key","your-access-id-secret");
IAcsClient client = new DefaultAcsClient(defaultProfile);
Map<String, Object> map = new HashMap<>();
String text = "As part of the 11-billion-dollar sale of USA Interactive's film and television operations to the French media company in December 2001, USA Interactive received 2.5 billion dollars in preferred shares in Vivendi Universal Entertainment.";
map.put("text", text);
RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
request.setServiceName("NLP-Event-Extraction-En");
request.setPredictContent(JSON.toJSONString(map));
RunPreTrainServiceResponse response = client.getAcsResponse(request);
System.out.println(response.getPredictResult());
Python代码示例
# 安装依赖
pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-nlp-automl
# -*- coding: utf8 -*-
import json
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest
# Initialize AcsClient instance
client = AcsClient(
"<your-access-key-id>",
"<your-access-key-secret>",
"cn-hangzhou"
);
text = "As part of the 11-billion-dollar sale of USA Interactive's film and television operations to the French media company in December 2001, USA Interactive received 2.5 billion dollars in preferred shares in Vivendi Universal Entertainment."
content ={"text": text}
# Initialize a request and set parameters
request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
request.set_ServiceName('NLP-Event-Extraction-En')
request.set_PredictContent(json.dumps(content))
# Print response
response = client.do_action_with_exception(request)
resp_obj = json.loads(response)
predict_result = json.loads(resp_obj['PredictResult'])
print(predict_result['predictions'])
PredictContent内容示例
{
"messages": "As part of the 11-billion-dollar sale of USA Interactive's film and television operations to the French media company in December 2001, USA Interactive received 2.5 billion dollars in preferred shares in Vivendi Universal Entertainment."
}
PredictResult内容示例
{
"predictions":"As part of the 11-billion-dollar <event type = Transaction.Transfer-Ownership>sale<event> of USA Interactive's film and television operations to the French media company in December 2001, USA Interactive <event type = Transaction.Transfer-Money>received<event> 2.5 billion dollars in preferred shares in Vivendi Universal Entertainment ."
}
入参说明
参数 | 说明 |
---|---|
text | 待预测文本 |
出参说明
参数 | 说明 |
---|---|
predictions | 原文本上标注事件 |
在文档使用中是否遇到以下问题
更多建议
匿名提交