public void Rejects_Short_Script_Short_Label() { string scriptLabel = "C"; string realLabel = "D"; Assert.IsFalse(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Can_Match_1() { string scriptLabel = "Invoice"; string realLabel = "Invoice"; Assert.IsTrue(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Can_Match_Partial_Label_2() { string scriptLabel = "Customer Number"; string realLabel = "stomer Number"; Assert.IsTrue(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Rejects_2() { string scriptLabel = "To"; string realLabel = "From"; Assert.IsFalse(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Rejects_3() { string scriptLabel = "Banana Factory"; string realLabel = "Apple Factory"; Assert.IsFalse(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Can_Match_3() { string scriptLabel = "Banana Factory"; string realLabel = "Banana Factory"; Assert.IsTrue(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Rejects_1() { string scriptLabel = "Invoice"; string realLabel = "Address"; Assert.IsFalse(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Rejects_Different() { string scriptLabel = "Banana"; string realLabel = "Apple"; Assert.IsFalse(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Rejects_Short() { string scriptLabel = "BA"; string realLabel = "AB"; Assert.IsFalse(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
public void Matches_Short() { string scriptLabel = "AB"; string realLabel = "AB"; Assert.IsTrue(FuzzyTextComparer.FuzzyEquals(scriptLabel, realLabel)); }
private AnalyzedTableColumns[] GetAnalyzedTableColumns(Page page, TableColumn[] tableColumns) { // Experimentation shows that trimming the Y index more can help normalise table headers var tableAnalysisPage = new PageTrimmer().TrimPage(page, 20, 20, true); // This finds the row in the page that can best match the TextType and label definitions along with the indices where they match. var bestMatch = tableColumns .SelectMany((tableColumn, TableIndex) => tableAnalysisPage .GetIndexWhere(t => tableColumn.LabelParameters.Any(v => FuzzyTextComparer.FuzzyEquals(v, t.Value)) ) .Select(Index => new { TableIndex, Index, tableColumn.TextType })) .GroupBy(x => x.Index.Coordinate.Y) .OrderByDescending(x => x.Count()) .FirstOrDefault(); if (bestMatch == null) { return null; } var columns = bestMatch .GroupBy(x => x.TableIndex) .Select(x => x.First()) .Select(x => new AnalyzedTableColumns() { Rows = GetTableColumn(page, (PageIndex)x.Index.Clone(), x.TextType), ColumnIndex = x.TableIndex }) .ToArray(); return columns; }
private bool ValidateTextTypeMatch(PageUnit pageUnit, string textType, string[] matchContent) => pageUnit != null && pageUnit?.TextType == textType && (matchContent?.Any(x => FuzzyTextComparer.FuzzyEquals(x, pageUnit.Value)) ?? true);