Example #1
0
 /// <summary>
 /// Pass fully match words from word sequence using word extractor settings provided.
 /// </summary>
 /// <param name="wordPartSequence">Sequence of full and partial words</param>
 /// <param name="wordExtractorSettings">Word extractor settings. Defaults settings inlude Full word length = 6, Ignore casing is off</param>
 /// <returns>Fully matched words from word part sequence</returns>
 public static List<string> Compose(string wordPartSequence, WordExtractorSettings wordExtractorSettings)
 {
     List<string> wordList;
     using (IWordComposer wordComposer = new WordComposer(new WordExtractor(wordExtractorSettings)))
     {
         wordList = wordComposer.Compose(wordPartSequence);
     }
     return wordList;
 }
        public void CanComposeWordsFromMessyCasingNonAlphaWordPartSequenceIgnoreCase()
        {
            const string wordPartSequence = "tty /.,<>?Minute snotty, min people ple min. -  forrest  befoul ute sno";

            IWordExtractor wordExtractor = new WordExtractor(new WordExtractorSettings
                {
                    IgnoreCase = true
                });

            WordComposer wordComposer = new WordComposer(wordExtractor);

            List<string> composedWords = wordComposer.Compose(wordPartSequence);

            Assert.IsNotNull(composedWords);
            Assert.AreEqual(composedWords.Count, 2);

            foreach (var composedWord in composedWords)
            {
                Assert.AreEqual(composedWord.Length, wordExtractor.WordExtractorSettings.WordLength);
            }
        }
        public void CanComposeWordsFromOriginalWordPartSequence()
        {
            WordExtractorSettings wordExtractorSettings = new WordExtractorSettings {
                WordLength = 6,
                IgnoreCase = true
            };

            const string wordPartSequence = "al, albums, aver, bar, barely, be, befoul, bums, by, cat, con, convex, ely, foul, here, hereby, jig, jigsaw, or, saw, tail, tailor, vex, we, weaver";

            IWordExtractor wordExtractor = new WordExtractor(wordExtractorSettings);
            WordComposer wordComposer = new WordComposer(wordExtractor);

            List<string> composedWords = wordComposer.Compose(wordPartSequence);

            Assert.IsNotNull(composedWords);
            Assert.AreEqual(composedWords.Count, 8);

            foreach (var composedWord in composedWords)
            {
                Assert.AreEqual(composedWord.Length, wordExtractor.WordExtractorSettings.WordLength);
            }
        }