mirror of
https://github.com/qingjian-team/qingjian.git
synced 2026-11-18 16:16:35 +00:00
之前词库原始数据、基础词库输入和六张释义表在两个仓库各有一份,改一边容易漏另一边。 现在词库仓库是唯一来源:dict-convert、gloss-gen 和 tools/corpus 的缺省路径改指并排的 ../qingjian-dicts;Server 与设置页的释义表 TSV 退路改为 data/generated/ 里开发时导出的那份; CLI 不再退到 assets/ 下的词库,领域词库只读 data/generated/dicts/。 Linux 打包脚本不再带释义表 TSV。dict-convert 的 lexicon 测试依赖已删的数据,一并删掉, 基础词库输入的覆盖检查挪到词库仓库的 tools/check.py。
44 lines
1.9 KiB
C++
44 lines
1.9 KiB
C++
//! 真 Server 与 Fcitx5 面板显示分段假名,Alt+数字只上屏原始译文。
|
|
#include "qingjian.h"
|
|
#include "support/context.h"
|
|
#include "support/server.h"
|
|
#include <fcitx/inputcontextmanager.h>
|
|
#include <fcitx/inputpanel.h>
|
|
|
|
int main() {
|
|
Server server("learning_language = \"ja\"\n");
|
|
server.stop();
|
|
std::filesystem::remove(server.directory / "server.sock");
|
|
std::filesystem::create_directories(server.directory / "data/generated");
|
|
std::ofstream(server.directory / "data/generated/glossary-ja.tsv")
|
|
<< "开发\tv. 開発する|かいはつする\tn. 開発|かいはつ\n";
|
|
server.start();
|
|
char program[] = "qingjian-test"; char disable[] = "--disable=all";
|
|
char *arguments[] = {program, disable, nullptr};
|
|
fcitx::Instance instance(2, arguments);
|
|
instance.initialize();
|
|
fcitx::QingjianEngine engine(&instance.addonManager());
|
|
Context context(instance.inputContextManager());
|
|
context.focusIn();
|
|
auto compose = [&] {
|
|
for (char c : std::string("kaifa"))
|
|
assert(engine.process(&context, fcitx::Key(static_cast<fcitx::KeySym>(c))));
|
|
auto list = context.inputPanel().candidateList();
|
|
assert(list && list->candidate(0).text().toString() == "开发");
|
|
const auto annotation = list->candidate(0).comment().toString();
|
|
assert(annotation == "v. 開発(かいはつ)する · 生");
|
|
};
|
|
compose();
|
|
assert(engine.process(&context, fcitx::Key(FcitxKey_1, fcitx::KeyState::Alt)));
|
|
assert(context.committed == "開発する");
|
|
assert(context.inputPanel().empty());
|
|
context.committed.clear();
|
|
compose();
|
|
assert(engine.process(&context, fcitx::Key(FcitxKey_exclam, fcitx::KeyStates{fcitx::KeyState::Alt, fcitx::KeyState::Shift})));
|
|
assert(context.committed == "開発");
|
|
context.committed.clear();
|
|
compose();
|
|
context.inputPanel().candidateList()->candidate(0).select(&context);
|
|
assert(context.committed == "开发");
|
|
}
|