package org.diagbot.nlp.feature.extract;

import org.diagbot.nlp.participle.word.Lexeme;
import org.diagbot.nlp.participle.word.LexemePath;
import org.diagbot.nlp.util.Constants;
import org.diagbot.nlp.util.NegativeEnum;
import org.diagbot.nlp.util.NlpUtil;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class CaseTokenFeature extends CaseToken {
    private NegativeEnum[] nees_symptom = new NegativeEnum[]{NegativeEnum.SYMPTOM,
            NegativeEnum.BODY_PART, NegativeEnum.PROPERTY, NegativeEnum.DEEP, NegativeEnum.DISEASE,
            NegativeEnum.CAUSE, NegativeEnum.VITAL_RESULT, NegativeEnum.VITAL_INDEX_VALUE, NegativeEnum.DIAG_STAND,
            NegativeEnum.SYMPTOM_PERFORMANCE, NegativeEnum.MEDICINE,NegativeEnum.MEDICINE_NAME, NegativeEnum.MEDICINE_PRD,
            NegativeEnum.OPERATION, NegativeEnum.TREATMENT, NegativeEnum.SYMPTOM_INDEX};

    {
        stop_symbol = NlpUtil.extendsSymbol(stop_symbol, new String[]{",", "，", ":", "："});
        Arrays.sort(stop_symbol);
    }

    public List<Map<String, Object>> analyze(LexemePath<Lexeme> lexemePath) throws Exception {
        super.sn = 0;
        //词性
        String property = null;
        List<Map<String, Object>> featuresList = new ArrayList<>();
        for (int index = 0; index < lexemePath.size(); index++) {
            Lexeme lexeme = lexemePath.get(index);
            property = lexeme.getProperty();
            if (NlpUtil.isFeature(property, nees_symptom)) {          //特征词 症状
                //特定的一些体征描述不需要参与推送
                searched_position = Arrays.binarySearch(vital_filter_data, lexeme.getText());
                if (searched_position > -1) {
                    continue;
                }
                lookFeatures(featuresList, index, lexemePath, lexeme, Constants.feature_type_feature, nees_symptom, true);
            }
        }
        return featuresList;
    }
}
