MLBookProc 1.0.1
 
Loading...
Searching...
No Matches
FormatAnnotation Class Reference

The FormatAnnotation class. More...

#include <FormatAnnotation.h>

Inheritance diagram for FormatAnnotation:
XMLParser

Public Member Functions

 FormatAnnotation (const std::shared_ptr< AuxFunc > &af)
 FormatAnnotation constructor.
 
void remove_escape_sequences (std::string &annotation)
 Removes escape sequences from annotation.
 
void replace_tags (std::string &annotation)
 Replaces XML tags.
 
void final_cleaning (std::string &annotation)
 Cleans some sequences from annotation.
 
void removeAllTags (std::string &annotation)
 Simply removes all XML tags.
 
void setTagReplacementTable (const std::vector< ReplaceTagItem > &replacement_table)
 Sets tag replacement table.
 

Detailed Description

The FormatAnnotation class.

This class contains different methods for annotation processing.

Constructor & Destructor Documentation

◆ FormatAnnotation()

FormatAnnotation::FormatAnnotation ( const std::shared_ptr< AuxFunc > & af)

FormatAnnotation constructor.

Parameters
afsmart pointer to AuxFunc object.

Member Function Documentation

◆ final_cleaning()

void FormatAnnotation::final_cleaning ( std::string & annotation)

Cleans some sequences from annotation.

Replaces "three spaces" by "two spaces" at the annotation beginning, removes "\n" from annotation beginning, removes 0 - 32 ASCII symbols from the annotation end. Also replaces "\n\n\n" sequences by "\n\n" in whole annotation.

Parameters
annotationUTF-8 annotation content string.

◆ remove_escape_sequences()

void FormatAnnotation::remove_escape_sequences ( std::string & annotation)

Removes escape sequences from annotation.

Removes ASCII symbols 0 to 31 (inclusive) from annotation. Only exception is symbol 9 (horizontal tab). It will be replaced by 32 (space). Also removes extra spaces from annotation beginning.

Parameters
annotationUTF-8 annotation content string.

◆ removeAllTags()

void FormatAnnotation::removeAllTags ( std::string & annotation)

Simply removes all XML tags.

Parameters
annotationUTF-8 annotation content string.

◆ replace_tags()

void FormatAnnotation::replace_tags ( std::string & annotation)

Replaces XML tags.

It is highly recommended to call setTagReplacementTable() method before this method call (but it is not compulsory). If tag replacement table is empty, all tags will be just removed.

Parameters
annotationUTF-8 annotation content string.

◆ setTagReplacementTable()

void FormatAnnotation::setTagReplacementTable ( const std::vector< ReplaceTagItem > & replacement_table)

Sets tag replacement table.

If you need to replace XML tags by your own tags or text, you should call this method before replace_tags() call to set replacement table.

Parameters
replacement_tablevector containing ReplaceTagItem objects.