<commit_before>package com.grayben.riskExtractor.htmlScorer.partScorers.tagScorers;

import com.grayben.riskExtractor.htmlScorer.partScorers.Scorer;

import java.util.Map;

/**
 * Created by beng on 17/12/2015.
 */
public abstract class MapScorer<T> extends Scorer<T> {

    Map<T, Integer> scoresMap;

    protected MapScorer(String scoreLabel, Map<T, Integer> scoresMap) {
        super(scoreLabel);
        if(scoresMap == null){
            throw new NullPointerException(
                    "The scores map can not be null"
            );
        }
        if(scoresMap.isEmpty()){
            throw new IllegalArgumentException(
                    "The scores map cannot be empty"
            );
        }
        this.scoresMap = scoresMap;
    }

    @Override
    public int score(T input){
        validateScoreInput(input);
        boolean containsKey = scoresMap.containsKey(input);
        if (containsKey)
            return scoresMap.get(input);<commit_msg>Add accessor to unmodifiable copy of scoresMap<commit_after>package com.grayben.riskExtractor.htmlScorer.partScorers.tagScorers;

import com.grayben.riskExtractor.htmlScorer.partScorers.Scorer;

import java.util.Collections;
import java.util.Map;

/**
 * Created by beng on 17/12/2015.
 */
public abstract class MapScorer<T> extends Scorer<T> {

    Map<T, Integer> scoresMap;

    public Map<T, Integer> getScoresMap() {
        return Collections.unmodifiableMap(scoresMap);
    }

    protected MapScorer(String scoreLabel, Map<T, Integer> scoresMap) {
        super(scoreLabel);
        if(scoresMap == null){
            throw new NullPointerException(
                    "The scores map can not be null"
            );
        }
        if(scoresMap.isEmpty()){
            throw new IllegalArgumentException(
                    "The scores map cannot be empty"
            );
        }
        this.scoresMap = scoresMap;
    }

    @Override
    public int score(T input){
        validateScoreInput(input);
        boolean containsKey = scoresMap.containsKey(input);
        if (containsKey)
            return scoresMap.get(input);
{'fraction_non_alphanumeric': 0.09258384506376949, 'fraction_numerical': 0.007557864903164856, 'mean_word_length': 2.3565768621236134, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '5567632', 'n_tokens_mistral': 627, 'n_tokens_neox': 585, 'n_words': 143}