TextDirection.Unknown -> TextDirection.Other

Imporve NearestNeighbourWordExtractor for TextDirection.Other
This commit is contained in:
BobLd
2020-01-17 11:33:59 +00:00
committed by Eliot Jones
parent 9bcafdaa98
commit a326d7e9d9
5 changed files with 11 additions and 11 deletions

View File

@@ -65,7 +65,7 @@
}
else
{
TextDirection = TextDirection.Unknown;
TextDirection = TextDirection.Other;
}
}

View File

@@ -63,9 +63,9 @@
wordsH.AddRange(words90);
List<Word> wordsU = GetWords(
letters.Where(l => l.TextDirection == TextDirection.Unknown),
(l1, l2) => Math.Max(l1.GlyphRectangle.Width, l2.GlyphRectangle.Width) * 0.2,
Distances.Manhattan, MaxDegreeOfParallelism)
letters.Where(l => l.TextDirection == TextDirection.Other),
(l1, l2) => Math.Max(Math.Abs(l1.GlyphRectangle.Width), Math.Abs(l2.GlyphRectangle.Width)) * 0.2,
Distances.Euclidean, MaxDegreeOfParallelism)
.OrderByDescending(x => x.BoundingBox.Bottom)
.ThenBy(x => x.BoundingBox.Left).ToList();
wordsH.AddRange(wordsU);

View File

@@ -118,7 +118,7 @@
return TextDirection.Rotate270;
}
return TextDirection.Unknown;
return TextDirection.Other;
}
/// <summary>

View File

@@ -6,9 +6,9 @@
public enum TextDirection
{
/// <summary>
/// Text direction not known.
/// Other text direction.
/// </summary>
Unknown,
Other,
/// <summary>
/// Usual text direction (Left to Right).

View File

@@ -57,7 +57,7 @@
var tempTextDirection = letters[0].TextDirection;
if (letters.Any(l => l.TextDirection != tempTextDirection))
{
tempTextDirection = TextDirection.Unknown;
tempTextDirection = TextDirection.Other;
}
Tuple<string, PdfRectangle> data;
@@ -80,9 +80,9 @@
data = GetBoundingBox270(letters);
break;
case TextDirection.Unknown:
case TextDirection.Other:
default:
data = GetBoundingBoxUnknown(letters);
data = GetBoundingBoxOther(letters);
break;
}
@@ -256,7 +256,7 @@
new PdfPoint(maxX, maxY)));
}
private Tuple<string, PdfRectangle> GetBoundingBoxUnknown(IReadOnlyList<Letter> letters)
private Tuple<string, PdfRectangle> GetBoundingBoxOther(IReadOnlyList<Letter> letters)
{
var builder = new StringBuilder();
for (var i = 0; i < letters.Count; i++)