|
Open Chinese Convert 1.3.2
A project for conversion between Traditional and Simplified Chinese
|
Single-dictionary phrase conversion. More...
#include <Conversion.hpp>
Public Member Functions | |
| Conversion (DictPtr _dict) | |
Constructs a Conversion backed by dict. | |
| std::string | Convert (std::string_view phrase) const |
Converts phrase using prefix-match replacement and returns the result. | |
| std::string | Convert (const char *phrase) const |
Converts phrase using prefix-match replacement and returns the result. | |
| void | AppendConverted (std::string_view phrase, std::string *output) const |
Converts phrase and appends the result to output. | |
| void | AppendConverted (const char *phrase, std::string *output) const |
Converts phrase and appends the result to output. | |
| SegmentsPtr | Convert (const SegmentsPtr &input) const |
Converts every segment in input and returns a new Segments object. | |
| const DictPtr | GetDict () const |
| Returns the backing dictionary. | |
Single-dictionary phrase conversion.
Applies prefix-match replacement using one dictionary (DictPtr) to an already-segmented piece of text. This is the lowest-level conversion primitive: it knows nothing about segmentation and operates on a single segment or a pre-built Segments object.
Multiple Conversion objects are composed in a ConversionChain to apply several dictionaries in order (e.g. phrase dictionary first, then character dictionary).
| void Conversion::AppendConverted | ( | const char * | phrase, |
| std::string * | output ) const |
Converts phrase and appends the result to output.
| phrase | Null-terminated UTF-8 text. |
| output | Destination buffer; content is appended, not replaced. |
| void Conversion::AppendConverted | ( | std::string_view | phrase, |
| std::string * | output ) const |
Converts phrase and appends the result to output.
Preferred in hot paths (e.g. ConversionChain) to avoid extra allocations.
| phrase | UTF-8 text; need not be null-terminated. |
| output | Destination buffer; content is appended, not replaced. |
| std::string Conversion::Convert | ( | const char * | phrase | ) | const |
Converts phrase using prefix-match replacement and returns the result.
| phrase | Null-terminated UTF-8 text. |
| SegmentsPtr Conversion::Convert | ( | const SegmentsPtr & | input | ) | const |
Converts every segment in input and returns a new Segments object.
Each segment is converted independently via Convert(const char*).
| std::string Conversion::Convert | ( | std::string_view | phrase | ) | const |
Converts phrase using prefix-match replacement and returns the result.
| phrase | UTF-8 text; need not be null-terminated. |