package org.diagbot.push.controller;

import org.diagbot.nlp.relation.analyze.StructureAnalyze;
import org.diagbot.nlp.relation.util.OutputInfo;
import org.diagbot.pub.api.Response;
import org.diagbot.pub.web.BaseController;
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.push.controller.RelationController
 * @Description TODO
 * @Author fyeman
 * @Date 2019/1/22/022 13:33
 * @Version 1.0
 **/
@Controller
@RequestMapping("/relation")
public class RelationController extends BaseController {
    {
        listView = "/pages/relation/sample.html";
    }
    @RequestMapping({"/index"})
    public String index() {
        return listView;
    }

    @RequestMapping({"/list"})
    public String list() {
        return "/pages/label/list.html";
    }

    @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"));
        StructureAnalyze structureAnalyze = new StructureAnalyze();
        List<OutputInfo> outputInfos = structureAnalyze.extract(content);
        response.setData(outputInfos);
        return response;
    }
}
