<commit_before>package cn.edu.seu.kse.lpmln.solver;

import cn.edu.seu.kse.lpmln.model.WeightedAnswerSet;

import java.util.*;

/**
 * Created by 王彬 on 2016/8/31.
 */
public class LPMLNBaseSolver extends AdvancedBaseSolver {

    @Override
    public String marginalDistribution(int factor){
        Date enter=new Date();
        HashMap<String,Double> result=new HashMap<>();
        double wsum=0;
        double expw=0;


        HashSet<String> literals=null;
        for(WeightedAnswerSet as : weightedAs){
            expw=as.getProbability();
            literals=as.getAnswerSet().getLiterals();
            for(String lit:literals){
                if(result.containsKey(lit)){
                    wsum=result.get(lit);
                }else {
                    wsum=0;
                }
                wsum+=expw;
                result.put(lit,wsum);
            }
        }

        String res= formateMarginalResult(result);
        Date exit=new Date();
        StringBuilder sb=new StringBuilder();
        sb.append("求边缘分布用时：").append(exit.getTime()-enter.getTime()).append(" ms");
        sb.append(System.lineSeparator());
        marginalTime=sb.toString();
        return res;
    }

    public String formateMarginalResult(HashMap<String, Double> result){
        StringBuilder fres=new StringBuilder();
        for(HashMap.Entry<String,Double> entry:result.entrySet()){
            fres.append(entry.getKey()).append("  ").append(entry.getValue()).append(System.lineSeparator());
        }
        return fres.toString();<commit_msg>拼写错误<commit_after>package cn.edu.seu.kse.lpmln.solver;

import cn.edu.seu.kse.lpmln.model.WeightedAnswerSet;

import java.util.*;

/**
 * Created by 王彬 on 2016/8/31.
 */
public class LPMLNBaseSolver extends AdvancedBaseSolver {

    @Override
    public String marginalDistribution(int factor){
        Date enter=new Date();
        HashMap<String,Double> result=new HashMap<>();
        double wsum=0;
        double expw=0;


        HashSet<String> literals=null;
        for(WeightedAnswerSet as : weightedAs){
            expw=as.getProbability();
            literals=as.getAnswerSet().getLiterals();
            for(String lit:literals){
                if(result.containsKey(lit)){
                    wsum=result.get(lit);
                }else {
                    wsum=0;
                }
                wsum+=expw;
                result.put(lit,wsum);
            }
        }

        String res= formatMarginalResult(result);
        Date exit=new Date();
        StringBuilder sb=new StringBuilder();
        sb.append("求边缘分布用时：").append(exit.getTime()-enter.getTime()).append(" ms");
        sb.append(System.lineSeparator());
        marginalTime=sb.toString();
        return res;
    }

    public String formatMarginalResult(HashMap<String, Double> result){
        StringBuilder fres=new StringBuilder();
        for(HashMap.Entry<String,Double> entry:result.entrySet()){
            fres.append(entry.getKey()).append("  ").append(entry.getValue()).append(System.lineSeparator());
        }
        return fres.toString();
{'fraction_non_alphanumeric': 0.1287415513356936, 'fraction_numerical': 0.006437077566784679, 'mean_word_length': 2.240875912408759, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '137101', 'n_tokens_mistral': 942, 'n_tokens_neox': 915, 'n_words': 149}