This commit is contained in:
Alexander Zaitsev 2018-05-20 01:31:03 +03:00
parent 0248c7ff9d
commit 0697235bb2
42 changed files with 82 additions and 82 deletions

View File

@ -88,7 +88,7 @@ struct LineHypothesis {
class ParagraphTheory; // Forward Declaration
typedef GenericVectorEqEq<const ParagraphModel *> SetOfModels;
using SetOfModels = GenericVectorEqEq<const ParagraphModel *>;
// Row Scratch Registers are data generated by the paragraph detection
// algorithm based on a RowInfo input.

View File

@ -71,7 +71,7 @@ struct TPOINT {
int16_t x; // absolute x coord.
int16_t y; // absolute y coord.
};
typedef TPOINT VECTOR; // structure for coordinates.
using VECTOR = TPOINT; // structure for coordinates.
struct EDGEPT {
EDGEPT()

View File

@ -120,7 +120,7 @@ class DetLineFit {
// Type holds the distance of each point from the fitted line and the point
// itself. Use of double allows integer distances from ICOORDs to be stored
// exactly, and also the floating point results from ConstrainedFit.
typedef KDPairInc<double, ICOORD> DistPointPair;
using DistPointPair = KDPairInc<double, ICOORD>;
// Computes and returns the squared evaluation metric for a line fit.
double EvaluateLineFit();

View File

@ -628,6 +628,6 @@ struct MATRIX_COORD {
};
// The MatrixCoordPair contains a MATRIX_COORD and its priority.
typedef tesseract::KDPairInc<float, MATRIX_COORD> MatrixCoordPair;
using MatrixCoordPair = tesseract::KDPairInc<float, MATRIX_COORD>;
#endif // TESSERACT_CCSTRUCT_MATRIX_H_

View File

@ -119,7 +119,7 @@ struct ParamsTrainingHypothesis {
};
// A list of hypotheses explored during one run of segmentation search.
typedef GenericVector<ParamsTrainingHypothesis> ParamsTrainingHypothesisList;
using ParamsTrainingHypothesisList = GenericVector<ParamsTrainingHypothesis>;
// A bundle that accumulates all of the hypothesis lists explored during all
// of the runs of segmentation search on a word (e.g. a list of hypotheses

View File

@ -637,7 +637,7 @@ class WERD_CHOICE : public ELIST_LINK {
// Make WERD_CHOICE listable.
ELISTIZEH(WERD_CHOICE)
typedef GenericVector<BLOB_CHOICE_LIST *> BLOB_CHOICE_LIST_VECTOR;
using BLOB_CHOICE_LIST_VECTOR = GenericVector<BLOB_CHOICE_LIST *>;
// Utilities for comparing WERD_CHOICEs

View File

@ -39,7 +39,7 @@
/*----------------------------------------------------------------------
T y p e s
----------------------------------------------------------------------*/
typedef float PRIORITY; /* PRIORITY */
using PRIORITY = float; /* PRIORITY */
class SEAM {
public:

View File

@ -31,7 +31,7 @@
namespace tesseract {
typedef GenericVector<UNICHAR_ID> UnicharIdVector;
using UnicharIdVector = GenericVector<UNICHAR_ID>;
static const int kUnigramAmbigsBufferSize = 1000;
static const char kAmbigNgramSeparator[] = { ' ', '\0' };
@ -138,7 +138,7 @@ ELISTIZEH(AmbigSpec)
// AMBIG_TABLE[i] stores a set of ambiguities whose
// wrong ngram starts with unichar id i.
typedef GenericVector<AmbigSpec_LIST *> UnicharAmbigsVector;
using UnicharAmbigsVector = GenericVector<AmbigSpec_LIST *>;
class UnicharAmbigs {
public:

View File

@ -31,9 +31,9 @@
#include <cstdint> // int32_t, ...
// definitions of portable data types (numbers and characters)
typedef float FLOAT32;
typedef double FLOAT64;
typedef unsigned char BOOL8;
using FLOAT32 = float;
using FLOAT64 = double;
using BOOL8 = unsigned char;
#if defined(_WIN32)

View File

@ -176,7 +176,7 @@ struct KDPtrPairDec : public KDPtrPair<Key, Data> {
};
// Specialization for a pair of ints in increasing order.
typedef KDPairInc<int, int> IntKDPair;
using IntKDPair = KDPairInc<int, int>;
// Vector of IntKDPair.
class KDVector : public GenericVector<IntKDPair> {

View File

@ -32,7 +32,7 @@
// TODO(rays) Move these to the tesseract namespace.
// A UNICHAR_ID is the unique id of a unichar.
typedef int UNICHAR_ID;
using UNICHAR_ID = int;
// A variable to indicate an invalid or uninitialized unichar id.
static const int INVALID_UNICHAR_ID = -1;
@ -49,7 +49,7 @@ enum StrongScriptDirection {
namespace tesseract {
typedef signed int char32;
using char32 = signed int;
// The UNICHAR class holds a single classification result. This may be
// a single Unicode character (stored as between 1 and 4 utf8 bytes) or
@ -106,7 +106,7 @@ class UNICHAR {
// tprintf("Char = %s\n", buf);
// }
class const_iterator {
typedef const_iterator CI;
using CI = const_iterator ;
public:
// Step to the next UTF8 character.

View File

@ -44,9 +44,9 @@ static int RadicalPreHash(const std::vector<int>& rs) {
}
// A hash map to convert unicodes to radical encoding.
typedef std::unordered_map<int, std::unique_ptr<std::vector<int>>> RSMap;
using RSMap = std::unordered_map<int, std::unique_ptr<std::vector<int>>>;
// A hash map to count occurrences of each radical encoding.
typedef std::unordered_map<int, int> RSCounts;
using RSCounts = std::unordered_map<int, int>;
static bool DecodeRadicalLine(STRING* radical_data_line, RSMap* radical_map) {
if (radical_data_line->length() == 0 || (*radical_data_line)[0] == '#')

View File

@ -164,8 +164,8 @@ struct TEMPCLUSTER {
CLUSTER *Neighbor;
};
typedef tesseract::KDPairInc<float, TEMPCLUSTER*> ClusterPair;
typedef tesseract::GenericHeap<ClusterPair> ClusterHeap;
using ClusterPair = tesseract::KDPairInc<float, TEMPCLUSTER*>;
using ClusterHeap = tesseract::GenericHeap<ClusterPair>;
struct STATISTICS {
FLOAT32 AvgVariance;

View File

@ -43,14 +43,14 @@ struct CHAR_DESC_STRUCT {
uint32_t NumFeatureSets;
FEATURE_SET FeatureSets[NUM_FEATURE_TYPES];
};
typedef CHAR_DESC_STRUCT *CHAR_DESC;
using CHAR_DESC = CHAR_DESC_STRUCT *;
struct FEATURE_DEFS_STRUCT {
int32_t NumFeatureTypes;
const FEATURE_DESC_STRUCT* FeatureDesc[NUM_FEATURE_TYPES];
int FeatureEnabled[NUM_FEATURE_TYPES];
};
typedef FEATURE_DEFS_STRUCT *FEATURE_DEFS;
using FEATURE_DEFS = FEATURE_DEFS_STRUCT *;
/*----------------------------------------------------------------------
Generic functions for manipulating character descriptions

View File

@ -30,7 +30,7 @@ typedef struct
{
FLOAT32 x, y;
} FPOINT;
typedef FPOINT FVECTOR;
using FVECTOR = FPOINT;
/**----------------------------------------------------------------------------
Macros

View File

@ -58,26 +58,26 @@ struct FEATURE_DESC_STRUCT {
const char *ShortName; // short name for feature
const PARAM_DESC *ParamDesc; // array - one per param
};
typedef FEATURE_DESC_STRUCT *FEATURE_DESC;
using FEATURE_DESC = FEATURE_DESC_STRUCT *;
struct FEATURE_STRUCT {
const FEATURE_DESC_STRUCT *Type; // points to description of feature type
FLOAT32 Params[1]; // variable size array - params for feature
};
typedef FEATURE_STRUCT *FEATURE;
using FEATURE = FEATURE_STRUCT *;
struct FEATURE_SET_STRUCT {
uint16_t NumFeatures; // number of features in set
uint16_t MaxNumFeatures; // maximum size of feature set
FEATURE Features[1]; // variable size array of features
};
typedef FEATURE_SET_STRUCT *FEATURE_SET;
using FEATURE_SET = FEATURE_SET_STRUCT *;
// A generic character description as a char pointer. In reality, it will be
// a pointer to some data structure. Paired feature extractors/matchers need
// to agree on the data structure to be used, however, the high level
// classifier does not need to know the details of this data structure.
typedef char *CHAR_FEATURES;
using CHAR_FEATURES = char *;
/*----------------------------------------------------------------------
Macros for defining the parameters of a new features

View File

@ -37,7 +37,7 @@
/*----------------------------------------------------------------------
T y p e s
----------------------------------------------------------------------*/
typedef BIT_VECTOR *CONFIGS;
using CONFIGS = BIT_VECTOR *;
typedef struct
{
@ -49,7 +49,7 @@ typedef struct
FLOAT32 Angle;
FLOAT32 Length;
} PROTO_STRUCT;
typedef PROTO_STRUCT *PROTO;
using PROTO = PROTO_STRUCT *;
struct CLASS_STRUCT {
CLASS_STRUCT()
@ -64,8 +64,8 @@ struct CLASS_STRUCT {
CONFIGS Configurations;
UnicityTableEqEq<int> font_set;
};
typedef CLASS_STRUCT *CLASS_TYPE;
typedef CLASS_STRUCT *CLASSES;
using CLASS_TYPE = CLASS_STRUCT *;
using CLASSES = CLASS_STRUCT *;
/*----------------------------------------------------------------------
C o n s t a n t s

View File

@ -153,7 +153,7 @@ struct ShapeQueueEntry {
// Which level in the tree did this come from?
int level;
};
typedef GenericHeap<ShapeQueueEntry> ShapeQueue;
using ShapeQueue = GenericHeap<ShapeQueueEntry>;
// Simple struct to hold a set of fonts associated with a single unichar-id.
// A vector of UnicharAndFonts makes a shape.

View File

@ -25,7 +25,7 @@
-----------------------------------------------------------------------------*/
// TODO(rays) Rename BITSINLONG to BITSINuint32_t, and use sizeof.
#define BITSINLONG 32 /**< no of bits in a long */
typedef uint32_t *BIT_VECTOR;
using BIT_VECTOR = uint32_t *;
/*-----------------------------------------------------------------------------
Public Function Prototypes

View File

@ -24,7 +24,7 @@
#define NOERROR 0
#define DO_NOTHING 0
typedef int TRAPERROR;
using TRAPERROR = int;
typedef void (*VOID_PROC) ();
/**----------------------------------------------------------------------------

View File

@ -129,7 +129,7 @@ struct list_rec
struct list_rec *node;
struct list_rec *next;
};
typedef list_rec *LIST;
using LIST = list_rec *;
/*----------------------------------------------------------------------
M a c r o s

View File

@ -50,11 +50,11 @@
----------------------------------------------------------------------*/
class UNICHARSET;
typedef uint64_t EDGE_RECORD;
typedef EDGE_RECORD *EDGE_ARRAY;
typedef int64_t EDGE_REF;
typedef int64_t NODE_REF;
typedef EDGE_REF *NODE_MAP;
using EDGE_RECORD = uint64_t;
using EDGE_ARRAY = EDGE_RECORD *;
using EDGE_REF = int64_t;
using NODE_REF = int64_t;
using NODE_MAP = EDGE_REF *;
namespace tesseract {
@ -65,9 +65,9 @@ struct NodeChild {
NodeChild(): unichar_id(INVALID_UNICHAR_ID), edge_ref(NO_EDGE) {}
};
typedef GenericVector<NodeChild> NodeChildVector;
typedef GenericVector<int> SuccessorList;
typedef GenericVector<SuccessorList *> SuccessorListsVector;
using NodeChildVector = GenericVector<NodeChild>;
using SuccessorList = GenericVector<int>;
using SuccessorListsVector = GenericVector<SuccessorList *>;
enum DawgType {
DAWG_TYPE_PUNCTUATION,

View File

@ -46,7 +46,7 @@ struct CHAR_FRAGMENT_INFO {
namespace tesseract {
typedef GenericVector<Dawg *> DawgVector;
using DawgVector = GenericVector<Dawg *>;
//
// Constants

View File

@ -32,19 +32,19 @@
#define MAX_CLASS_ID (MAX_NUM_CLASSES - 1)
/** a CLASS_ID is the ascii character to be associated with a class */
typedef UNICHAR_ID CLASS_ID;
using CLASS_ID = UNICHAR_ID;
#define NO_CLASS (0)
/** a PROTO_ID is the index of a prototype within it's class. Valid proto
id's are 0 to N-1 where N is the number of prototypes that make up the
class. */
typedef int16_t PROTO_ID;
using PROTO_ID = int16_t;
#define NO_PROTO (-1)
/** FEATURE_ID is the index of a feature within a character description
The feature id ranges from 0 to N-1 where N is the number
of features in a character description. */
typedef uint8_t FEATURE_ID;
using FEATURE_ID = uint8_t;
#define NO_FEATURE 255
#define NOISE_FEATURE 254
#define MISSING_PROTO 254
@ -53,13 +53,13 @@ typedef uint8_t FEATURE_ID;
/** a RATING is the match rating returned by a classifier.
Higher is better. */
typedef FLOAT32 RATING;
using RATING = FLOAT32;
/** a CERTAINTY is an indication of the degree of confidence of the
classifier. Higher is better. 0 means the match is as good as the
mean of the matches seen in training. -1 means the match was one
standard deviation worse than the training matches, etc. */
typedef FLOAT32 CERTAINTY;
using CERTAINTY = FLOAT32;
/** define a data structure to hold a single match result */
typedef struct

View File

@ -29,7 +29,7 @@
class WERD_CHOICE;
typedef uint8_t BLOB_WIDTH;
using BLOB_WIDTH = uint8_t;
struct DANGERR_INFO {
DANGERR_INFO() :
@ -44,7 +44,7 @@ struct DANGERR_INFO {
UNICHAR_ID leftmost; // in the replacement, what's the leftmost character?
};
typedef GenericVector<DANGERR_INFO> DANGERR;
using DANGERR = GenericVector<DANGERR_INFO>;
#endif

View File

@ -41,15 +41,15 @@ class UNICHARSET;
// It might be cleanest to change the types of most of the Trie/Dawg related
// typedefs to int and restrict the casts to extracting these values from
// the 64 bit EDGE_RECORD.
typedef int64_t EDGE_INDEX; // index of an edge in a given node
typedef bool *NODE_MARKER;
typedef GenericVector<EDGE_RECORD> EDGE_VECTOR;
using EDGE_INDEX = int64_t ; // index of an edge in a given node
using NODE_MARKER = bool *;
using EDGE_VECTOR = GenericVector<EDGE_RECORD> ;
struct TRIE_NODE_RECORD {
EDGE_VECTOR forward_edges;
EDGE_VECTOR backward_edges;
};
typedef GenericVector<TRIE_NODE_RECORD *> TRIE_NODES;
using TRIE_NODES = GenericVector<TRIE_NODE_RECORD *> ;
namespace tesseract {

View File

@ -1243,7 +1243,7 @@ double LSTMTrainer::ComputeCharError(const GenericVector<int>& truth_str,
// Computes word recall error rate using a very simple bag of words algorithm.
// NOTE that this is destructive on both input strings.
double LSTMTrainer::ComputeWordError(STRING* truth_str, STRING* ocr_str) {
typedef std::unordered_map<std::string, int, std::hash<std::string> > StrMap;
using StrMap = std::unordered_map<std::string, int, std::hash<std::string>>;
GenericVector<STRING> truth_words, ocr_words;
truth_str->split(' ', &truth_words);
if (truth_words.empty()) return 0.0;

View File

@ -169,8 +169,8 @@ struct RecodeNode {
uint64_t code_hash;
};
typedef KDPairInc<double, RecodeNode> RecodePair;
typedef GenericHeap<RecodePair> RecodeHeap;
using RecodePair = KDPairInc<double, RecodeNode>;
using RecodeHeap = GenericHeap<RecodePair>;
// Class that holds the entire beam search for recognition of a text line.
class RecodeBeamSearch {
@ -262,7 +262,7 @@ class RecodeBeamSearch {
// all of the step.
RecodeNode best_initial_dawgs_[NC_COUNT];
};
typedef KDPairInc<float, int> TopPair;
using TopPair = KDPairInc<float, int>;
// Generates debug output of the content of a single beam position.
void DebugBeamPos(const UNICHARSET& unicharset, const RecodeHeap& heap) const;

View File

@ -28,7 +28,7 @@ CLISTIZEH(BLOBNBOX)
namespace tesseract {
typedef GridSearch<BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT> BlobGridSearch;
using BlobGridSearch = GridSearch<BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT>;
class BlobGrid : public BBGrid<BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT> {
public:

View File

@ -925,9 +925,9 @@ class ColPartition : public ELIST2_LINK {
};
// Typedef it now in case it becomes a class later.
typedef GridSearch<ColPartition,
using ColPartitionGridSearch = GridSearch<ColPartition,
ColPartition_CLIST,
ColPartition_C_IT> ColPartitionGridSearch;
ColPartition_C_IT> ;
} // namespace tesseract.

View File

@ -31,7 +31,7 @@ namespace tesseract {
class WorkingPartSet_LIST;
class ColSegment_LIST;
class ColPartitionSet;
typedef GenericVector<ColPartitionSet*> PartSetVector;
using PartSetVector = GenericVector<ColPartitionSet*>;
// ColPartitionSet is a class that holds a list of ColPartitions.
// Its main use is in holding a candidate partitioning of the width of the

View File

@ -33,7 +33,7 @@ struct Pix;
namespace tesseract {
typedef TessResultCallback1<bool, int> WidthCallback;
using WidthCallback = TessResultCallback1<bool, int>;
struct AlignedBlobParams;
class ColPartitionGrid;

View File

@ -113,12 +113,12 @@ class ColSegment : public ELIST_LINK {
};
// Typedef BBGrid of ColSegments
typedef BBGrid<ColSegment,
using ColSegmentGrid = BBGrid<ColSegment,
ColSegment_CLIST,
ColSegment_C_IT> ColSegmentGrid;
typedef GridSearch<ColSegment,
ColSegment_C_IT>;
using ColSegmentGridSearch = GridSearch<ColSegment,
ColSegment_CLIST,
ColSegment_C_IT> ColSegmentGridSearch;
ColSegment_C_IT>;
// TableFinder is a utility class to find a set of tables given a set of
// ColPartitions and Columns. The TableFinder will mark candidate ColPartitions

View File

@ -62,8 +62,8 @@ class WordWithBox {
// Make it usable by BBGrid.
CLISTIZEH(WordWithBox)
typedef BBGrid<WordWithBox, WordWithBox_CLIST, WordWithBox_C_IT> WordGrid;
typedef GridSearch<WordWithBox, WordWithBox_CLIST, WordWithBox_C_IT> WordSearch;
using WordGrid = BBGrid<WordWithBox, WordWithBox_CLIST, WordWithBox_C_IT>;
using WordSearch = GridSearch<WordWithBox, WordWithBox_CLIST, WordWithBox_C_IT>;
class Textord {
public:

View File

@ -57,7 +57,7 @@ typedef struct
int NumMerged[MAX_NUM_PROTOS];
CLASS_TYPE Class;
}MERGE_CLASS_NODE;
typedef MERGE_CLASS_NODE* MERGE_CLASS;
using MERGE_CLASS = MERGE_CLASS_NODE*;
//////////////////////////////////////////////////////////////////////////////

View File

@ -33,7 +33,7 @@ namespace tesseract {
class PangoFontInfo; // defined in pango_font_info.h
// Map to substitute strings for ligatures.
typedef std::unordered_map<std::string, std::string, StringHash> LigHash;
using LigHash = std::unordered_map<std::string, std::string, StringHash>;
class LigatureTable {
public:

View File

@ -35,7 +35,7 @@
DECLARE_STRING_PARAM_FLAG(fonts_dir);
DECLARE_STRING_PARAM_FLAG(fontconfig_tmpdir);
typedef signed int char32;
using char32 = signed int;
namespace tesseract {

View File

@ -130,7 +130,7 @@ class Validator {
kWhitespace = ' ',
kCombiner = 'c', // Combiners other than virama.
};
typedef std::pair<CharClass, char32> IndicPair;
using IndicPair = std::pair<CharClass, char32>;
Validator(ViramaScript script, bool report_errors)
: script_(script),

View File

@ -38,7 +38,7 @@
---------------------------------------------------------------------*/
#define MAX_NUM_POINTS 50
// The PointPair elements do NOT own the EDGEPTs.
typedef tesseract::KDPairInc<float, EDGEPT*> PointPair;
typedef tesseract::GenericHeap<PointPair> PointHeap;
using PointPair = tesseract::KDPairInc<float, EDGEPT*>;
using PointHeap = tesseract::GenericHeap<PointPair>;
#endif

View File

@ -35,10 +35,10 @@
#include "chop.h"
// The SeamPair elements own their SEAMs and delete them upon destruction.
typedef tesseract::KDPtrPairInc<float, SEAM> SeamPair;
typedef tesseract::GenericHeap<SeamPair> SeamQueue;
using SeamPair = tesseract::KDPtrPairInc<float, SEAM>;
using SeamQueue = tesseract::GenericHeap<SeamPair>;
typedef tesseract::KDPtrPairDec<float, SEAM> SeamDecPair;
typedef tesseract::GenericHeap<SeamDecPair> SeamPile;
using SeamDecPair = tesseract::KDPtrPairDec<float, SEAM>;
using SeamPile = tesseract::GenericHeap<SeamDecPair>;
#endif

View File

@ -31,7 +31,7 @@
namespace tesseract {
// Heap of pain points used for determining where to chop/join.
typedef GenericHeap<MatrixCoordPair> PainPointHeap;
using PainPointHeap = GenericHeap<MatrixCoordPair>;
// Types of pain points (ordered in the decreasing level of importance).
enum LMPainPointsType {

View File

@ -34,7 +34,7 @@
namespace tesseract {
/// Used for expressing various language model flags.
typedef unsigned char LanguageModelFlagsType;
using LanguageModelFlagsType = unsigned char;
/// The following structs are used for storing the state of the language model
/// in the segmentation search graph. In this graph the nodes are BLOB_CHOICEs