public MainWindow() { InitializeComponent(); parser = new NgramsParser(); parser.Load(); predictionAI = new TextPredictionAI(parser); learner = new Learner(); UpdateSuggestions(null, null); }
//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); }
public TextPredictionAI(NgramsParser parser) { this.knowledge = parser; }