示例#1
0
        private static IDictionary <string, string> CreateStemMapFile()
        {
            var words = File.ReadAllLines(WordListPath, Encoding.UTF8);
            var map   = Stems.Stem(words);
            var list  = map.Select(x => x.Key + "\t" + x.Value);

            File.WriteAllLines(StemMapPath, list, Encoding.UTF8);
            return(map);
        }
示例#2
0
        private static void Process(
            bool addNewWords        = false,
            bool createStemMapFile  = false,
            bool generateDictionary = false,
            bool runTests           = false)
        {
            var sw = new Stopwatch();

            sw.Start();

            if (addNewWords)
            {
                if (AddNewWordsToWordList())
                {
                    Console.WriteLine(@"New Word List Constructed: " + sw.Elapsed);
                }
                else
                {
                    Console.WriteLine(@"undefined words in word list. Aborting...");
                    return;
                }
            }

            //Analyze and stem all the words from start or just use the created stems
            var wordStemMap = createStemMapFile ? CreateStemMapFile() : Stems.FromDictionary(StemMapPath);

            Console.WriteLine(@"Stem Map Constructed: " + sw.Elapsed);

            if (generateDictionary)
            {
                DictionaryGenerator.Generate(wordStemMap, DictDirectoryPath + "tr-TR", langCode: "tr-TR");
                Console.WriteLine(@"Dictionary Generated: " + sw.Elapsed);
            }

            if (runTests)
            {
                HunspellHelper.RunTests();
            }
        }
示例#3
0
        private static void GenerateTestDictionary()
        {
            var map = Stems.FromDictionary(DataDir + "stemMapTest.txt");

            DictionaryGenerator.Generate(map, DictDirectoryPath + @"test", "test");
        }