Update Tesseract to version 5.0.
This commit is contained in:
32 files changed
+1119
-12894
No files matched your search
@@ -4,7 +4,6 @@
|
||||
// iterating in proper reading order over Bi Directional
|
||||
// (e.g. mixed Hebrew and English) text.
|
||||
// Author: David Eger
|
||||
// Created: Fri May 27 13:58:06 PST 2011
|
||||
//
|
||||
// (C) Copyright 2011, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -22,38 +21,32 @@
|
||||
#ifndef TESSERACT_CCMAIN_RESULT_ITERATOR_H_
|
||||
#define TESSERACT_CCMAIN_RESULT_ITERATOR_H_
|
||||
|
||||
#include <set> // for std::pair
|
||||
#include <vector> // for std::vector
|
||||
#include "ltrresultiterator.h" // for LTRResultIterator
|
||||
#include "platform.h" // for TESS_API, TESS_LOCAL
|
||||
#include "publictypes.h" // for PageIteratorLevel
|
||||
#include "unichar.h" // for StrongScriptDirection
|
||||
#include "export.h" // for TESS_API, TESS_LOCAL
|
||||
#include "ltrresultiterator.h" // for LTRResultIterator
|
||||
#include "publictypes.h" // for PageIteratorLevel
|
||||
#include "unichar.h" // for StrongScriptDirection
|
||||
|
||||
template <typename T> class GenericVector;
|
||||
template <typename T> class GenericVectorEqEq;
|
||||
|
||||
class STRING;
|
||||
#include <set> // for std::pair
|
||||
#include <vector> // for std::vector
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class Tesseract;
|
||||
|
||||
class TESS_API ResultIterator : public LTRResultIterator {
|
||||
public:
|
||||
public:
|
||||
static ResultIterator *StartOfParagraph(const LTRResultIterator &resit);
|
||||
|
||||
/**
|
||||
* ResultIterator is copy constructible!
|
||||
* The default copy constructor works just fine for us.
|
||||
*/
|
||||
virtual ~ResultIterator() = default;
|
||||
~ResultIterator() override = default;
|
||||
|
||||
// ============= Moving around within the page ============.
|
||||
/**
|
||||
* Moves the iterator to point to the start of the page to begin
|
||||
* an iteration.
|
||||
*/
|
||||
virtual void Begin();
|
||||
void Begin() override;
|
||||
|
||||
/**
|
||||
* Moves to the start of the next object at the given level in the
|
||||
@@ -67,7 +60,7 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
* This function iterates words in right-to-left scripts correctly, if
|
||||
* the appropriate language has been loaded into Tesseract.
|
||||
*/
|
||||
virtual bool Next(PageIteratorLevel level);
|
||||
bool Next(PageIteratorLevel level) override;
|
||||
|
||||
/**
|
||||
* IsAtBeginningOf() returns whether we're at the logical beginning of the
|
||||
@@ -75,15 +68,15 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
* order). Otherwise, this acts the same as PageIterator::IsAtBeginningOf().
|
||||
* For a full description, see pageiterator.h
|
||||
*/
|
||||
virtual bool IsAtBeginningOf(PageIteratorLevel level) const;
|
||||
bool IsAtBeginningOf(PageIteratorLevel level) const override;
|
||||
|
||||
/**
|
||||
* Implement PageIterator's IsAtFinalElement correctly in a BiDi context.
|
||||
* For instance, IsAtFinalElement(RIL_PARA, RIL_WORD) returns whether we
|
||||
* point at the last word in a paragraph. See PageIterator for full comment.
|
||||
*/
|
||||
virtual bool IsAtFinalElement(PageIteratorLevel level,
|
||||
PageIteratorLevel element) const;
|
||||
*/
|
||||
bool IsAtFinalElement(PageIteratorLevel level,
|
||||
PageIteratorLevel element) const override;
|
||||
|
||||
// ============= Functions that refer to words only ============.
|
||||
// Returns the number of blanks before the current word.
|
||||
@@ -94,18 +87,21 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
/**
|
||||
* Returns the null terminated UTF-8 encoded text string for the current
|
||||
* object at the given level. Use delete [] to free after use.
|
||||
*/
|
||||
virtual char* GetUTF8Text(PageIteratorLevel level) const;
|
||||
*/
|
||||
virtual char *GetUTF8Text(PageIteratorLevel level) const;
|
||||
|
||||
/**
|
||||
* Returns the LSTM choices for every LSTM timestep for the current word.
|
||||
*/
|
||||
virtual std::vector<std::vector<std::pair<const char*, float>>>* GetBestLSTMSymbolChoices() const;
|
||||
*/
|
||||
virtual std::vector<std::vector<std::vector<std::pair<const char *, float>>>>
|
||||
*GetRawLSTMTimesteps() const;
|
||||
virtual std::vector<std::vector<std::pair<const char *, float>>>
|
||||
*GetBestLSTMSymbolChoices() const;
|
||||
|
||||
/**
|
||||
* Return whether the current paragraph's dominant reading direction
|
||||
* is left-to-right (as opposed to right-to-left).
|
||||
*/
|
||||
*/
|
||||
bool ParagraphIsLtr() const;
|
||||
|
||||
// ============= Exposed only for testing =============.
|
||||
@@ -134,23 +130,23 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
*/
|
||||
static void CalculateTextlineOrder(
|
||||
bool paragraph_is_ltr,
|
||||
const GenericVector<StrongScriptDirection> &word_dirs,
|
||||
GenericVectorEqEq<int> *reading_order);
|
||||
const std::vector<StrongScriptDirection> &word_dirs,
|
||||
std::vector<int> *reading_order);
|
||||
|
||||
static const int kMinorRunStart;
|
||||
static const int kMinorRunEnd;
|
||||
static const int kComplexWord;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
/**
|
||||
* We presume the data associated with the given iterator will outlive us.
|
||||
* NB: This is private because it does something that is non-obvious:
|
||||
* it resets to the beginning of the paragraph instead of staying wherever
|
||||
* resit might have pointed.
|
||||
*/
|
||||
TESS_LOCAL explicit ResultIterator(const LTRResultIterator &resit);
|
||||
explicit ResultIterator(const LTRResultIterator &resit);
|
||||
|
||||
private:
|
||||
private:
|
||||
/**
|
||||
* Calculates the current paragraph's dominant writing direction.
|
||||
* Typically, members should use current_paragraph_ltr_ instead.
|
||||
@@ -170,12 +166,12 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
*/
|
||||
void CalculateTextlineOrder(bool paragraph_is_ltr,
|
||||
const LTRResultIterator &resit,
|
||||
GenericVectorEqEq<int> *indices) const;
|
||||
std::vector<int> *indices) const;
|
||||
/** Same as above, but the caller's ssd gets filled in if ssd != nullptr. */
|
||||
void CalculateTextlineOrder(bool paragraph_is_ltr,
|
||||
const LTRResultIterator &resit,
|
||||
GenericVector<StrongScriptDirection> *ssd,
|
||||
GenericVectorEqEq<int> *indices) const;
|
||||
std::vector<StrongScriptDirection> *ssd,
|
||||
std::vector<int> *indices) const;
|
||||
|
||||
/**
|
||||
* What is the index of the current word in a strict left-to-right reading
|
||||
@@ -187,7 +183,7 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
* Given an iterator pointing at a word, returns the logical reading order
|
||||
* of blob indices for the word.
|
||||
*/
|
||||
void CalculateBlobOrder(GenericVector<int> *blob_indices) const;
|
||||
void CalculateBlobOrder(std::vector<int> *blob_indices) const;
|
||||
|
||||
/** Precondition: current_paragraph_is_ltr_ is set. */
|
||||
void MoveToLogicalStartOfTextline();
|
||||
@@ -208,10 +204,10 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
* Append any extra marks that should be appended to this word when printed.
|
||||
* Mostly, these are Unicode BiDi control characters.
|
||||
*/
|
||||
void AppendSuffixMarks(STRING *text) const;
|
||||
void AppendSuffixMarks(std::string *text) const;
|
||||
|
||||
/** Appends the current word in reading order to the given buffer.*/
|
||||
void AppendUTF8WordText(STRING *text) const;
|
||||
void AppendUTF8WordText(std::string *text) const;
|
||||
|
||||
/**
|
||||
* Appends the text of the current text line, *assuming this iterator is
|
||||
@@ -220,7 +216,7 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
* Each textline is terminated in a single newline character.
|
||||
* If the textline ends a paragraph, it gets a second terminal newline.
|
||||
*/
|
||||
void IterateAndAppendUTF8TextlineText(STRING *text);
|
||||
void IterateAndAppendUTF8TextlineText(std::string *text);
|
||||
|
||||
/**
|
||||
* Appends the text of the current paragraph in reading order
|
||||
@@ -228,7 +224,7 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
* Each textline is terminated in a single newline character, and the
|
||||
* paragraph gets an extra newline at the end.
|
||||
*/
|
||||
void AppendUTF8ParagraphText(STRING *text) const;
|
||||
void AppendUTF8ParagraphText(std::string *text) const;
|
||||
|
||||
/** Returns whether the bidi_debug flag is set to at least min_level. */
|
||||
bool BidiDebug(int min_level) const;
|
||||
@@ -251,6 +247,6 @@ class TESS_API ResultIterator : public LTRResultIterator {
|
||||
bool preserve_interword_spaces_;
|
||||
};
|
||||
|
||||
} // namespace tesseract.
|
||||
} // namespace tesseract.
|
||||
|
||||
#endif // TESSERACT_CCMAIN_RESULT_ITERATOR_H_
|
||||
#endif // TESSERACT_CCMAIN_RESULT_ITERATOR_H_
|
||||
Reference in new issue
Block a user