libcrn
3.9.5
A document image processing library
|
A text file. More...
#include <CRNTextFile.h>
Public Types | |
enum | Encoding { Encoding::UTF_8, Encoding::UTF_32 } |
Allowed text encoding. More... | |
Public Member Functions | |
TextFile (Encoding enc=Encoding::UTF_8) | |
Blank constructor. More... | |
TextFile (const Path &fname, Encoding enc=Encoding::UTF_8) | |
File constructor. More... | |
TextFile (const TextFile &)=delete | |
TextFile (TextFile &&)=default | |
~TextFile ()=default | |
Destructor. More... | |
TextFile & | operator= (const TextFile &)=delete |
TextFile & | operator= (TextFile &&)=default |
void | Save (const Path &fname) |
Saves a file with the same encoding as when loaded. More... | |
void | Save (const Path &fname, Encoding enc) |
Saves a file with specific encoding. More... | |
void | Save () |
Overwrites the loaded file. More... | |
const String & | GetText () const noexcept |
Get text content. More... | |
std::vector< String > | SplitText () const |
Extract words. More... | |
std::set< String > | ExtractWords (bool case_sensitive=false) const |
Extract unique words. More... | |
std::map< int, String > | ExtractWordsByFrequency (bool case_sensitive=false) const |
Extract unique words sorted by frequency. More... | |
Public Attributes | |
String | text |
A text file.
A UTF-8 text file.
Definition at line 43 of file CRNTextFile.h.
|
strong |
TextFile::TextFile | ( | Encoding | enc = Encoding::UTF_8 | ) |
Blank constructor.
Blank constructor
[in] | enc | the default encoding for writting |
Definition at line 35 of file CRNTextFile.cpp.
TextFile::TextFile | ( | const Path & | fname, |
Encoding | enc = Encoding::UTF_8 |
||
) |
File constructor.
File constructor
ExceptionIO | cannot open file |
[in] | fname | the file to load |
[in] | enc | the encoding of the file |
Definition at line 48 of file CRNTextFile.cpp.
|
delete |
|
default |
|
default |
Destructor.
Extract unique words.
Extract unique words
[in] | case_sensitive | if false, all words are converted to lower case |
Definition at line 156 of file CRNTextFile.cpp.
Extract unique words sorted by frequency.
Extract unique words and sort them from least frequent to most frequent.
If you want to sweep to words from the most frequent to the least frequent, use a reverse_iterator.
[in] | case_sensitive | if true, all words are converted to lower case |
Definition at line 181 of file CRNTextFile.cpp.
|
inlinenoexcept |
Get text content.
Definition at line 69 of file CRNTextFile.h.
void TextFile::Save | ( | const Path & | fname | ) |
Saves a file with the same encoding as when loaded.
Saves to file
ExceptionIO | cannot open file |
[in] | fname | the file name |
Definition at line 85 of file CRNTextFile.cpp.
Saves a file with specific encoding.
Saves to file
ExceptionIO | cannot open file |
[in] | fname | the file name |
[in] | enc | the encoding for saving |
Definition at line 110 of file CRNTextFile.cpp.
void TextFile::Save | ( | ) |
Overwrites the loaded file.
Saves to file
ExceptionIO | cannot open file |
Definition at line 133 of file CRNTextFile.cpp.
|
inline |
Extract words.
Definition at line 72 of file CRNTextFile.h.
String crn::TextFile::text |
the content of the file
Definition at line 78 of file CRNTextFile.h.