1 /* 2 * SPDX-FileCopyrightText: 2017-2017 CSSlayer <wengxt@gmail.com> 3 * 4 * SPDX-License-Identifier: LGPL-2.1-or-later 5 */ 6 #ifndef _FCITX_LIBIME_PINYIN_PINYINDECODER_H_ 7 #define _FCITX_LIBIME_PINYIN_PINYINDECODER_H_ 8 9 #include "libimepinyin_export.h" 10 #include <libime/core/decoder.h> 11 #include <libime/pinyin/pinyindictionary.h> 12 13 namespace libime { 14 15 class PinyinLatticeNodePrivate; 16 17 class LIBIMEPINYIN_EXPORT PinyinLatticeNode : public LatticeNode { 18 public: 19 PinyinLatticeNode(std::string_view word, WordIndex idx, 20 SegmentGraphPath path, const State &state, float cost, 21 std::unique_ptr<PinyinLatticeNodePrivate> data); 22 virtual ~PinyinLatticeNode(); 23 24 const std::string &encodedPinyin() const; 25 26 private: 27 std::unique_ptr<PinyinLatticeNodePrivate> d_ptr; 28 }; 29 30 class LIBIMEPINYIN_EXPORT PinyinDecoder : public Decoder { 31 public: PinyinDecoder(const PinyinDictionary * dict,const LanguageModelBase * model)32 PinyinDecoder(const PinyinDictionary *dict, const LanguageModelBase *model) 33 : Decoder(dict, model) {} 34 35 protected: 36 LatticeNode *createLatticeNodeImpl(const SegmentGraphBase &graph, 37 const LanguageModelBase *model, 38 std::string_view word, WordIndex idx, 39 SegmentGraphPath path, 40 const State &state, float cost, 41 std::unique_ptr<LatticeNodeData> data, 42 bool onlyPath) const override; 43 }; 44 } // namespace libime 45 46 #endif // _FCITX_LIBIME_PINYIN_PINYINDECODER_H_ 47