|
Open Chinese Convert 1.3.2+gad37fd0a6.dirty
A project for conversion between Traditional and Simplified Chinese
|
An ordered sequence of Conversion objects applied to pre-segmented text.
More...
#include <ConversionChain.hpp>
Public Member Functions | |
| ConversionChain (const std::list< ConversionPtr > _conversions) | |
| Constructs a chain from an ordered list of conversions. | |
| SegmentsPtr | Convert (const SegmentsPtr &input) const |
Passes input through every conversion in the chain sequentially and returns the final Segments. | |
| void | AppendConvertedSegment (const char *segment, std::string *output) const |
Converts the null-terminated segment through all conversions and appends the result to output. | |
| void | AppendConvertedSegment (std::string_view segment, std::string *output) const |
Like AppendConvertedSegment(const char*, std::string*) but accepts the segment as a string_view, avoiding a copy when the caller already has a non-null-terminated view (e.g. | |
| std::vector< SegmentsPtr > | ConvertWithTrace (const SegmentsPtr &input) const |
Converts input through the chain and records every intermediate Segments after each conversion stage. | |
| const std::list< ConversionPtr > | GetConversions () const |
| Returns the list of conversions in application order. | |
An ordered sequence of Conversion objects applied to pre-segmented text.
Each Conversion in the chain wraps one dictionary. The chain applies them in order: the output segments of conversion N become the input of conversion N+1. This enables priority-ordered substitution, such as applying phrase dictionaries before character dictionaries so that multi-character matches take precedence.
A ConversionChain operates on Segments (output of Segmentation) and has no knowledge of how those segments were produced.
| void ConversionChain::AppendConvertedSegment | ( | const char * | segment, |
| std::string * | output ) const |
Converts the null-terminated segment through all conversions and appends the result to output.
This is the hot-path entry point used by SingleStageConverter to avoid intermediate string allocations.
| void ConversionChain::AppendConvertedSegment | ( | std::string_view | segment, |
| std::string * | output ) const |
Like AppendConvertedSegment(const char*, std::string*) but accepts the segment as a string_view, avoiding a copy when the caller already has a non-null-terminated view (e.g.
SingleStageConverter with no segmentation).
| std::vector< SegmentsPtr > ConversionChain::ConvertWithTrace | ( | const SegmentsPtr & | input | ) | const |
Converts input through the chain and records every intermediate Segments after each conversion stage.