84 void SetBaseline(
double d,
bool check_bounds =
true);
112 Option<double>
GetHPos()
const;
116 Option<double>
GetVPos()
const;
124 LineElement(
const Element &el,
const Option<double> &x,
const Option<double> &y,
const Option<double> &w);
147 const Option<Id>&
GetId()
const {
return id; }
165 Option<Alto::Styles::Text::FontStyle>
GetFontStyle()
const;
178 Option<double>
GetWC()
const;
180 void SetWC(
double conf);
182 Option<StringUTF8>
GetCC()
const;
189 Word(
const Element &el);
191 Word(
const Element &el,
const Id &id_,
const StringUTF8 &text,
const Option<double> &x,
const Option<double> &y,
const Option<double> &w,
const Option<double> &h);
199 const std::vector<WordPtr>&
GetWords()
const;
205 Word&
AddWord(
const Id &id_,
const StringUTF8 &text,
const Option<double> &x = Option<double>(),
const Option<double> &y = Option<double>(),
const Option<double> &w = Option<double>(),
const Option<double> &h = Option<double>());
207 Word&
AddWordAfter(
const Id &pred,
const Id &id_,
const StringUTF8 &text,
const Option<double> &x = Option<double>(),
const Option<double> &y = Option<double>(),
const Option<double> &w = Option<double>(),
const Option<double> &h = Option<double>());
209 Word&
AddWordBefore(
const Id &next,
const Id &id_,
const StringUTF8 &text,
const Option<double> &x = Option<double>(),
const Option<double> &y = Option<double>(),
const Option<double> &w = Option<double>(),
const Option<double> &h = Option<double>());
228 const Option<Id>&
GetId()
const {
return id; }
260 Hyphen(
const Element &el);
270 TextLine(
const Element &el,
const Id &id_,
double x,
double y,
double w,
double h);
272 void update_subelements();
275 mutable std::vector<std::shared_ptr<LineElement> > lineElements;
276 mutable std::vector<WordPtr> words;
277 mutable std::map<Id, WordPtr> id_words;
290 TextLine&
AddTextLine(
const Id &id_,
double x,
double y,
double w,
double h);
292 TextLine&
AddTextLineAfter(
const Id &pred,
const Id &id_,
double x,
double y,
double w,
double h);
303 TextBlock(
const Element &el,
const Id &id_,
int x,
int y,
int w,
int h);
305 void update_subelements();
307 std::vector<std::shared_ptr<TextLine> > lines;
308 std::map<Id, TextLinePtr> id_lines;
313 #error you cannot include this file directly
TextLine & GetTextLine(const Id &id_)
Returns a text line contained in the block.
const std::vector< WordPtr > & GetWords() const
Returns the list of words in the line.
Base class for elements in a text line.
Option< double > GetVPos() const
Returns the ordinate of the element.
virtual ~TextBlock() override
const Id & GetId() const
Returns the id of the element.
TextLine & AddTextLine(const Id &id_, double x, double y, double w, double h)
Adds a text line in the block.
void AddStyle(const Id &styleid)
Adds a reference to a style.
StringUTF8 GetContent() const
Returns the transcription of the word.
Hyphen & operator=(const Hyphen &)=delete
double GetHPos() const
Returns the abscissa of the line.
Option< Alto::Styles::Text::FontStyle > GetFontStyle() const
Returns the font style of the word.
Option< StringUTF8 > GetCC() const
Returns the OCR confidence of the characters.
Option< double > GetHeight() const
Returns the height of the word.
void SetWidth(double d)
Sets the width of the element.
Word & operator=(const Word &)=delete
void UnsetBaseline()
Unsets the baseline ordinate.
virtual ~Hyphen() override
double GetHeight() const
Returns the height of the line.
void RemoveStyle(const Id &styleid)
Removes a reference to a style.
std::weak_ptr< WhiteSpace > WhiteSpacePtr
TextLine & AddTextLineAfter(const Id &pred, const Id &id_, double x, double y, double w, double h)
Adds a text line in the block.
WhiteSpace(const WhiteSpace &)=delete
void SetHeight(double d)
Sets the height of the line.
Word & AddWord(const Id &id_, const StringUTF8 &text, const Option< double > &x=Option< double >(), const Option< double > &y=Option< double >(), const Option< double > &w=Option< double >(), const Option< double > &h=Option< double >())
Adds a word in the line.
TextLine & operator=(const TextLine &)=delete
void SetHPos(double d)
Sets the abscissa of the line.
void SetWidth(double d)
Sets the width of the line.
std::weak_ptr< Word > WordPtr
Word & AddWordBefore(const Id &next, const Id &id_, const StringUTF8 &text, const Option< double > &x=Option< double >(), const Option< double > &y=Option< double >(), const Option< double > &w=Option< double >(), const Option< double > &h=Option< double >())
Adds a word in the line.
void SetManuallyCorrected(bool c)
Sets whether the line was manually corrected or not.
Option< double > GetWC() const
Returns the OCR confidence of the word [0, 1].
std::weak_ptr< Hyphen > HyphenPtr
std::vector< Id > GetStyles() const
Returns the list of style references.
Option< bool > GetManuallyCorrected() const
Returns whether the line was manually corrected or not.
std::vector< Id > GetStyles() const
Returns the list of style references.
void SetWC(double conf)
Sets the OCR confidence of the word [0, 1].
void RemoveStyle(const Id &styleid)
Removes a reference to a style.
void RemoveTextLine(const Id &tid)
Removes a text line.
Word(const Word &)=delete
TextLine(const TextLine &)=delete
Alto white space ("SP" element)
StringUTF8 GetContent() const
Returns hyphenation marker.
void UnsetFontStyle()
Unsets the font style of the word.
Option< double > GetWidth() const
Returns the width of the element.
TextBlock(const TextBlock &)=delete
TextBlock & operator=(const TextBlock &)=delete
Alto word ("String" element)
void SetHeight(double d)
Returns the height of the word.
const Option< Id > & GetId() const
Returns the id of the element.
size_t GetNbLineElements() const
Returns the number of elements in the line.
Option< double > GetHPos() const
Returns the abscissa of the element.
double GetVPos() const
Returns the ordinate of the line.
void SetHPos(double d)
Sets the abscissa of the element.
void SetContent(const StringUTF8 &s)
Sets the hyphenation marker.
Hyphen(const Hyphen &)=delete
void SetVPos(double d)
Sets the ordinate of the element.
LineElement(const LineElement &)=delete
void SetFontStyle(Alto::Styles::Text::FontStyle fs)
Sets the font style of the word.
const Option< Id > & GetId() const
Returns the id of the element.
virtual ~LineElement() override
Word & GetWord(const Id &id_)
Returns a word contained in the line.
Option< SubstitutionType > GetSubstitutionType() const
Returns the substitution type of the word.
TextLine & AddTextLineBefore(const Id &next, const Id &id_, double x, double y, double w, double h)
Adds a text line in the block.
size_t GetNbTextLines() const
Returns the number of text lines in the block.
std::weak_ptr< TextLine > TextLinePtr
void SetVPos(double d)
Sets the ordinate of the line.
Option< StringUTF8 > GetLanguage() const
Returns the language of the text inside the block.
WhiteSpace & operator=(const WhiteSpace &)=delete
std::vector< LineElementPtr > GetLineElements() const
Returns the list of elements in the line.
Option< StringUTF8 > GetSubstitutionContent() const
Returns the substitution of the word.
std::vector< TextLinePtr > GetTextLines() const
Returns the list of text lines in the block.
Alto hyphen ("HYP" element)
void SetContent(const StringUTF8 &s)
Sets the transcription of the word.
size_t GetNbWords() const
Returns the number of words in the line.
Word & AddWordAfter(const Id &pred, const Id &id_, const StringUTF8 &text, const Option< double > &x=Option< double >(), const Option< double > &y=Option< double >(), const Option< double > &w=Option< double >(), const Option< double > &h=Option< double >())
Adds a word in the line.
virtual ~TextLine() override
double GetWidth() const
Returns the width of the line.
void UnsetManuallyCorrected()
Unsets whether the line was manually corrected or not.
Option< double > GetBaseline() const
Returns the ordinate of the baseline.
void UnsetWC()
Unsets the OCR confidence of the word.
void SetBaseline(double d, bool check_bounds=true)
Sets the baseline ordinate.
void SetSubstitution(SubstitutionType stype, const StringUTF8 &scontent)
Sets the substitution of the word.
virtual ~WhiteSpace() override
std::weak_ptr< LineElement > LineElementPtr
void RemoveWord(const Id &wid)
Removes a word.
LineElement & operator=(const LineElement &)=delete
void AddStyle(const Id &styleid)
Adds a reference to a style.