Beispiel #1
0
 private static void conditional_frequency_basic_test()
 {
     var text1 = new List<string>(){"a", "b"};
       var cf = new ConditionalFrequencies();
       cf.Add(text1);
       cf.Add(text1);
       foreach (var term in cf.Conditions())
       {
     Console.WriteLine(term);
       }
       foreach (var term in cf.Values())
       {
     foreach (var t in term.Terms())
       Console.WriteLine("{0} => {1}", t, term.Get(t));
       }
 }
Beispiel #2
0
        private static void inaugural_ngram_conditional_frequencies()
        {
            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Data\inaugural");
              var inaugural = new TextCorpusReader(path);
              var cf = new ConditionalFrequencies();

              foreach (var term in inaugural.words().Where((x) => x != ", ").NGram(3))
              {
            cf.Add(term);
              }
              foreach (var term in cf.Generate())
              {
            if (term.Value.Count() > 1)
            {
              Console.WriteLine(term.Key);
              foreach (var evt in term.Value.Generate())
              {
            Console.WriteLine("\t{0} -> {1}", evt.Key, evt.Value);
              }
            }
              }
        }