LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
Lima::Common::Misc::TextFormater Class Reference

This class is dedicated to the various adaptations that have to be done on texts : More...

#include <linguisticProcessing/common/misc/textFormater.h>

Public Member Functions

 TextFormater ()
 
virtual ~TextFormater ()
 
int untaggingWithSpaces (std::ostream &status, std::istream &input, std::ostream &output, bool wide=false, const std::string &endSentenceTag="") const
 This method replaces all the tags in the UTF-8 encoded input stream by spaces or underscores in the output stream.
 

Detailed Description

This class is dedicated to the various adaptations that have to be done on texts :

  • un-HTML-isation;
  • maybe XML validation;
  • ...
Author
Gael de Chalendar

Definition at line 36 of file textFormater.h.

Constructor & Destructor Documentation

◆ TextFormater()

Lima::Common::Misc::TextFormater::TextFormater ( )

Definition at line 33 of file textFormater.cpp.

◆ ~TextFormater()

Lima::Common::Misc::TextFormater::~TextFormater ( )
virtual

Definition at line 37 of file textFormater.cpp.

Member Function Documentation

◆ untaggingWithSpaces()

int Lima::Common::Misc::TextFormater::untaggingWithSpaces ( std::ostream &  status,
std::istream &  input,
std::ostream &  output,
bool  wide = false,
const std::string &  endSentenceTag = "" 
) const

This method replaces all the tags in the UTF-8 encoded input stream by spaces or underscores in the output stream.

Underscores are written when the tag is adjacent to a word (directly or by another) tag. Spaces are written otherwise.
If an unclosed tag finishes the input stream, the result is written but an error message is written in status and a non zero-value is returned. If an opening '<' is found inside a tag, it is ignored (replaced) but an error message is written in status and a non zero-value will be returned. If a closing '>' is found outside a tag, it is ignored (replaced) but an error message is written in status and a non zero-value will be returned. Currently, this method is stateless. 2 subsequent calls consider working on two different streams. By the way, it has not to store persistent information about its state and thus it does not modify its receiver. Consequently, it is constant.

Parameters
std::ostream&status the stream where errors and warning will be written
std::istream&input the input stream. Should contain a valid SGML file
std::ostream&output the output stream. The result stream where un-tagged results are written
std::string&endSentenceTag if set to non-empty, this will be used as a sentence separator and the first character of this tag (the <) will be replaced by a dot in the output
Returns
int 0 if there is no error nor warning ; non-zero otherwise.

Underscores are written when the tag is adjacent to a word (directly or by another) tag. Spaces are written otherwise. If an unclosed tag finishes the input stream, the result is written but an error message is written in status and a non zero-value is returned. If an opening '<' is found inside a tag, it is ignored (replaced) but an error message is written in status and a non zero-value will be returned. If a closing '>' is found outside a tag, it is ignored (replaced) but an error message is written in status and a non zero-value will be returned. This method does not modify its receiver and thus is constant. Throws a runtime_error in case of an unknown internal state It does not record the removed tags. Should be done in another method;

Parameters
std::ostream&status the stream where errors and warning will be written
std::istream&input the input stream. Should contain a valid SGML file
std::ostream&output the output stream. The result stream where un-tagged results are written
Returns
int 0 if there is no error nor warning ; non-zero otherwise.

Definition at line 55 of file textFormater.cpp.


The documentation for this class was generated from the following files: