package com.lantone.structure.facade.tran;

import com.lantone.structure.ai.AIAnalyze;
import com.lantone.structure.client.CRFServiceClient;
import com.lantone.structure.client.SimilarityServiceClient;
import com.lantone.structure.model.InputInfo;
import com.lantone.structure.util.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @Description:
 * @author: rengb
 * @time: 2021/2/2 13:49
 */
@Slf4j
public abstract class TargetTran {

    InputInfo inputInfo;
    SimilarityServiceClient similarityServiceClient;
    CRFServiceClient crfServiceClient;

    public abstract Map<String, String> convert(String text);

    public TargetTran() {
        this.inputInfo = new InputInfo();
        similarityServiceClient = SpringContextUtil.getBean(SimilarityServiceClient.class);
        crfServiceClient = SpringContextUtil.getBean(CRFServiceClient.class);
    }

    public void aiProcess() {
        AIAnalyze aiAnalyze = new AIAnalyze(crfServiceClient, similarityServiceClient);
        try {
            aiAnalyze.aiProcess(inputInfo);
        } catch (Exception e) {
            log.error("AI模型执行错误：" + e.getMessage(), e);
        }
    }

}