Loading...
Searching...
No Matches
opencc::MarisaDict Class Reference
OpenCC C++ Comprehensive API

Darts dictionary. More...

`#include <src/MarisaDict.hpp>`

Inheritance diagram for opencc::MarisaDict:

## Public Member Functions

virtual size_t | KeyMaxLength () const override
| Returns the length of the longest key in the dictionary.
virtual Optional< const DictEntry * > | Match (const char *word, size_t len) const override
| Matches a word exactly and returns the DictEntry or Optional::Null().
virtual Optional< const DictEntry * > | MatchPrefix (const char *word, size_t len) const override
| Matches the longest matched prefix of a word.
virtual std::vector< const DictEntry * > | MatchAllPrefixes (const char *word, size_t len) const override
| Returns all matched prefixes of a word, sorted by the length (desc).
virtual LexiconPtr | GetLexicon () const override
| Returns all entries in the dictionary.
virtual bool | SupportsFastPrefixMatch () const override
| 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 override
| Fast-path prefix match.
virtual void | SerializeToFile (FILE *fp) const override
| Serializes the dictionary and writes in to a file.
bool | IsLexiconReconstructed () const
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 const std::list< DictPtr > * | GetDictGroupItems () const
| Returns child dictionaries when this dictionary is a group.
virtual DictGroupMatchPolicy | GetMatchPolicy () const
| Returns the match policy when this dictionary is a group.
Public Member Functions inherited from opencc::SerializableDict
virtual void | SerializeToFile (const std::string &fileName) const
| Serializes the dictionary and writes in to a file.

## Static Public Member Functions

static MarisaDictPtr | NewFromDict (const Dict &thatDict)
| Constructs a MarisaDict from another dictionary.
static MarisaDictPtr | NewFromFile (FILE *fp)
static MarisaDictPtr | NewFromBuffer (const char *data, size_t size)
Static Public Member Functions inherited from opencc::SerializableDict
template<typename DICT>
static bool | TryLoadFromFile (const std::string &fileName, std::shared_ptr< DICT > *dict)
template<typename DICT>
static std::shared_ptr< DICT > | NewFromFile (const std::string &fileName)

## Detailed Description

Darts dictionary.

## Member Function Documentation

## GetLexicon()

LexiconPtr MarisaDict::GetLexicon | ( |  | ) | const

override virtual

Returns all entries in the dictionary.

Implements opencc::Dict.

## KeyMaxLength()

size_t MarisaDict::KeyMaxLength | ( |  | ) | const

override virtual

Returns the length of the longest key in the dictionary.

Implements opencc::Dict.

## Match()

Optional< const DictEntry * > MarisaDict::Match | ( | const char * | word,
|  | size_t | len ) const

override virtual

Matches a word exactly and returns the DictEntry or Optional::Null().

Implements opencc::Dict.

## MatchAllPrefixes()

std::vector< const DictEntry * > MarisaDict::MatchAllPrefixes | ( | const char * | word,
|  | size_t | len ) const

override virtual

Returns all matched prefixes of a word, sorted by the length (desc).

For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", all the matched prefixes of "banana" are "bana", "ban", "ba", "b".

Reimplemented from opencc::Dict.

## MatchPrefix()

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

override virtual

Matches the longest matched prefix of a word.

For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", the longest prefix of "banana" matched is "bana".

Reimplemented from opencc::Dict.

## MatchPrefixValue()

PrefixMatchView MarisaDict::MatchPrefixValue | ( | const char * | word,
|  | size_t | len ) const

override virtual

Fast-path prefix match.

Only called when SupportsFastPrefixMatch() is true. Returns a PrefixMatchView with matched=false on no match. See PrefixMatch::MatchPrefixView() for key/value lifetime details.

Reimplemented from opencc::Dict.

## SerializeToFile()

void MarisaDict::SerializeToFile | ( | FILE * | fp | ) | const

override virtual

Serializes the dictionary and writes in to a file.

Implements opencc::SerializableDict.

## SupportsFastPrefixMatch()

virtual bool opencc::MarisaDict::SupportsFastPrefixMatch | ( |  | ) | const

inline override virtual

Returns true if this dict can handle prefix queries directly without PrefixMatch building a lookup table.

Subclasses that override MatchPrefixValue() must also override this to return true.

Reimplemented from opencc::Dict.

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

- MarisaDict.hpp
- MarisaDict.cpp