// // Copyright RIME Developers // Distributed under the BSD License // // 2011-7-12 Zou xu // #ifndef RIME_SYLLABIFIER_H_ #define RIME_SYLLABIFIER_H_ #include #include #include #include "spelling.h" namespace rime { class Prism; class Corrector; using SyllableId = int32_t; struct EdgeProperties : SpellingProperties { EdgeProperties(SpellingProperties sup) : SpellingProperties(sup) {}; EdgeProperties() = default; // 切分歧義編碼段的起始位置 set ambiguous_source_positions; }; using SpellingMap = map; using VertexMap = map; using EndVertexMap = map; using EdgeMap = map; using SpellingPropertiesList = vector; using SpellingIndex = map; using SpellingIndices = map; struct SyllableGraph { size_t input_length = 0; size_t interpreted_length = 0; VertexMap vertices; EdgeMap edges; SpellingIndices indices; }; class Syllabifier { public: Syllabifier() = default; explicit Syllabifier(const string& delimiters, bool enable_completion = false, bool strict_spelling = false) : delimiters_(delimiters), enable_completion_(enable_completion), strict_spelling_(strict_spelling) {} RIME_DLL int BuildSyllableGraph(const string& input, Prism& prism, SyllableGraph* graph); RIME_DLL void EnableCorrection(Corrector* corrector); protected: void CheckOverlappedSpellings(SyllableGraph* graph, size_t start, size_t end); void Transpose(SyllableGraph* graph); string delimiters_; bool enable_completion_ = false; bool strict_spelling_ = false; Corrector* corrector_ = nullptr; }; } // namespace rime #endif // RIME_SYLLABIFIER_H_