static void Main(string[] args)
        {
            WordPrediction.Initialize();
            LinkedList <string> words = new LinkedList <string>();

            //if you like
            words.AddLast("for");
            words.AddLast("he");
            words.AddLast("was");
            foreach (var word in words)
            {
                Console.Write(word + " ");
            }
            while (true)
            {
                //var line = Console.ReadLine();
                var predictions = WordPrediction.Predict(words.Aggregate((a, b) => a + " " + b));
                predictions.OrderByDescending(a => a.Item2);
                words.RemoveFirst();
                var prediction = predictions.FirstOrDefault();
                if (prediction == null)
                {
                    break;
                }
                var word = predictions.FirstOrDefault().Item1;
                words.AddLast(word);
                Console.Write(" " + word);
                Thread.Sleep(250);
            }
        }
 public void Post([FromBody]string text)
 {
     string txt = System.Web.HttpContext.Current.Request.Form["text"];
     using (var stream = GenerateStreamFromString(txt))
     {
         WordPrediction.Teach(stream);
     }
 }
Beispiel #3
0
        public ActionResult GetSnippetResponses(string snippet)
        {
            var Collection = new Dictionary <string, List <string> >();

            //From SQLite DB
            List <string> DictionaryMatch = SQLiteDb.GetDictionaryMatches(snippet);

            Collection.Add("CustomDict", DictionaryMatch);

            //From word prediction website
            List <string> WordPredictMatches = WordPrediction.GetWordPredictMatches(snippet);

            Collection.Add("PreDict", WordPredictMatches);

            var jsonSerialiser = new JsonSerializer();
            var json           = JsonConvert.SerializeObject(Collection, Formatting.Indented);

            return(Ok(json));
        }
 // GET api/wordprediction
 public IEnumerable<string> Get(string text)
 {
     text = System.Web.HttpContext.Current.Server.UrlDecode(text);
     return WordPrediction.Predict(text).OrderByDescending(a => a.Item2).Take(3).Select(a => a.Item1).ToList();
 }