本文整理汇总了C#中Page.GetIterator方法的典型用法代码示例。如果您正苦于以下问题:C# Page.GetIterator方法的具体用法?C# Page.GetIterator怎么用?C# Page.GetIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page.GetIterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteResultsToString
private string WriteResultsToString(Page page)
{
var output = new StringBuilder();
using (var iter = page.GetIterator()) {
iter.Begin();
do {
do {
do {
do {
do {
if (iter.IsAtBeginningOf(PageIteratorLevel.Block)) {
var confidence = iter.GetConfidence(PageIteratorLevel.Block) / 100;
Rect bounds;
if (iter.TryGetBoundingBox(PageIteratorLevel.Block, out bounds)) {
output.AppendFormat("<block confidence=\"{0:P}\" bounds=\"{1}, {2}, {3}, {4}\">", confidence, bounds.X1, bounds.Y1, bounds.X2, bounds.Y2);
} else {
output.AppendFormat("<block confidence=\"{0:P}\">", confidence);
}
output.AppendLine();
}
if (iter.IsAtBeginningOf(PageIteratorLevel.Para)) {
var confidence = iter.GetConfidence(PageIteratorLevel.Para) / 100;
Rect bounds;
if (iter.TryGetBoundingBox(PageIteratorLevel.Para, out bounds)) {
output.AppendFormat("<para confidence=\"{0:P}\" bounds=\"{1}, {2}, {3}, {4}\">", confidence, bounds.X1, bounds.Y1, bounds.X2, bounds.Y2);
} else {
output.AppendFormat("<para confidence=\"{0:P}\">", confidence);
}
output.AppendLine();
}
if (iter.IsAtBeginningOf(PageIteratorLevel.TextLine)) {
var confidence = iter.GetConfidence(PageIteratorLevel.TextLine) / 100;
Rect bounds;
if (iter.TryGetBoundingBox(PageIteratorLevel.TextLine, out bounds)) {
output.AppendFormat("<line confidence=\"{0:P}\" bounds=\"{1}, {2}, {3}, {4}\">", confidence, bounds.X1, bounds.Y1, bounds.X2, bounds.Y2);
} else {
output.AppendFormat("<line confidence=\"{0:P}\">", confidence);
}
}
if (iter.IsAtBeginningOf(PageIteratorLevel.Word)) {
var confidence = iter.GetConfidence(PageIteratorLevel.Word) / 100;
Rect bounds;
if (iter.TryGetBoundingBox(PageIteratorLevel.Word, out bounds)) {
output.AppendFormat("<word confidence=\"{0:P}\" bounds=\"{1}, {2}, {3}, {4}\">", confidence, bounds.X1, bounds.Y1, bounds.X2, bounds.Y2);
} else {
output.AppendFormat("<word confidence=\"{0:P}\">", confidence);
}
}
output.Append(iter.GetText(PageIteratorLevel.Symbol));
if (iter.IsAtFinalOf(PageIteratorLevel.Word, PageIteratorLevel.Symbol)) {
output.Append("</word>");
}
} while (iter.Next(PageIteratorLevel.Word, PageIteratorLevel.Symbol));
if (iter.IsAtFinalOf(PageIteratorLevel.TextLine, PageIteratorLevel.Word)) {
output.AppendLine("</line>");
}
} while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word));
if (iter.IsAtFinalOf(PageIteratorLevel.Para, PageIteratorLevel.TextLine)) {
output.AppendLine("</para>");
}
} while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine));
} while (iter.Next(PageIteratorLevel.Block, PageIteratorLevel.Para));
output.AppendLine("</block>");
} while (iter.Next(PageIteratorLevel.Block));
}
return output.ToString();
}
示例2: WriteResultsToString
private string WriteResultsToString(Page page, bool outputChoices)
{
var output = new StringBuilder();
using (var iter = page.GetIterator()) {
iter.Begin();
do {
do {
do {
do {
do {
if (iter.IsAtBeginningOf(PageIteratorLevel.Block)) {
var confidence = iter.GetConfidence(PageIteratorLevel.Block) / 100;
Rect bounds;
if (iter.TryGetBoundingBox(PageIteratorLevel.Block, out bounds)) {
output.AppendFormat(CultureInfo.InvariantCulture, "<block confidence=\"{0:P}\" bounds=\"{1}, {2}, {3}, {4}\">", confidence, bounds.X1, bounds.Y1, bounds.X2, bounds.Y2);
} else {
output.AppendFormat(CultureInfo.InvariantCulture, "<block confidence=\"{0:P}\">", confidence);
}
output.AppendLine();
}
if (iter.IsAtBeginningOf(PageIteratorLevel.Para)) {
var confidence = iter.GetConfidence(PageIteratorLevel.Para) / 100;
Rect bounds;
if (iter.TryGetBoundingBox(PageIteratorLevel.Para, out bounds)) {
output.AppendFormat(CultureInfo.InvariantCulture, "<para confidence=\"{0:P}\" bounds=\"{1}, {2}, {3}, {4}\">", confidence, bounds.X1, bounds.Y1, bounds.X2, bounds.Y2);
} else {
output.AppendFormat(CultureInfo.InvariantCulture, "<para confidence=\"{0:P}\">", confidence);
}
output.AppendLine();
}
if (iter.IsAtBeginningOf(PageIteratorLevel.TextLine)) {
var confidence = iter.GetConfidence(PageIteratorLevel.TextLine) / 100;
Rect bounds;
if (iter.TryGetBoundingBox(PageIteratorLevel.TextLine, out bounds)) {
output.AppendFormat(CultureInfo.InvariantCulture, "<line confidence=\"{0:P}\" bounds=\"{1}, {2}, {3}, {4}\">", confidence, bounds.X1, bounds.Y1, bounds.X2, bounds.Y2);
} else {
output.AppendFormat(CultureInfo.InvariantCulture, "<line confidence=\"{0:P}\">", confidence);
}
}
if (iter.IsAtBeginningOf(PageIteratorLevel.Word)) {
var confidence = iter.GetConfidence(PageIteratorLevel.Word) / 100;
Rect bounds;
if (iter.TryGetBoundingBox(PageIteratorLevel.Word, out bounds)) {
output.AppendFormat(CultureInfo.InvariantCulture, "<word confidence=\"{0:P}\" bounds=\"{1}, {2}, {3}, {4}\">", confidence, bounds.X1, bounds.Y1, bounds.X2, bounds.Y2);
} else {
output.AppendFormat(CultureInfo.InvariantCulture, "<word confidence=\"{0:P}\">", confidence);
}
}
// symbol and choices
if (outputChoices)
{
using (var choiceIter = iter.GetChoiceIterator())
{
var symbolConfidence = iter.GetConfidence(PageIteratorLevel.Symbol)/100;
if (choiceIter != null)
{
output.AppendFormat(CultureInfo.InvariantCulture, "<symbol text=\"{0}\" confidence=\"{1:P}\">", iter.GetText(PageIteratorLevel.Symbol), symbolConfidence);
output.Append("<choices>");
do
{
var choiceConfidence = choiceIter.GetConfidence()/100;
output.AppendFormat(CultureInfo.InvariantCulture, "<choice text=\"{0}\" confidence\"{1:P}\"/>", choiceIter.GetText(), choiceConfidence);
} while (choiceIter.Next());
output.Append("</choices>");
output.Append("</symbol>");
}
else
{
output.AppendFormat(CultureInfo.InvariantCulture, "<symbol text=\"{0}\" confidence=\"{1:P}\"/>", iter.GetText(PageIteratorLevel.Symbol), symbolConfidence);
}
}
}
else
{
output.Append(iter.GetText(PageIteratorLevel.Symbol));
}
if (iter.IsAtFinalOf(PageIteratorLevel.Word, PageIteratorLevel.Symbol)) {
output.Append("</word>");
}
} while (iter.Next(PageIteratorLevel.Word, PageIteratorLevel.Symbol));
if (iter.IsAtFinalOf(PageIteratorLevel.TextLine, PageIteratorLevel.Word)) {
output.AppendLine("</line>");
}
} while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word));
if (iter.IsAtFinalOf(PageIteratorLevel.Para, PageIteratorLevel.TextLine)) {
output.AppendLine("</para>");
}
} while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine));
} while (iter.Next(PageIteratorLevel.Block, PageIteratorLevel.Para));
output.AppendLine("</block>");
} while (iter.Next(PageIteratorLevel.Block));
}
return NormaliseNewLine(output.ToString());
}