Open Chinese Convert: opencc::PipelineConverter Class Reference

Open Chinese Convert 1.4.0+g4813e9d34.dirty A project for conversion between Traditional and Simplified Chinese

Loading...
Searching...
No Matches
Public Member Functions | List of all members
opencc::PipelineConverter Class Reference
OpenCC C++ Comprehensive API

A `Converter` that passes text through a sequence of `Converter` stages in order, feeding the output of each stage as input to the next. More...

`#include <PipelineConverter.hpp>`

Inheritance diagram for opencc::PipelineConverter:

## Public Member Functions
| PipelineConverter (std::vector< ConverterPtr > stages)
std::string | Convert (std::string_view text) const override
| Converts `text` and returns the result.
ConversionInspectionResult | Inspect (std::string_view text) const override
| Returns an inspection result with `input` and `output` populated.
SegmentationPtr | GetSegmentation () const override
| Returns the last stage's segmentation, or `nullptr` for an empty pipeline.
ConversionChainPtr | GetConversionChain () const override
| Always returns `nullptr`; a pipeline has no single conversion chain.

## Detailed Description

A `Converter` that passes text through a sequence of `Converter` stages in order, feeding the output of each stage as input to the next.

This enables multi-step conversion schemes where different segmentation strategies or dictionary sets are needed at each step. For example, the `s2twp` config first converts Simplified to Traditional (stage 1) and then applies Taiwan-specific phrase substitution (stage 2).

Note
  `GetConversionChain()` always returns `nullptr` because a pipeline has no single chain. `GetSegmentation()` returns the last stage's segmentation as a best-effort representative.

## Constructor & Destructor Documentation

## ◆ PipelineConverter()

opencc::PipelineConverter::PipelineConverter | ( | std::vector< ConverterPtr > | stages | ) |
| inlineexplicit

Parameters

  stages | Ordered list of converters to apply in sequence.

## Member Function Documentation

## ◆ Convert()

std::string PipelineConverter::Convert | ( | std::string_view | text | ) | const
| overridevirtual

Converts `text` and returns the result.

Parameters

  text | UTF-8 input; need not be null-terminated.

Implements opencc::Converter.

## ◆ GetConversionChain()

ConversionChainPtr opencc::PipelineConverter::GetConversionChain | ( |  | ) | const
| inlineoverridevirtual

Always returns `nullptr`; a pipeline has no single conversion chain.

Implements opencc::Converter.

## ◆ GetSegmentation()

SegmentationPtr PipelineConverter::GetSegmentation | ( |  | ) | const
| overridevirtual

Returns the last stage's segmentation, or `nullptr` for an empty pipeline.

Implements opencc::Converter.

## ◆ Inspect()

ConversionInspectionResult PipelineConverter::Inspect | ( | std::string_view | text | ) | const
| overridevirtual

Returns an inspection result with `input` and `output` populated.

Per-stage segment detail is not available at the pipeline level.

Implements opencc::Converter.

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

- PipelineConverter.hpp
- PipelineConverter.cpp