public void Analyze(TextReader reader)
        {
            var builder = new StringBuilder('^');

            while (reader.Peek() != -1)
            {
                var c = (char)reader.Read();
                if (!InCharSet(c))
                {
                    if (builder.Length >= 2)
                    {
                        builder.Append('$');
                        Statistic.Add("*", builder.Length);
                        foreach (var str in SubStringSelector(builder.ToString()))
                        {
                            Statistic.Add(str);
                        }
                    }

                    builder.Clear();
                    builder.Append('^');
                }
                else
                {
                    builder.Append(c);
                }
            }
        }
 public void MergeFrom(TextStatistician another)
 {
     foreach (var pair in another.Statistic.KeyFrequency)
     {
         Statistic.Add(pair.Key, pair.Value);
     }
 }
Exemplo n.º 3
0
        public override void FromStatistician(TextStatistician stat)
        {
            base.FromStatistician(stat);
            var stat0 = new Statistic <char>();

            foreach (var pair in stat.StringFrequency)
            {
                if (pair.Key.Length != 1)
                {
                    continue;
                }
                char c    = pair.Key[0];
                int  freq = pair.Value;
                stat0.Add(c, freq);
            }
            dtb = stat0.ToDistribute();
        }