Open Chinese Convert: opencc::UnionDictGroup Class Reference

Open Chinese Convert 1.3.2.dirty A project for conversion between Traditional and Simplified Chinese

Loading...
Searching...
No Matches
Public Member Functions | List of all members
opencc::UnionDictGroup Class Reference

Group of dictionaries with union prefix-match semantics. More...

`#include <DictGroup.hpp>`

Inheritance diagram for opencc::UnionDictGroup:

## Public Member Functions
| UnionDictGroup (const std::list< DictPtr > &dicts)
virtual Optional< const DictEntry * > | MatchPrefix (const char *word, size_t len) const
| Matches the longest prefix within the first child dictionary that has any prefix match.
Public Member Functions inherited from opencc::DictGroup
| DictGroup (const std::list< DictPtr > &dicts)
| DictGroup (const std::list< DictPtr > &dicts, DictGroupMatchPolicy matchPolicy)
virtual size_t | KeyMaxLength () const
| Returns the maximum KeyMaxLength() among all child dictionaries.
virtual Optional< const DictEntry * > | Match (const char *word, size_t len) const
| Matches the key exactly against child dictionaries in group order.
virtual std::vector< const DictEntry * > | MatchAllPrefixes (const char *word, size_t len) const
| Returns prefix matches from all child dictionaries, sorted by key length descending.
virtual LexiconPtr | GetLexicon () const
| Returns a merged lexicon from all child dictionaries.
virtual const std::list< DictPtr > * | GetDictGroupItems () const
| Exposes child dictionaries to callers that need group-aware behavior.
const std::list< DictPtr > | GetDicts () const
| Returns the child dictionaries by value.
virtual DictGroupMatchPolicy | GetMatchPolicy () const
| Returns how this group resolves matches across child dictionaries.
Public Member Functions inherited from opencc::Dict
Optional< const DictEntry * > | Match (const std::string &word) const
| Matches a word exactly and returns the DictEntry or Optional::Null().
Optional< const DictEntry * > | MatchPrefix (const char *word) const
| Matches the longest matched prefix of a word.
Optional< const DictEntry * > | MatchPrefix (const std::string &word) const
| Matches the longest matched prefix of a word.
std::vector< const DictEntry * > | MatchAllPrefixes (const std::string &word) const
| Returns all matched prefixes of a word, sorted by the length (desc).
virtual bool | SupportsFastPrefixMatch () const
| Returns true if this dict can handle prefix queries directly without PrefixMatch building a lookup table.
virtual PrefixMatchView | MatchPrefixValue (const char *word, size_t len) const
| Fast-path prefix match.

## Additional Inherited Members
Static Public Member Functions inherited from opencc::DictGroup
static DictGroupPtr | NewFromDict (const Dict &dict)

## Detailed Description

Group of dictionaries with union prefix-match semantics.

Exact lookup still uses dictionary order for duplicate keys. Prefix lookup chooses the longest child match, using dictionary order only as a tie-breaker. MatchAllPrefixes() has the same behavior as DictGroup: all matched prefix lengths are returned once, and earlier dictionaries win equal-length ties.

## Member Function Documentation

## ◆ MatchPrefix()

Optional< const DictEntry * > UnionDictGroup::MatchPrefix | ( | const char * | word,
|  | size_t | len ) const
| virtual

Matches the longest prefix within the first child dictionary that has any prefix match.

A shorter match from an earlier child dictionary therefore wins over a longer match from a later child dictionary.

This method is not used by OpenCC's normal conversion or mmseg segmentation paths; PrefixMatch expands the group via GetDictGroupItems() instead.

Reimplemented from opencc::DictGroup.

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

- DictGroup.hpp
- DictGroup.cpp