From cce68296772cc94c32830c06458241b2b140fbf8 Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Tue, 23 Jul 2024 07:04:12 +0800 Subject: [PATCH] Print Candidate Weights in API Console for Easy Debugging --- src/rime_api.cc | 1 + src/rime_api.h | 1 + tools/rime_api_console.cc | 1 + 3 files changed, 3 insertions(+) diff --git a/src/rime_api.cc b/src/rime_api.cc index 2f75e7e3ec..19f048265b 100644 --- a/src/rime_api.cc +++ b/src/rime_api.cc @@ -239,6 +239,7 @@ static void rime_candidate_copy(RimeCandidate* dest, const an& src) { } else { dest->comment = nullptr; } + dest->quality = src->quality(); dest->reserved = nullptr; } diff --git a/src/rime_api.h b/src/rime_api.h index a44f7b53ce..c94ed8b832 100644 --- a/src/rime_api.h +++ b/src/rime_api.h @@ -114,6 +114,7 @@ typedef struct { typedef struct rime_candidate_t { char* text; char* comment; + double quality; void* reserved; } RimeCandidate; diff --git a/tools/rime_api_console.cc b/tools/rime_api_console.cc index 5cd73167e1..d5b0c88192 100644 --- a/tools/rime_api_console.cc +++ b/tools/rime_api_console.cc @@ -78,6 +78,7 @@ void print_menu(RimeMenu* menu) { bool highlighted = i == menu->highlighted_candidate_index; printf("%d. %c%s%c ", (i + 1) % 10, highlighted ? '[' : ' ', menu->candidates[i].text, highlighted ? ']' : ' '); + printf("%f ", menu->candidates[i].quality); print_comment(menu->candidates[i].comment); putchar('\n'); }