package com.qiuguo.iot.third.enums;


import com.qiuguo.iot.base.enums.AskTypeEnum;
import com.qiuguo.iot.base.utils.StringUtils;
import com.qiuguo.iot.data.entity.device.DeviceUserBindEntity;
import com.qiuguo.iot.data.entity.system.SystemTalkAnswerConfigEntity;
import com.qiuguo.iot.third.nlp.action.Action;
import com.qiuguo.iot.third.nlp.action.ActionTime;
import com.qiuguo.iot.third.nlp.action.Actions;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/*
* 词性表
* 作者：吴林
* */
// 中文词性表
@Slf4j
public enum ChinesePartSpeechEnum implements IChinesePartSpeech{

    v(0, "动词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            action.setAction(key);
            SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(action.getAction(), keyGroup);
            if(entity != null){
                systemTalkAnswerConfigEntities.add(entity);
            }
            actions.setA(1);
            return action;
        }
    },
    /*vd(0, "副动词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    vn(0, "名动词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },



    ng(1, "名语素"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    nr(2, "人名"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },//LAC PER
    PER(2, "人名"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    ns(3, "地名"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },*/
    nt(4, "机构团体"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            action.getLbs().add(key);
            return action;
        }
    },
    ORG(4, "机构团体"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return nt.getAction(keyGroup, key, actions, action, systemTalkAnswerConfigEntities, includs, commands);
        }
    },
    LOC(4, "机构团体"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return nt.getAction(keyGroup, key, actions, action, systemTalkAnswerConfigEntities, includs, commands);
        }
    },
    /*nz(5, "其他专名"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },*/
    n(6, "名词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            //匹配到关键词就不能作为名词加入，未匹配到的，分割前的都加入名词
            SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(key, keyGroup);
            if(entity != null){
                if(entity.getAnswerType().equals(AskTypeEnum.IOT.getCode())){
                    systemTalkAnswerConfigEntities.add(entity);
                    actions.setA(1);
                    //已记录的加进去
                    if(StringUtils.isNotEmpty(actions.getName())){
                        //
                        entity = getSystemTalkWithKey(actions.getName(), keyGroup);
                        if(entity != null){
                            systemTalkAnswerConfigEntities.add(entity);
                            actions.setA(1);
                        }else{
                            //这里会走到a+b=2
                            action.setName(actions.getName());
                            actions.setB(1);
                            actions.setName("");
                        }
                    }
                }else{
                    log.info("IOT不支持的自定义指令");
                }

            }else{
                if(actions.getB() == 1 && actions.getA() == 0){
                    //本名称没有找到对应的动作
                    action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
                    action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
                    action.setDeviceUserBindEntity(actions.getLastDeviceUserBindEntity());
                    actions.getActions().add(action);
                    actions.setLastName(action.getName());//lastName = action.getName();
                    actions.setLastDeviceUserBindEntity(action.getDeviceUserBindEntity());

                    action = new Action();
                    actions.setName("");//name = "";
                    action.setLbs(new ArrayList<>());
                    action.setAsk(actions.getRecordText());
                }
                actions.setName(actions.getName() + key);//name += key.getKey();
            }
            return action;
        }
    },
    q(7, "量词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },

    /*b(8, "区别词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },*/
    c(9, "连接词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            if(StringUtils.isNotEmpty(actions.getName())){
                //action.setName(name);//.add(name);
                SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(actions.getName(), keyGroup);
                if(entity != null){
                    if(entity.getAnswerType().equals(AskTypeEnum.IOT.getCode())){
                        systemTalkAnswerConfigEntities.add(entity);
                        actions.setA(1);//a = 1;
                    }else{
                        log.info("IOT不支持的自定义指令");
                    }

                }else{
                    if(actions.getB() == 1 && actions.getA() == 0){
                        //本名称没有找到对应的动作
                        action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
                        action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
                        action.setDeviceUserBindEntity(actions.getLastDeviceUserBindEntity());
                        actions.getActions().add(action);
                        actions.setLastName(action.getName());
                        actions.setLastDeviceUserBindEntity(action.getDeviceUserBindEntity());

                        action = new Action();
                        actions.setName("");
                        //action.setName(new ArrayList<>());
                        action.setLbs(new ArrayList<>());
                        action.setAsk(actions.getRecordText());
                    }
                    action.setName(actions.getName());
                    //name = "";
                    actions.setB(1);//b = 1;
                }
            }
            actions.setName("");//name = "";
            return action;
        }
    },
    /*dg(10, "副语素"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    d(10, "副词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    e(11, "叹词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    f(12, "方位词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    g(13, "语素"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    h(14, "前街成分"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },//LAC t
    i(15, "成语"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },//LAC vn
    j(16, "简称略语"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    k(17, "后接成分"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    l(18, "习惯用语"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },*/
    m(19, "数词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            action.setStatus(key);
            return action;
        }
    },
    /*o(20, "拟声词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    p(21, "介词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },

    r(22, "代词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    s(23, "触动词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    tg(24, "时语素"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                ist<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },*/
    t(25, "时间词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            //解析时间关键字
            action.setTime(new ActionTime());
            action.getTime().setTime(key);
            return action;
        }
    },//LAC TIME
    TIME(25, "时间词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return t.getAction(keyGroup, key, actions, action, systemTalkAnswerConfigEntities, includs, commands);
        }
    },//LAC TIME
   /* u(26, "助词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    vg(27, "动语素"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },*/

    a(28, "形容词:包含 ad ag an"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return n.getAction(keyGroup, key, actions, action, systemTalkAnswerConfigEntities, includs, commands);
        }
    },
    /*ag(28, "形玉素"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    ad(28, "副形词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                     List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    an(28, "名形词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },*/
    w(29, "标点符号"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return c.getAction(keyGroup, key, actions, action, systemTalkAnswerConfigEntities, includs, commands);
        }
    },
    /*x(30, "非语素词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    y(31, "语气词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },//LAC xc
    xc(31, "语气词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },//LAC xc
    z(32, "状态词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    un(33, "未知词"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup, 
                                String key, 
                                Actions actions, 
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },
    zd(99, "自定义"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup,
                     String key,
                     Actions actions,
                     Action action,
                     List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities, 
                     List<DeviceUserBindEntity> includs,
                     List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    },*/

    qg(100, "在查找字符串时用来临时替换用户命名的设备，目前最多同时支持20个，见LAC字典>1<"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup,
                     String key,
                     Actions actions,
                     Action action,
                     List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities, 
                     List<DeviceUserBindEntity> includs,
                     List<SystemTalkAnswerConfigEntity> commands){
            if(actions.getB() == 1 && actions.getA() == 0){
                //本名称没有找到对应的动作
                action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
                action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
                action.setDeviceUserBindEntity(actions.getLastDeviceUserBindEntity());
                actions.getActions().add(action);
                actions.setLastName(action.getName());
                actions.setLastDeviceUserBindEntity(action.getDeviceUserBindEntity());

                action = new Action();
                actions.setName("");
                action.setLbs(new ArrayList<>());
                action.setAsk(actions.getRecordText());
            }
            int index = Integer.parseInt(key.replace(">", ""));
            action.setDeviceUserBindEntity(includs.get(index));
            actions.setName("");
            action.setName(action.getDeviceUserBindEntity().getBindName());
            actions.setB(1);
            return action;
        }
    },
    qj(101, "在查找字符串时用来临时替换系统自定义动词后面词，目前最多同时支持20个，见LAC字典>1<"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup,
                                String key,
                                Actions actions,
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            //动词后面的名词只支持已经产生的action，后面的不要
            int index = Integer.parseInt(key.replace("#", ""));
            action.setActionCommand(commands.get(index).getAskKey());
            for (Action ac: actions.getActions()
                 ) {
                if(!StringUtils.isNotEmpty(ac.getActionCommand())){
                    ac.setActionCommand(action.getActionCommand());
                }

            }
            return action;
        }
    },
    DEFAULT(1000, "默认"){
        @Override
        public Action getAction(ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup,
                                String key,
                                Actions actions,
                                Action action,
                                List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
                                List<DeviceUserBindEntity> includs,
                                List<SystemTalkAnswerConfigEntity> commands){
            return action;
        }
    }
    ;
     ChinesePartSpeechEnum(Integer c, String n){
        code = c;
        name = n;
    }
    private Integer code;
    private String name;



    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ChinesePartSpeechEnum getEnumWithCode(Integer c){
        for (ChinesePartSpeechEnum e:values()
        ) {
            if(e.getCode().compareTo(c) == 0){
                return e;
            }
        }
        return DEFAULT;
    }
    public static ChinesePartSpeechEnum getEnumWithName(String name){

        for (ChinesePartSpeechEnum e:values()
        ) {
            if(e.getName().equals(name)){
                return e;
            }
        }
        return DEFAULT;
    }
    public static ChinesePartSpeechEnum getWitchValue(String tag) {
        for (ChinesePartSpeechEnum e:values()
        ) {
            if(tag.equals(e.toString())){
                return e;
            }
        }
        return DEFAULT;
    }

    private static SystemTalkAnswerConfigEntity getSystemTalkWithKey(String key,
                                                                     ConcurrentHashMap<String, SystemTalkAnswerConfigEntity> keyGroup){
        if(keyGroup.containsKey(key)){
            return keyGroup.get(key);
        }
        return null;
    }
    
}
