<commit_before>package pl.edu.icm.coansys.similarity.documents.function;

import java.util.List;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author akawa
 */
public class AvgSimilarityFunction implements SimilarityFunction {

    @Override
    public double getDocumentsKeywordSimilarity(String keyword, byte[] doc1key, double doc1keywordWeight, byte[] doc2key, double doc2keywordWeight) {
        return doc1keywordWeight * doc2keywordWeight;
    }

    @Override
    public double getDocumentsTotalSimilarity(byte[] doc1key, byte[] doc2key, List<Double> keywordsSimilarities) {
        double similarity = keywordsSimilarities.get(0);
        for (int i = 1; i < keywordsSimilarities.size(); ++i) {
            similarity *= keywordsSimilarities.get(i);
        }
        
        similarity /= keywordsSimilarities.size();
        return similarity;
    }<commit_msg>small update<commit_after>package pl.edu.icm.coansys.similarity.documents.function;

import java.util.List;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author akawa
 */
public class AvgSimilarityFunction implements SimilarityFunction {
    
    private static double EMPTY_VALUE = 0d;

    @Override
    public double getDocumentsKeywordSimilarity(String keyword, byte[] doc1key, double doc1keywordWeight, byte[] doc2key, double doc2keywordWeight) {
        return doc1keywordWeight * doc2keywordWeight;
    }

    @Override
    public double getDocumentsTotalSimilarity(byte[] doc1key, byte[] doc2key, List<Double> keywordsSimilarities) {
        if (keywordsSimilarities == null || keywordsSimilarities.isEmpty()) {
            return EMPTY_VALUE;
        }
        
        double similarity = keywordsSimilarities.get(0);
        for (int i = 1; i < keywordsSimilarities.size(); ++i) {
            similarity *= keywordsSimilarities.get(i);
        }
        
        similarity /= keywordsSimilarities.size();
        return similarity;
    }
{'fraction_non_alphanumeric': 0.09431210500729217, 'fraction_numerical': 0.010209042294603793, 'mean_word_length': 3.243298969072165, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1225725', 'n_tokens_mistral': 597, 'n_tokens_neox': 557, 'n_words': 144}