/// ------------------------------------------------------------------------------------ private WordListCache GetCIEResults(CIEOptions options) { var sortOptions = new SortOptions(true, _prj) { AdvancedEnabled = true }; if (options.Type != CIEOptions.IdenticalType.After) { sortOptions.AdvSortOrder = new[] { 0, 1, 2 } } ; else { sortOptions.AdvSortOrder = new[] { 2, 1, 0 }; sortOptions.AdvRlOptions[2] = true; } _cache.Sort(sortOptions); sortOptions = new SortOptions(true, _prj) { AdvancedEnabled = true }; return(new CIEBuilder(_cache, sortOptions, options).FindMinimalPairs()); }
public void SimpleMatchOnEnvironmentAfterTest() { AddWords("pnm mib gid bab wad tob kod mnp pig"); var options = new CIEOptions(); options.Type = CIEOptions.IdenticalType.After; options.SearchQuery.IgnoreDiacritics = false; options.SearchQuery.IgnoredCharacters = null; var retCache = GetCIEResults(options); Assert.AreEqual(6, retCache.Count); Assert.AreEqual(retCache[0].CIEGroupId, retCache[1].CIEGroupId); Assert.AreEqual(retCache[1].CIEGroupId, retCache[2].CIEGroupId); Assert.AreNotEqual(retCache[2].CIEGroupId, retCache[3].CIEGroupId); Assert.AreEqual(retCache[3].CIEGroupId, retCache[4].CIEGroupId); Assert.AreEqual(retCache[4].CIEGroupId, retCache[5].CIEGroupId); Assert.AreEqual("mib", retCache[0].PhoneticValue); Assert.AreEqual("tob", retCache[1].PhoneticValue); Assert.AreEqual("bab", retCache[2].PhoneticValue); Assert.AreEqual("gid", retCache[3].PhoneticValue); Assert.AreEqual("kod", retCache[4].PhoneticValue); Assert.AreEqual("wad", retCache[5].PhoneticValue); }
public void SimpleMatchOnEnvironmentBeforeTest() { AddWords("pnm bim dig bab daw bot dok mnp pig"); var options = new CIEOptions(); options.Type = CIEOptions.IdenticalType.Before; options.SearchQuery.IgnoreDiacritics = false; options.SearchQuery.IgnoredCharacters = null; var retCache = GetCIEResults(options); Assert.AreEqual(6, retCache.Count); Assert.AreEqual(retCache[0].CIEGroupId, retCache[1].CIEGroupId); Assert.AreEqual(retCache[1].CIEGroupId, retCache[2].CIEGroupId); Assert.AreNotEqual(retCache[2].CIEGroupId, retCache[3].CIEGroupId); Assert.AreEqual(retCache[3].CIEGroupId, retCache[4].CIEGroupId); Assert.AreEqual(retCache[4].CIEGroupId, retCache[5].CIEGroupId); Assert.AreEqual("bim", retCache[0].PhoneticValue); Assert.AreEqual("bot", retCache[1].PhoneticValue); Assert.AreEqual("bab", retCache[2].PhoneticValue); Assert.AreEqual("dig", retCache[3].PhoneticValue); Assert.AreEqual("dok", retCache[4].PhoneticValue); Assert.AreEqual("daw", retCache[5].PhoneticValue); }
public void SimpleMatchOnBothEnvironmentsTest() { AddWords("pim bit dig bat dag bot dog mop"); var options = new CIEOptions(); options.Type = CIEOptions.IdenticalType.Both; options.SearchQuery.IgnoreDiacritics = false; options.SearchQuery.IgnoredCharacters = null; var retCache = GetCIEResults(options); Assert.AreEqual(6, retCache.Count); Assert.AreEqual(retCache[0].CIEGroupId, retCache[1].CIEGroupId); Assert.AreEqual(retCache[1].CIEGroupId, retCache[2].CIEGroupId); Assert.AreNotEqual(retCache[2].CIEGroupId, retCache[3].CIEGroupId); Assert.AreEqual(retCache[3].CIEGroupId, retCache[4].CIEGroupId); Assert.AreEqual(retCache[4].CIEGroupId, retCache[5].CIEGroupId); Assert.AreEqual("bit", retCache[0].PhoneticValue); Assert.AreEqual("bot", retCache[1].PhoneticValue); Assert.AreEqual("bat", retCache[2].PhoneticValue); Assert.AreEqual("dig", retCache[3].PhoneticValue); Assert.AreEqual("dog", retCache[4].PhoneticValue); Assert.AreEqual("dag", retCache[5].PhoneticValue); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Refreshes the search results by performing the search again and rebuilding the /// grid contents. /// </summary> /// <param name="cieType"></param> /// ------------------------------------------------------------------------------------ public void RefreshResults(CIEOptions.CIEType cieType) { int savCurrRowIndex = 0; int savCurrColIndex = 0; int savFirstRowIndex = 0; SortOptions savSortOptions = null; CIEOptions savCIEOptions = null; if (_errorControl != null) { Controls.Remove(_errorControl); _errorControl.Dispose(); _errorControl = null; } if (_grid != null) { // Save the index of the row and column that's current, the // index of the first visible row, and the current sort options. savCurrRowIndex = (_grid.CurrentRow != null ? _grid.CurrentRow.Index : 0); savCurrColIndex = (_grid.CurrentCell != null ? _grid.CurrentCell.ColumnIndex : 0); savFirstRowIndex = _grid.FirstDisplayedScrollingRowIndex; savSortOptions = _grid.SortOptions; savCIEOptions = _grid.CIEOptions; if (savCIEOptions != null) { savCIEOptions.CieType = cieType; } } App.InitializeProgressBar(App.kstidQuerySearchingMsg); var resultCache = App.Search(_query); if (resultCache != null) { resultCache.SearchQuery = _query; Initialize(resultCache); } // Restore the current row to what it was before // rebuilding. Then make sure the row is visible. if (_grid != null) { _grid.PostDataSourceModifiedRestore(savCurrRowIndex, savCurrColIndex, savFirstRowIndex, savSortOptions, savCIEOptions); } App.UninitializeProgressBar(); }
public void MatchOnEnvironmentBeforeWithIgnoredDiacriticsTest2() { AddWords("p\u02B0it pbit pat p\u02B0ot"); var options = new CIEOptions(); options.Type = CIEOptions.IdenticalType.Before; options.SearchQuery.IgnoreDiacritics = true; options.SearchQuery.IgnoredCharacters = null; var retCache = GetCIEResults(options); Assert.AreEqual(3, retCache.Count); Assert.AreEqual(retCache[0].CIEGroupId, retCache[1].CIEGroupId); Assert.AreEqual(retCache[1].CIEGroupId, retCache[2].CIEGroupId); Assert.AreEqual("p\u02B0it", retCache[0].PhoneticValue); Assert.AreEqual("p\u02B0ot", retCache[1].PhoneticValue); Assert.AreEqual("pat", retCache[2].PhoneticValue); }
public void MatchOnEnvironmentAfterIgnoreingDiacriticsTest() { AddWords("tib\u0324 gab g\u02B0id nod"); var options = new CIEOptions(); options.Type = CIEOptions.IdenticalType.After; options.SearchQuery.IgnoreDiacritics = true; options.SearchQuery.IgnoredCharacters = null; var retCache = GetCIEResults(options); Assert.AreEqual(4, retCache.Count); Assert.AreEqual(retCache[0].CIEGroupId, retCache[1].CIEGroupId); Assert.AreEqual(retCache[2].CIEGroupId, retCache[3].CIEGroupId); Assert.AreNotEqual(retCache[1].CIEGroupId, retCache[2].CIEGroupId); Assert.AreEqual("tib\u0324", retCache[0].PhoneticValue); Assert.AreEqual("gab", retCache[1].PhoneticValue); Assert.AreEqual("g\u02B0id", retCache[2].PhoneticValue); Assert.AreEqual("nod", retCache[3].PhoneticValue); }
public void MatchOnEnvironmentBeforeIgnoreingDiacriticsTest() { AddWords("b\u0324it bag dig\u02B0 don"); var options = new CIEOptions(); options.Type = CIEOptions.IdenticalType.Before; options.SearchQuery.IgnoreDiacritics = true; options.SearchQuery.IgnoredCharacters = null; var retCache = GetCIEResults(options); Assert.AreEqual(4, retCache.Count); Assert.AreEqual(retCache[0].CIEGroupId, retCache[1].CIEGroupId); Assert.AreEqual(retCache[2].CIEGroupId, retCache[3].CIEGroupId); Assert.AreNotEqual(retCache[1].CIEGroupId, retCache[2].CIEGroupId); Assert.AreEqual("b\u0324it", retCache[0].PhoneticValue); Assert.AreEqual("bag", retCache[1].PhoneticValue); Assert.AreEqual("dig\u02B0", retCache[2].PhoneticValue); Assert.AreEqual("don", retCache[3].PhoneticValue); }
public void MatchOnBothEnvironmentsWithIngoreItemsTest() { AddWords("b\u0324it bat dig\u02B0 dog"); var options = new CIEOptions(); options.Type = CIEOptions.IdenticalType.Both; options.SearchQuery.IgnoreDiacritics = false; options.SearchQuery.IgnoredCharacters = "\u0324,\u02B0"; var retCache = GetCIEResults(options); Assert.AreEqual(4, retCache.Count); Assert.AreEqual(retCache[0].CIEGroupId, retCache[1].CIEGroupId); Assert.AreEqual(retCache[2].CIEGroupId, retCache[3].CIEGroupId); Assert.AreNotEqual(retCache[1].CIEGroupId, retCache[2].CIEGroupId); Assert.AreEqual("b\u0324it", retCache[0].PhoneticValue); Assert.AreEqual("bat", retCache[1].PhoneticValue); Assert.AreEqual("dig\u02B0", retCache[2].PhoneticValue); Assert.AreEqual("dog", retCache[3].PhoneticValue); }