예제 #1
0
        public void TestNoIndexOutOfRange()
        {
            var predictor = new TextPredictor();
            var results   = predictor.Predict(435566893, _testWords.ToList());

            Assert.IsTrue(true);
        }
예제 #2
0
        public void TestNoMatch()
        {
            var predictor = new TextPredictor();
            var results   = predictor.Predict(777, _testWords.ToList());

            Assert.IsTrue(results.Count == 0);
        }
예제 #3
0
        public void TestfooIs366()
        {
            var predictor = new TextPredictor();
            var results   = predictor.Predict(366, _testWords.ToList());

            Assert.IsTrue(results.Contains("foo"));
            Assert.IsTrue(results.Count == 1);
        }
예제 #4
0
        public void Test2633IsCodeAndBode()
        {
            var predictor = new TextPredictor();
            var results   = predictor.Predict(2633, _testWords.ToList());

            Assert.IsTrue(results.Contains("Code"));
            Assert.IsTrue(results.Contains("Bode"));
            Assert.IsTrue(results.Count == 2);
        }
예제 #5
0
        public JsonResult Predict(string text)
        {
            int code;

            if (!int.TryParse(text, out code))
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            var predictor = new TextPredictor();
            var data      = new Data();

            return(Json(predictor.Predict(code, data.GetAllWords().ToList()), JsonRequestBehavior.AllowGet));
        }