libime
pinyinime.h
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_PINYINIME_H_
7 #define _FCITX_LIBIME_PINYIN_PINYINIME_H_
8 
9 #include <cstddef>
10 #include <limits>
11 #include <memory>
12 #include <fcitx-utils/connectableobject.h>
13 #include <fcitx-utils/macros.h>
14 #include <libime/pinyin/libimepinyin_export.h>
15 #include <libime/pinyin/pinyincorrectionprofile.h>
16 #include <libime/pinyin/pinyinencoder.h>
17 
18 namespace libime {
19 
20 class PinyinIMEPrivate;
21 class PinyinDecoder;
22 class PinyinDictionary;
23 class UserLanguageModel;
24 
25 enum class PinyinPreeditMode { RawText, Pinyin };
26 
27 /// \brief Provides shared data for PinyinContext.
28 class LIBIMEPINYIN_EXPORT PinyinIME : public fcitx::ConnectableObject {
29 public:
30  PinyinIME(std::unique_ptr<PinyinDictionary> dict,
31  std::unique_ptr<UserLanguageModel> model);
32  virtual ~PinyinIME();
33 
34  PinyinFuzzyFlags fuzzyFlags() const;
35  void setFuzzyFlags(PinyinFuzzyFlags flags);
36  size_t nbest() const;
37  void setNBest(size_t n);
38  size_t beamSize() const;
39  void setBeamSize(size_t n);
40  size_t frameSize() const;
41  void setFrameSize(size_t n);
42  size_t partialLongWordLimit() const;
43  void setPartialLongWordLimit(size_t n);
44  /**
45  * \brief The maximum number of candidates that is a word.
46  *
47  * Limit the non single character candidates to avoid need to scroll/next
48  * page too many characters.
49  *
50  * When is 0, it means no limit.
51  *
52  * Since 1.1.12
53  */
54  size_t wordCandidateLimit() const;
55  /**
56  * \brief Set the maximum number of candidates that is a word.
57  * Since 1.1.12
58  */
59  void setWordCandidateLimit(size_t n);
60  void setScoreFilter(float maxDistance = std::numeric_limits<float>::max(),
61  float minPath = -std::numeric_limits<float>::max());
62  void setShuangpinProfile(std::shared_ptr<const ShuangpinProfile> profile);
63  std::shared_ptr<const ShuangpinProfile> shuangpinProfile() const;
64  void setPreeditMode(PinyinPreeditMode mode);
65  PinyinPreeditMode preeditMode() const;
66 
67  void setCorrectionProfile(
68  std::shared_ptr<const PinyinCorrectionProfile> profile);
69  std::shared_ptr<const PinyinCorrectionProfile> correctionProfile() const;
70 
71  float maxDistance() const;
72  float minPath() const;
73 
74  PinyinDictionary *dict();
75  const PinyinDictionary *dict() const;
76  const PinyinDecoder *decoder() const;
77  UserLanguageModel *model();
78  const UserLanguageModel *model() const;
79 
80  FCITX_DECLARE_SIGNAL(PinyinIME, optionChanged, void());
81 
82 private:
83  std::unique_ptr<PinyinIMEPrivate> d_ptr;
84  FCITX_DECLARE_PRIVATE(PinyinIME);
85 };
86 } // namespace libime
87 
88 #endif // _FCITX_LIBIME_PINYIN_PINYINIME_H_
PinyinDictionary is a set of dictionaries for Pinyin.
Provides shared data for PinyinContext.
Definition: pinyinime.h:28