|
Open Chinese Convert 1.3.2
A project for conversion between Traditional and Simplified Chinese
|
Group of dictionaries. More...
#include <DictGroup.hpp>
Public Member Functions | |
| 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 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. | |
| 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. | |
Static Public Member Functions | |
| static DictGroupPtr | NewFromDict (const Dict &dict) |
Group of dictionaries.
DictGroup preserves dictionary order. With the current ShortCircuit match policy, exact lookup returns the first match from the first child dictionary that contains the key.
OpenCC's built-in conversion and mmseg segmentation paths do not call DictGroup::MatchPrefix() or DictGroup::MatchAllPrefixes() directly. They construct a PrefixMatch from the group, and PrefixMatch uses GetDictGroupItems() to build its own group-aware prefix matcher. The prefix methods below are still part of the Dict API for direct DictGroup callers and tests.
|
inlinevirtual |
Exposes child dictionaries to callers that need group-aware behavior.
PrefixMatch uses this to preserve nested group boundaries and dictionary order.
Reimplemented from opencc::Dict.
|
virtual |
Returns a merged lexicon from all child dictionaries.
Duplicate keys are not deduplicated here. PrefixMatch handles group priority while building its lookup table.
Implements opencc::Dict.
|
inlinevirtual |
Returns how this group resolves matches across child dictionaries.
Reimplemented from opencc::Dict.
|
virtual |
Returns the maximum KeyMaxLength() among all child dictionaries.
Implements opencc::Dict.
Matches the key exactly against child dictionaries in group order.
Returns the first child dictionary's exact match, if any.
Implements opencc::Dict.
|
virtual |
Returns prefix matches from all child dictionaries, sorted by key length descending.
When multiple child dictionaries have matches of the same key length, the first child dictionary wins.
This method is not used by OpenCC's normal conversion or mmseg segmentation paths; PrefixMatch expands the group via GetDictGroupItems() instead.
Reimplemented from opencc::Dict.
|
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::Dict.
Reimplemented in opencc::UnionDictGroup.