Ejemplo n.º 1
0
        static PredictionDictionary CreateDictionary(IEnumerable <string> sentences)
        {
            var environment = new TestPredictionEnvironment();
            var dictionary  = PredictionDictionary.Create(environment);

            foreach (var sentence in sentences)
            {
                var position = sentence.PunctuationLength(0);

                var words = new List <string>();
                while (position < sentence.Length)
                {
                    var wordLength = sentence.WordLength(position);
                    var word       = sentence.Substring(position, wordLength).ToLowerInvariant();
                    position += wordLength;
                    position += sentence.PunctuationLength(position);

                    words.Add(word);
                }

                dictionary.AddPhrase(words.ToArray());
            }

            return(dictionary);
        }
Ejemplo n.º 2
0
        public void AllTestPhrases()
        {
            var environment = new TestPredictionEnvironment();
            var dictionary  = PredictionDictionary.Create(environment);

            foreach (var sentence in TestSentences.Instance)
            {
                var position = sentence.PunctuationLength(0);

                var words = new List <string>();
                while (position < sentence.Length)
                {
                    var wordLength = sentence.WordLength(position);
                    var word       = sentence.Substring(position, wordLength).ToLowerInvariant();
                    position += wordLength;
                    position += sentence.PunctuationLength(position);

                    words.Add(word);
                }

                dictionary.AddPhrase(words.ToArray());
            }

            dictionary.Dump();
        }
Ejemplo n.º 3
0
        public void SimpleQuickBrownFox()
        {
            var environment = new TestPredictionEnvironment();
            var dictionary  = PredictionDictionary.Create(environment);

            dictionary.AddPhrase("the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog");
            dictionary.Dump();
        }
Ejemplo n.º 4
0
        public void OrderNeutrality()
        {
            var environment = new TestPredictionEnvironment();

            var dictionaryAB = PredictionDictionary.Create(environment);

            dictionaryAB.AddPhrase("A");
            dictionaryAB.AddPhrase("B");

            var dictionaryBA = PredictionDictionary.Create(environment);

            dictionaryBA.AddPhrase("B");
            dictionaryBA.AddPhrase("A");
        }
Ejemplo n.º 5
0
 public void WarAndPeaceFireUp()
 {
     var environment = new TestPredictionEnvironment(Resources.spoken);
     var predictor   = PredictionEngineFactory.Create(environment);
 }