<commit_before>package roart.aggregatorindicator.impl;

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

import org.apache.commons.math3.util.Pair;

import roart.aggregatorindicator.AggregatorIndicator;
import roart.common.config.MyMyConfig;
import roart.common.pipeline.PipelineConstants;
import roart.indicator.AbstractIndicator;

public abstract class Recommend extends AggregatorIndicator {
    public Recommend(MyMyConfig conf) {
        super(conf);
    }
    public abstract List<Pair<String, String>> getBuyList();
    public abstract List<Pair<String, String>> getSellList();
    public abstract String complexity();
    
    public static Map<String, List<Recommend>> getUsedRecommenders(MyMyConfig conf) {
        List<Recommend> all = new ArrayList<>();
        all.add(new MACDRecommendSimple(conf));
        all.add(new MACDRecommendComplex(conf));
        all.add(new RSIRecommendSimple(conf));
        all.add(new RSIRecommendComplex(conf));
        all.add(new ATRRecommendComplex(conf));
        all.add(new CCIRecommendComplex(conf));
        all.add(new STOCHRecommendComplex(conf));
        all.add(new STOCHRSIRecommendComplex(conf));
        Map<String, List<Recommend>> result = new HashMap<>();
        for (Recommend recommend : all) {
            if (recommend.isEnabled()) {
                List<Recommend> recommendList = result.get(recommend.complexity());
                if (recommendList == null) {
                    recommendList = new ArrayList<>();
                }
                recommendList.add(recommend);
                result.put(recommend.complexity(), recommendList);
            }
        }
        return result;
    }
    
    public static Map<String, List<String>[]> getRecommenderKeyMap(Map<String, List<Recommend>> usedRecommenders, Map<String, AbstractIndicator> usedIndicatorMap, MyMyConfig conf) {
        Map<String, List<String>[]> result = new HashMap<>();
        for (String complexity : usedRecommenders.keySet()) {
            List<String>[] recommenders = new ArrayList[2];
            List<Recommend> recommenderList = usedRecommenders.get(complexity);
            List<String> buyList = new ArrayList<>();
            List<String> sellList = new ArrayList<>();
            for (Recommend recommend : recommenderList) {
                AbstractIndicator indicator = usedIndicatorMap.get(recommend.indicator());
                Map<String, Object> resultMap = indicator.getLocalResultMap();
                Map<String, Object[]> objMap = (Map<String, Object[]>) resultMap.get(PipelineConstants.OBJECT);
                if (objMap != null) { 
                    List<Pair<String, String>> aBuyList = recommend.getBuyList();
                    for (Pair<String, String> pair : aBuyList) {
                        String key = pair.getFirst();
                        String cnf = pair.getSecond();
                        if ((boolean) conf.getValueOrDefault(cnf)) {<commit_msg>Catch exception cause.<commit_after>package roart.aggregatorindicator.impl;

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

import org.apache.commons.math3.util.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import roart.aggregatorindicator.AggregatorIndicator;
import roart.common.config.MyMyConfig;
import roart.common.pipeline.PipelineConstants;
import roart.indicator.AbstractIndicator;

public abstract class Recommend extends AggregatorIndicator {
    protected static Logger log = LoggerFactory.getLogger(AggregatorIndicator.class);

    public Recommend(MyMyConfig conf) {
        super(conf);
    }
    public abstract List<Pair<String, String>> getBuyList();
    public abstract List<Pair<String, String>> getSellList();
    public abstract String complexity();
    
    public static Map<String, List<Recommend>> getUsedRecommenders(MyMyConfig conf) {
        List<Recommend> all = new ArrayList<>();
        all.add(new MACDRecommendSimple(conf));
        all.add(new MACDRecommendComplex(conf));
        all.add(new RSIRecommendSimple(conf));
        all.add(new RSIRecommendComplex(conf));
        all.add(new ATRRecommendComplex(conf));
        all.add(new CCIRecommendComplex(conf));
        all.add(new STOCHRecommendComplex(conf));
        all.add(new STOCHRSIRecommendComplex(conf));
        Map<String, List<Recommend>> result = new HashMap<>();
        for (Recommend recommend : all) {
            if (recommend.isEnabled()) {
                List<Recommend> recommendList = result.get(recommend.complexity());
                if (recommendList == null) {
                    recommendList = new ArrayList<>();
                }
                recommendList.add(recommend);
                result.put(recommend.complexity(), recommendList);
            }
        }
        return result;
    }
    
    public static Map<String, List<String>[]> getRecommenderKeyMap(Map<String, List<Recommend>> usedRecommenders, Map<String, AbstractIndicator> usedIndicatorMap, MyMyConfig conf) {
        Map<String, List<String>[]> result = new HashMap<>();
        for (String complexity : usedRecommenders.keySet()) {
            List<String>[] recommenders = new ArrayList[2];
            List<Recommend> recommenderList = usedRecommenders.get(complexity);
            List<String> buyList = new ArrayList<>();
            List<String> sellList = new ArrayList<>();
            for (Recommend recommend : recommenderList) {
                AbstractIndicator indicator = usedIndicatorMap.get(recommend.indicator());
                if (indicator == null) {
                    int jj = 0;
                    log.error("Indicator null for {} {}", recommend.indicator(), complexity);
                    continue;
                }
                Map<String, Object> resultMap = indicator.getLocalResultMap();
                Map<String, Object[]> objMap = (Map<String, Object[]>) resultMap.get(PipelineConstants.OBJECT);
                if (objMap != null) { 
                    List<Pair<String, String>> aBuyList = recommend.getBuyList();
                    for (Pair<String, String> pair : aBuyList) {
                        String key = pair.getFirst();
                        String cnf = pair.getSecond();
                        if ((boolean) conf.getValueOrDefault(cnf)) {
{'fraction_non_alphanumeric': 0.11175730902232002, 'fraction_numerical': 0.0011002829298962591, 'mean_word_length': 2.701570680628272, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2372584', 'n_tokens_mistral': 1758, 'n_tokens_neox': 1682, 'n_words': 361}