public List <KeyValuePair <NGram, int> > SortNGram(NGramDictionary dict) { List <KeyValuePair <NGram, int> > sortedList = dict.ToList(); sortedList.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value)); return(sortedList); }
public FileOperations(string path) { SOURCE_DIR = path; miliseconds = new long[3]; unigram = new NGramDictionary(new NGramExtractor(Unigram)); bigram = new NGramDictionary(new NGramExtractor(Bigram)); trigram = new NGramDictionary(new NGramExtractor(Trigram)); FillDictionaries(); }
private void ReadFiles(NGramDictionary dict) { var txtFiles = Directory.EnumerateFiles(SOURCE_DIR, "*.txt"); foreach (var item in txtFiles) { string fileContext = File.ReadAllText(item, Encoding.GetEncoding("ISO-8859-9")); fileContext = CleanText(fileContext); fileContext = fileContext.ToLower(new CultureInfo("tr-TR", false)); dict.AddSequence(fileContext.Split(null).ToList()); } }