<commit_before>/**
 * Copyright (C) 2015 <NAME> (<EMAIL>)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.brunocvcunha.dense4j;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.brunocvcunha.dense4j.ranker.CaseInsensitiveLinkedHashMap;
import org.brunocvcunha.dense4j.ranker.DenseRankerUtils;

/**
 * Main Class for the Dense4J Calculator
 * 
 * @author <NAME>
 *
 */
public class DenseCalculator {

    /**
     * Get keywords map based on the repetitions
     * 
     * @param text
     *            text to calculate density
     * @return map
     */
    public static Map<String, Integer> getKeywordsMap(String text) {
        String textLc = text.toLowerCase();
        String[] words = textLc.split("\\W");
        Map<String, Integer> uniques = new HashMap<String, Integer>();
        for (String word : words) {
            // ignore words 2 or less characters long
            if (word.length() <= 2) {
                continue;
            }

            if (uniques.containsKey(word)) {
                uniques.put(word, uniques.get(word) + 1);
            } else {<commit_msg>- add minLength as a parameter in the DenseCalculator<commit_after>/**
 * Copyright (C) 2015 <NAME> (<EMAIL>)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.brunocvcunha.dense4j;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.brunocvcunha.dense4j.ranker.CaseInsensitiveLinkedHashMap;
import org.brunocvcunha.dense4j.ranker.DenseRankerUtils;

/**
 * Main Class for the Dense4J Calculator
 * 
 * @author <NAME>
 *
 */
public class DenseCalculator {

    /**
     * Get keywords map based on the repetitions
     * 
     * @param text
     *            text to calculate density
     * @return map
     */
    public static Map<String, Integer> getKeywordsMap(String text) {
        return getKeywordsMap(text, 2);
    }
    
    /**
     * Get keywords map based on the repetitions
     * 
     * @param text
     *            text to calculate density
     * @param minLength
     *            min length of tokens
     * @return map
     */
    public static Map<String, Integer> getKeywordsMap(String text, int minLength) {
        String textLc = text.toLowerCase();
        String[] words = textLc.split("\\W");
        Map<String, Integer> uniques = new HashMap<String, Integer>();
        for (String word : words) {
            // ignore words 2 or less characters long
            if (word.length() <= minLength) {
                continue;
            }

            if (uniques.containsKey(word)) {
                uniques.put(word, uniques.get(word) + 1);
            } else {
{'fraction_non_alphanumeric': 0.09679978841576302, 'fraction_numerical': 0.007934408886537953, 'mean_word_length': 2.571293673276676, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6958753', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1056, 'n_words': 366}