mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 10:55:04 +08:00
TextDirection.Unknown -> TextDirection.Other
Imporve NearestNeighbourWordExtractor for TextDirection.Other
This commit is contained in:
@@ -65,7 +65,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
TextDirection = TextDirection.Unknown;
|
||||
TextDirection = TextDirection.Other;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -118,7 +118,7 @@
|
||||
return TextDirection.Rotate270;
|
||||
}
|
||||
|
||||
return TextDirection.Unknown;
|
||||
return TextDirection.Other;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -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).
|
||||
|
@@ -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++)
|
||||
|
Reference in New Issue
Block a user