阿里云首页 自然语言处理

事件抽取(英文)

注:本预训练模型提供的服务无需自主标注训练,直接调用API即可使用;

事件抽取(英文)服务适用于对英文新闻事件抽取,包含如下事件类别:

‘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代码示例

  1. DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou","your-access-id-key","your-access-id-secret");
  2. IAcsClient client = new DefaultAcsClient(defaultProfile);
  3. Map<String, Object> map = new HashMap<>();
  4. 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.";
  5. map.put("text", text);
  6. RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
  7. request.setServiceName("NLP-Event-Extraction-En");
  8. request.setPredictContent(JSON.toJSONString(map));
  9. RunPreTrainServiceResponse response = client.getAcsResponse(request);
  10. System.out.println(response.getPredictResult());

Python代码示例

  1. # 安装依赖
  2. pip install aliyun-python-sdk-core
  3. pip install aliyun-python-sdk-nlp-automl
  1. # -*- coding: utf8 -*-
  2. import json
  3. from aliyunsdkcore.client import AcsClient
  4. from aliyunsdkcore.acs_exception.exceptions import ClientException
  5. from aliyunsdkcore.acs_exception.exceptions import ServerException
  6. from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest
  7. # Initialize AcsClient instance
  8. client = AcsClient(
  9. "<your-access-key-id>",
  10. "<your-access-key-secret>",
  11. "cn-hangzhou"
  12. );
  13. 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."
  14. content ={"text": text}
  15. # Initialize a request and set parameters
  16. request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
  17. request.set_ServiceName('NLP-Event-Extraction-En')
  18. request.set_PredictContent(json.dumps(content))
  19. # Print response
  20. response = client.do_action_with_exception(request)
  21. resp_obj = json.loads(response)
  22. predict_result = json.loads(resp_obj['PredictResult'])
  23. print(predict_result['predictions'])

PredictContent内容示例

  1. {
  2. "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."
  3. }

PredictResult内容示例

  1. {
  2. "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 ."
  3. }

入参说明

参数 说明
text 待预测文本

出参说明

参数 说明
predictions 原文本上标注事件