diff --git a/src/libime/core/constants.h b/src/libime/core/constants.h index 4dfb0ac..e99f08e 100644 --- a/src/libime/core/constants.h +++ b/src/libime/core/constants.h @@ -11,11 +11,11 @@ namespace libime { constexpr float DEFAULT_USER_LANGUAGE_MODEL_UNIGRAM_WEIGHT = 3; constexpr float DEFAULT_USER_LANGUAGE_MODEL_BIGRAM_WEIGHT = 15; constexpr float DEFAULT_LANGUAGE_MODEL_UNKNOWN_PROBABILITY_PENALTY = - 1 / 60000000.0f; + 1 / 60000000.0F; // -38... is log10(2^-127) -constexpr float HISTORY_BIGRAM_ALPHA_VALUE = 1.0f; +constexpr float HISTORY_BIGRAM_ALPHA_VALUE = 1.0F; constexpr float MIN_FLOAT_LOG10 = -38.23080944932561; -constexpr float DEFAULT_USER_LANGUAGE_MODEL_USER_WEIGHT = 0.2f; +constexpr float DEFAULT_USER_LANGUAGE_MODEL_USER_WEIGHT = 0.2F; } // namespace libime #endif // _FCITX_LIBIME_CORE_CONSTANTS_H_ diff --git a/src/libime/core/datrie.cpp b/src/libime/core/datrie.cpp index c16f121..c67212f 100644 --- a/src/libime/core/datrie.cpp +++ b/src/libime/core/datrie.cpp @@ -18,10 +18,17 @@ #include #include #include +#include #include #include +#include +#include #include +#include #include +#include +#include +#include #include namespace libime { diff --git a/src/libime/core/decoder.cpp b/src/libime/core/decoder.cpp index 1f07165..516828c 100644 --- a/src/libime/core/decoder.cpp +++ b/src/libime/core/decoder.cpp @@ -7,14 +7,28 @@ #include "decoder.h" #include "languagemodel.h" #include "lattice_p.h" +#include "libime/core/lattice.h" +#include "libime/core/segmentgraph.h" #include "utils.h" +#include +#include #include #include #include +#include +#include +#include +#include #include #include #include +#include +#include +#include +#include #include +#include +#include namespace libime { @@ -25,7 +39,7 @@ struct NBestNode { const LatticeNode *node_; // for nbest - float gn_ = 0.0f; + float gn_ = 0.0F; float fn_ = -std::numeric_limits::max(); std::shared_ptr next_; }; @@ -387,9 +401,10 @@ bool Decoder::decode(Lattice &l, const SegmentGraph &graph, size_t nbest, } LatticeNode *Decoder::createLatticeNodeImpl( - const SegmentGraphBase &, const LanguageModelBase *, std::string_view word, - WordIndex idx, SegmentGraphPath path, const State &state, float cost, - std::unique_ptr, bool) const { + const SegmentGraphBase & /*unused*/, const LanguageModelBase * /*unused*/, + std::string_view word, WordIndex idx, SegmentGraphPath path, + const State &state, float cost, std::unique_ptr /*unused*/, + bool /*unused*/) const { return new LatticeNode(word, idx, std::move(path), state, cost); } } // namespace libime diff --git a/src/libime/core/zstdfilter.h b/src/libime/core/zstdfilter.h index 2ea10a3..982c602 100644 --- a/src/libime/core/zstdfilter.h +++ b/src/libime/core/zstdfilter.h @@ -7,11 +7,20 @@ #ifndef LIBIME_ZSTDFILTER_H #define LIBIME_ZSTDFILTER_H +#include +#include #include #include #include +#include +#include +#include #include #include +#include +#include +#include +#include #include namespace libime { @@ -41,14 +50,14 @@ enum class ZSTDResult { class ZSTDFilterBase { public: - typedef char char_type; + using char_type = char; + ZSTDFilterBase(const ZSTDFilterBase &) = delete; protected: ZSTDFilterBase() = default; - ZSTDFilterBase(const ZSTDFilterBase &) = delete; ~ZSTDFilterBase() {} void before(const char *&src_begin, const char *src_end, char *&dest_begin, - char *dest_end) { + const char *dest_end) { in_.src = src_begin; in_.size = static_cast(src_end - src_begin); in_.pos = 0; @@ -56,7 +65,8 @@ class ZSTDFilterBase { out_.size = static_cast(dest_end - dest_begin); out_.pos = 0; } - void after(const char *&src_begin, char *&dest_begin, bool) { + void after(const char *&src_begin, char *&dest_begin, + bool /*unused*/) const { src_begin = reinterpret_cast(in_.src) + in_.pos; dest_begin = reinterpret_cast(out_.dst) + out_.pos; } @@ -95,8 +105,9 @@ class ZSTDCompressorImpl : public ZSTDFilterBase { ZSTDResult deflate(bool finish) { // Ignore spurious extra calls. // Note size > 0 will trigger an error in this case. - if (eof_ && in_.size == 0) + if (eof_ && in_.size == 0) { return ZSTDResult::StreamEnd; + } size_t result = ZSTD_compressStream(cstream_.get(), &out_, &in_); ZSTDError::check(result); if (finish) { @@ -147,12 +158,12 @@ class ZSTDDecompressorImpl : public ZSTDFilterBase { struct ZSTDCompressor : boost::iostreams::symmetric_filter { private: - typedef details::ZSTDCompressorImpl impl_type; - typedef symmetric_filter base_type; + using impl_type = details::ZSTDCompressorImpl; + using base_type = symmetric_filter; public: - typedef typename base_type::char_type char_type; - typedef typename base_type::category category; + using char_type = typename base_type::char_type; + using category = typename base_type::category; ZSTDCompressor(std::streamsize buffer_size = boost::iostreams::default_device_buffer_size) : base_type(buffer_size) {} @@ -162,12 +173,12 @@ BOOST_IOSTREAMS_PIPABLE(ZSTDCompressor, 0) struct ZSTDDecompressor : boost::iostreams::symmetric_filter { private: - typedef details::ZSTDDecompressorImpl impl_type; - typedef symmetric_filter base_type; + using impl_type = details::ZSTDDecompressorImpl; + using base_type = symmetric_filter; public: - typedef typename base_type::char_type char_type; - typedef typename base_type::category category; + using char_type = typename base_type::char_type; + using category = typename base_type::category; ZSTDDecompressor(std::streamsize buffer_size = boost::iostreams::default_device_buffer_size) : base_type(buffer_size) {}