<commit_before>﻿using System;
using System.Collections.Generic;
using LemmaSharp;

namespace ReverseDictionary.DictionaryMakers
{
    class ReverseDictionaryMaker : IDictionaryMaker
    {
        public IDictionary<string, int> MakeDictionary(string text, ILemmatizer lemmatizer)
        {
            var dictionary = new SortedDictionary<String, int>(new ReverseStringComparer());

            var words = text.Split(new[] { ' ', ',', '.', ')', '(', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var word in words)
            {
                string lowerWord = lemmatizer.Lemmatize(word.ToLower().Trim());

                if (!dictionary.ContainsKey(lowerWord))
                    dictionary[lowerWord] = 1;
                else
                    dictionary[lowerWord] += 1;
            }

            return dictionary;
        }
    }
}<commit_msg>removing numbers and punctuation from text<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using LemmaSharp;

namespace ReverseDictionary.DictionaryMakers
{
    class ReverseDictionaryMaker : IDictionaryMaker
    {
        private Char[] _splitters = new Char[] { ' ', ',', '.', ';', ':', ')', '(', '\n', '!', 
            '?', '/', '\\', '%', '$', '#', '@', '*', '`', '~', '=', '+', '•', '–' };


        public IDictionary<string, int> MakeDictionary(string text, ILemmatizer lemmatizer)
        {
            // var _spl = new string(text.Where(c => !char.IsPunctuation(c)).ToArray());
            // Console.Out.Write(_spl);
            
            var dictionary = new SortedDictionary<String, int>(new ReverseStringComparer());
            var words = text.Split(_splitters, StringSplitOptions.RemoveEmptyEntries);


            foreach (var word in words)
            {
                int tmp = 0;
                if (Int32.TryParse(word, out tmp))
                {
                    continue;
                }
                
                string lowerWord = lemmatizer.Lemmatize(word.ToLower().Trim());

                if (!dictionary.ContainsKey(lowerWord))
                    dictionary[lowerWord] = 1;
                else
                    dictionary[lowerWord] += 1;
            }

            return dictionary;
        }
    }
}
{'fraction_non_alphanumeric': 0.13266637668551545, 'fraction_numerical': 0.003044802087864289, 'mean_word_length': 1.9187817258883249, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5934345', 'n_tokens_mistral': 641, 'n_tokens_neox': 590, 'n_words': 122}