コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            parser = new NgramsParser();
            parser.Load();
            predictionAI = new TextPredictionAI(parser);
            learner      = new Learner();

            UpdateSuggestions(null, null);
        }
コード例 #2
0
        //Returns a list of frequent words that start sentences
        public Dictionary <string, double> GetFirstWords(NgramsParser knowledge)
        {
            var results = new Dictionary <string, double>();
            int count   = 0;

            foreach (KeyValuePair <string, Sequence> entry in knowledge.nGramDebutPhrase.orderedSequence)
            {
                if (entry.Key.StartsWith("!") == false && entry.Key.StartsWith("?") == false && entry.Key.StartsWith(".") == false)
                {
                    int    sum   = knowledge.nGramsPerso[0].Sum();
                    int    freq  = entry.Value.Frequency;
                    double value = (double)freq / sum;
                    results.Add(FirstLetterUppercase(entry.Key), value);
                    count += 1;
                    if (count >= 100)
                    {
                        break;
                    }
                }
            }
            return(results);
        }
コード例 #3
0
 public TextPredictionAI(NgramsParser parser)
 {
     this.knowledge = parser;
 }