package org.diagbot.nlp.controller;

import org.diagbot.nlp.feature.FeatureType;
import org.diagbot.nlp.relation.RelationAnalyze;
import org.diagbot.nlp.relation.extract.output.OutputInfo;
import org.diagbot.pub.api.Response;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ClassName org.diagbot.nlp.controller.RelationExtractionController
 * @Description TODO
 * @Author fyeman
 * @Date 2019/1/17/017 11:21
 * @Version 1.0
 **/
@Controller
@RequestMapping("/relation")
public class RelationExtractionController {

    @RequestMapping({"/extraction"})
    @ResponseBody
    public Response extraction(String content) throws Exception {
        Response response = new Response();
        response.start();
        RelationAnalyze relationAnalyze = new RelationAnalyze();
        List<OutputInfo> outputInfos = relationAnalyze.analyze(content, FeatureType.parse("1"));
        response.setData(outputInfos);
        return response;
    }
}
