public void TestParallelFindSmallMatrixShortStream() { var solver = new WordFinder(_matrixSmall); var result = solver.ParallelFind(_searchWordsShort); Assert.AreEqual(3, result.Count); }
//========================================================================================= void MoveRight(MovementType movementType, bool clearSelection) { if (this.Doc.Count == 0) { this.MoveDocHome(); return; } int iLine = this._Point.Line, iChar, iCol; string sLine = this.Doc[iLine].Text; if (this._Point.Char >= sLine.Length) { if (iLine >= this.Doc.Count - 1) { return; } iLine++; iChar = 0; } else { if (movementType == MovementType.Char) { iChar = this._Point.Char + 1; } else { iChar = WordFinder.GetNextWordStart(sLine, this._Point.Char); } } iCol = this.GetColumn(sLine, iChar); this.SetCaretPos(iLine, iChar, iCol, true, clearSelection); }
public void TestFindSmallMatrixShortStreamNoMatch() { var solver = new WordFinder(_matrixSmall); var result = (List <string>)solver.Find(_searchWordsNoMatch); Assert.AreEqual(0, result.Count); }
public void Find_WhenNoMatchesFound_ReturnEmptyList() { WordFinder finder = new WordFinder(_testMatrix); IEnumerable <string> result = finder.Find(new[] { "Lauda", "Ronaldo", "Hewwit", "Iverson" }); Assert.That(result, Is.Empty); }
public void UsingAMatrixOf19x19CharsTest() { var dictionary = new string[] { "mariposa", "lanza", "celtina", "lete", "juanita", "lechiguana", "yuyera", "caronte", "mosca", "cochinilla", "agavo", "marmorea", "coma" }; var src = new string[] { "AECYMCCOCHINILLACMN", "AOLUVLAUENCCÓLGLCAR", "ADERNDRIATLOAIORORM", "ANCCHALZIIRSMTGIOIR", "RMHIREJAPETRSUSOAPA", "UMICARONTEOILELTPOE", "CNGOAJLIYHMIVDAALSA", "EAUUMUTJTOCOALNMVAS", "ELAOBAIENAEPEEZCOSA", "EANEMNPSRELNROANDTO", "DTAADIRIHMTASETOSAA", "NLNIATECCAINDROOAUM", "GMYGRANAAUNTERGTULO", "RRAEEIIEIAACANALGRS", "OPATHUDAGAVOAAUDTAC", "DINCIOUAHASLUACAOBA", "TSRMICOMAMARMOREARA", "AOTDNLRLLMILETEENEA", "BESYUYERANVEEHASERL" }; var wordFinder = new WordFinder(dictionary); var result = wordFinder.Find(src); Assert.AreEqual(result.Count, dictionary.Count()); }
public Form1() { InitializeComponent(); _WordFinder = new WordFinder(); _WordFinder.WordFound += WordFinder_WordFound; _WordFinder.NoWordsFound += WordFinder_NoWordsFound; }
public IActionResult Find([FromBody] string[] value, string uid) { var filename = string.Empty; IEnumerable <string> retval = new List <string>(); if (value.Length == 0 || string.IsNullOrEmpty(uid)) { return(BadRequest()); } try { var filePath = Path.Combine(_hostingEnvironment.ContentRootPath, uid + ".txt"); if (System.IO.File.Exists(filePath)) { var list = System.IO.File.ReadAllLines(filePath); var finder = new WordFinder(list); retval = finder.Find(value); } else { return(StatusCode((int)HttpStatusCode.NoContent, "The give uid doesn't have a valid board.")); } } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } return(Ok(retval)); }
public void Throw_ArgumentNullException_Wrong_Input() { Assert.Throws <ArgumentNullException>(() => { var _board = new WordFinder(null); }); }
public void Should_Throw_If_Matrix_Exceeds_Max_Size() { Assert.Throws <MatrixSizeExceededException>(() => { WordFinder wordFinder = new WordFinder(new string[WordFinder.MAX_MATRIX_SIZE + 1]); }); }
private static void RunSearch(UnscrambleOptions options, PrefixTreeDictionary dictionary) { if (options.MinWordLength < 0) { options.MinWordLength = options.Letters.Length; } Console.WriteLine("Looking for words..."); var foundWords = WordFinder.FindUnscrambledWords( options.Letters, options.MinWordLength, dictionary ); if (foundWords.Count == 0) { Console.WriteLine("Sorry, we didn't find any words :("); } else { Console.WriteLine($"Done! Found {foundWords.Count} words:"); foreach (string word in foundWords) { Console.WriteLine(word); } } }
private void DefineVariables() { if (wf is default(WordFinder)) { wf = new WordFinder(Constants.ConnectionString); } }
public void TestRotateMatrixLarge() { var solver = new WordFinder(_matrixLarge); var rotatedMtrx = solver.RotateMatrix(_matrixLarge); Assert.AreEqual(rotatedMtrx[0], "yxyyyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxv"); Assert.AreEqual(rotatedMtrx[63], "afcpuxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf"); }
public void TestRotateMatrixSmall() { var solver = new WordFinder(_matrixSmall); var rotatedMtrx = solver.RotateMatrix(_matrixSmall); Assert.AreEqual(rotatedMtrx[0], "coldy"); Assert.AreEqual(rotatedMtrx[4], "afcpu"); }
public static void Main() { var wordstream = new string[] { "chill", "wind", "cold" }; var matrix = new string[] { "abcdc", "fgwio", "chill", "pqnsd", "uvdxy" }; var result = new WordFinder(wordstream).Find(matrix); Console.WriteLine(string.Join(",", result)); }
public ActionResult CounterResult() { string sentenceResult = Request.Form[("your-sentence")]; string keyWordResult = Request.Form[("your-keyWord")]; WordFinder newWordFinder = new WordFinder(sentenceResult, keyWordResult); return(View("PageResults", newWordFinder)); }
public void AllDirectionsSmall() { var grid = new WordGrid(3, 3, new string[] { "BAC", "EOO", "CKB" }); var finder = new WordFinder(new List <string> { "BAC", "BOB", "BEC", "COC" }, grid); Assert.AreEqual("OK", finder.Find()); }
public void Find_Should_Match_Vertical_Top_To_Bottom_Rows() { IEnumerable <string> matrix = new string[] { "oo", "nw", "et" }; WordFinder wordFinder = new WordFinder(matrix); IEnumerable <string> results = wordFinder.Find(new string[] { "one", "two" }); Assert.True(results.Count() == 1 && results.ElementAt(0) == "one"); }
public void Find_Should_Match_Horizontal_Left_To_Right_Words() { IEnumerable <string> matrix = new string[] { "one", "owt" }; WordFinder wordFinder = new WordFinder(matrix); IEnumerable <string> results = wordFinder.Find(new string[] { "one", "two" }); Assert.True(results.Count() == 1 && results.ElementAt(0) == "one"); }
public void Should_Throw_If_Matrix_Is_Empty() { IEnumerable <string> matrix = new List <string>(); Assert.Throws <EmptyMatrixException>(() => { WordFinder wordFinder = new WordFinder(matrix); }); }
public void Should_Throw_If_At_Least_One_String_Has_A_Different_Length_Than_The_First() { IEnumerable <string> matrix = new string[] { "one", "two", "three" }; Assert.Throws <DifferentLengthRowsException>(() => { WordFinder wordFinder = new WordFinder(matrix); }); }
public void Find_Should_Count_Only_Once_A_Word_Found_Multiple_Times() { IEnumerable <string> matrix = new string[] { "one", "one", "two", "six" }; WordFinder wordFinder = new WordFinder(matrix); IEnumerable <string> results = _wordFinder.Find(new string[] { "one", "two", "two", "six", "six", "six" }); Assert.True(results.ElementAt(2) == "one"); }
public void Find_WhenMatchesFound_ReturnTopTenListOfMatchesOrderedByNumberOfMatches() { WordFinder finder = new WordFinder(_testMatrix); IEnumerable <string> result = finder.Find(new[] { "Messi", "Jordan", "Federer", "Ginobili", "Iverson", "Bird", "Ronaldo", "Ewing", "Stockton", "Maradona", "Cruyff", "Kobe", "James" }); Assert.That(result, Is.Unique); Assert.That(result, Is.EquivalentTo(new[] { "Messi", "Jordan", "Federer", "Bird", "Ewing", "Stockton", "Maradona", "Cruyff", "Kobe", "Ginobili" })); }
public void FindAllWords() { var wordFinder = new WordFinder(GetMatrix()); var wordSteam = GetWordStream(); var topWord = wordFinder.Find(wordSteam); var expectedResult = GetTop10Words(); Assert.Equal(expectedResult, topWord); }
public void VerticalWords() { var grid = new WordGrid(4, 4, new string[] { "GTRI", "LMAL", "UAGO", "ECML" }); var finder = new WordFinder(new List <string> { "GLUE", "RAG", "LOL", "MAC" }, grid); Assert.AreEqual("TIM", finder.Find()); }
public void UsingTheDictionaryAndSourceOfTheExerciseTest() { var dictionary = new string[] { "chill", "wind", "snow", "cold" }; var src = new string[] { "abcdc", "fgwio", "chill", "pqnsd", "uvdxy" }; var wordFinder = new WordFinder(dictionary); var result = wordFinder.Find(src); Assert.AreEqual(result.Count, 3); }
public ActionResult <IEnumerable <string> > GetMatrixQu(QuMatrixModel model) { if (!model.Valid()) { return(BadRequest()); } IWordFinder myMatrix = new WordFinder(model.matrix); return(myMatrix.Find(model.words).ToArray()); }
public void FindAllWordsReturnEmptyList() { var wordFinder = new WordFinder(GetMatrix()); var wordSteam = GetWordsStreamTwo(); var topWord = wordFinder.Find(wordSteam); var expectedResult = new List <string>(); Assert.Equal(expectedResult, topWord); }
public void MyFirstTheory(GameBoard board, int minWordLength, List <string> dictionary, List <string> expected) { Dictionary wordDictionary = new Dictionary(dictionary, minWordLength); List <string> result = WordFinder.FindWords(board, wordDictionary).ToList(); result.Sort(); expected.Sort(); Assert.Equal(result, expected); }
static void Main(string[] args) { IConsoleWrapper consoleWrapper = new ConsoleWrapper(); IFileOperations fileOperations = new FileOperations(); IWordFinder wordFinder = new WordFinder(); ISearchOrientationManager searchOrientationManager = new SearchOrientationManager(); var wordSearchProgram = new WordSearchProgram(consoleWrapper, fileOperations, wordFinder, searchOrientationManager); wordSearchProgram.ProgramLoop("puzzles"); }
static void Main() { var dictionary = new string[] { "chill", "wind", "snow", "cold" }; var src = new string[] { "abcdc", "fgwio", "chill", "pqnsd", "uvdxy" }; var result = new WordFinder(dictionary).Find(src); foreach (string show in result) { Console.WriteLine(show); } }
private void Run() { Stopwatch stopwatch = new Stopwatch(); Console.Write("Constructing search tree..."); stopwatch.Start(); var wordFinder = new WordFinder(@"C:\Users\Daniel\Dropbox\Programming\TernarySearchTree\swedish-word-list-bigger.txt", Encoding.UTF8, Language.Swedish); //var wordFinder = new WordFinder(@"C:\Users\danlid\Dropbox\Programming\TernarySearchTree\english-word-list.txt", Encoding.UTF8, Language.English); //var wordFinder = new WordFinder(@"C:\Users\danlid\Dropbox\Programming\TernarySearchTree\swedish-english.txt", Encoding.UTF8, Language.Swedish); stopwatch.Stop(); Console.WriteLine("{0} ms", stopwatch.ElapsedMilliseconds); Console.WriteLine("Enter word to search for. A single 'q' exits."); var lineEditor = new LineEditor("input"); string input = lineEditor.Edit(": ", string.Empty); while (input != "q") { do { if (string.IsNullOrWhiteSpace(input)) break; stopwatch.Restart(); var matches = wordFinder.Matches(input, 2, 100); stopwatch.Stop(); if (matches.Count > 0) { Console.WriteLine("Found {0} words matching '{1}':", matches.Count, input); matches.ForEach(m => Console.WriteLine("{0,-7}: {1}", m.Type, m.Value)); } else { Console.WriteLine("Did not find any words matching '{0}'", input); } Console.WriteLine("Search completed in {0:F2} ms. Visited {1} nodes.", 1000.0 * stopwatch.ElapsedTicks / Stopwatch.Frequency, wordFinder.Nodes); } while (false); input = lineEditor.Edit(": ", string.Empty); } }
private static void LoadDictionary() { Task.Factory.StartNew(() => { Log.Info("Loading dictionary"); object dir = AppDomain.CurrentDomain.GetData("DataDirectory"); string filename = Path.Combine(dir.ToString(), "words.txt"); string language = Path.Combine(dir.ToString(), "nian.txt"); wordFinder = new WordFinder(filename, Encoding.UTF8, Language.Swedish); nianFinder = new NianFinder(language, Encoding.UTF8, new CultureInfo("sv-SE")); LoadingEvent.Set(); Log.Info("Dictionary loaded"); }); }