Esempio n. 1
0
 public static void TestMillionTimesWithSingleWord(string word, WordAnalyzer analyzer)
 {
     var sw = Stopwatch.StartNew();
     for (var i = 0; i < Million; i++)
     {
         analyzer.Analyze(word);
     }
     sw.Stop();
     Console.WriteLine("Time taken for the word \"{0} \" is {1}ms", word, sw.Elapsed.TotalMilliseconds);
     GC.Collect();
 }
Esempio n. 2
0
 private static void Process(IEnumerable<string> tokens, WordAnalyzer analyzer)
 {
     foreach (string token in tokens)
     {
         IList<Word> sol;
         if (!Cache.TryAnalyze(token, out sol))
         {
             analyzer.Analyze(token);
         }
     }
 }
Esempio n. 3
0
 public static void Analyze(WordAnalyzer analyzer, IEnumerable<string> words)
 {
     foreach (string test in words)
     {
         IList<Word> solutions = analyzer.Analyze(test);
         Console.WriteLine("\n{0} için {1} çözüm bulundu:", test, solutions.Count);
         foreach (Word solution in solutions)
         {
             Console.WriteLine("\t{0}\n", solution);
         }
     }
 }
Esempio n. 4
0
 public static void Analyze(WordAnalyzer analyzer, string inputFilename, string undefinedOutputFilename)
 {
     IList<string> undefined = new List<string>();
     string[] lines = File.ReadAllLines(inputFilename, Encoding.UTF8);
     foreach (string line in lines)
     {
         IList<Word> solutions = analyzer.Analyze(line);
         if (!solutions.Any())
         {
             undefined.Add(line);
         }
     }
     File.WriteAllLines(undefinedOutputFilename, undefined);
 }
Esempio n. 5
0
 public static void AnalyzeTokensToFile(WordAnalyzer analyzer, IEnumerable<string> words,
     string undefinedOutputFilename)
 {
     IList<string> lines = new List<string>();
     foreach (string word in words)
     {
         string line = word;
         IList<Word> solutions = analyzer.Analyze(word);
         foreach (Word solution in solutions)
         {
             line += "\t" + solution;
         }
         lines.Add(line);
     }
     File.WriteAllLines(undefinedOutputFilename, lines);
 }
Esempio n. 6
0
 public static String[] ReplaceRoots(string root, string[] words)
 {
     Language turkish = Language.Turkish;
     var analyzer = new WordAnalyzer(turkish);
     var replacedWords = new List<string>();
     foreach (string word in words)
     {
         IEnumerable<Word> solutions = analyzer.Analyze(word, true, true);
         foreach (Word solution in solutions)
         {
             string output = solution.GetSurface();
             solution.Root = turkish.GetRootsHavingSurface(root).First();
             output += "\t" + solution.GetSurface();
             replacedWords.Add(output);
         }
     }
     return replacedWords.ToArray();
 }