下一页箭头原先在当前页满时一律可点,为首字母候选分批展开留口子; 但只有单个首字母且首字母候选恰好截在 24 条时才能展开,其余情况 末页满页的右箭头点了没反应也不会变灰。 引擎新增只判断不查库的 can_expand_initial_candidates,与实际展开 共用前置条件;Server 发布候选页快照时,满页只有在还能展开时才算 有下一页。 Refs #1069
47 lines
2.2 KiB
C++
47 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "pinyin_candidate_provider.h"
|
|
#include "wubi_candidate_provider.h"
|
|
#include "japanese_candidate_provider.h"
|
|
#include "../core/scheme_type.h"
|
|
#include <string>
|
|
|
|
class ProviderRegistry
|
|
{
|
|
public:
|
|
explicit ProviderRegistry(const ShuangpinProfile &shuangpin_profile = GetXiaoheShuangpinProfile(),
|
|
metasequoia::RuntimePaths paths = metasequoia::RuntimePaths::legacy());
|
|
ICandidateProvider &resolve(SchemeType scheme_type);
|
|
std::optional<WordItem> find_candidate(SchemeType scheme_type, const std::string &key, const std::string &value);
|
|
bool can_expand_initial_candidates(const QueryRequest &request, const std::vector<WordItem> &candidates) const;
|
|
bool expand_initial_candidates(const QueryRequest &request, std::vector<WordItem> &candidates);
|
|
// 双拼直接辅助码只出在拼音 provider 上,见 PinyinCandidateProvider::resolve_direct_helpcode。
|
|
bool resolve_direct_helpcode(QueryRequest &request)
|
|
{
|
|
return pinyin_provider_.resolve_direct_helpcode(request);
|
|
}
|
|
void reset_cache(SchemeType scheme_type);
|
|
// 整句(词格 + 神经重排)只出在拼音 provider 上,五笔混输查的也是它。
|
|
void reset_sentence_cache()
|
|
{
|
|
pinyin_provider_.reset_sentence_cache();
|
|
}
|
|
int create_word(SchemeType scheme_type, std::string pinyin, std::string word);
|
|
int update_weight_by_pinyin_and_word(SchemeType scheme_type, std::string pinyin, std::string word);
|
|
int delete_by_pinyin_and_word(SchemeType scheme_type, std::string pinyin, std::string word);
|
|
int cache_dynamic_candidate(SchemeType scheme_type, const std::string &pinyin, const std::string &word,
|
|
CandidateSource source);
|
|
int cache_dynamic_candidate_for_request(const QueryRequest &request, const std::string &word,
|
|
CandidateSource source);
|
|
|
|
void set_helpcode_keymap(HelpcodeUtils::SharedKeymap table)
|
|
{
|
|
pinyin_provider_.set_helpcode_keymap(std::move(table));
|
|
}
|
|
|
|
private:
|
|
PinyinCandidateProvider pinyin_provider_;
|
|
WubiCandidateProvider wubi_provider_;
|
|
JapaneseCandidateProvider japanese_provider_;
|
|
};
|