Add gazetteer to analyze worker

Pass a `Gazetteer` to the analyze worker to enable proper-name
correction. The gazetteer is loaded from disk at application startup. If
the directory is missing or unreadable, the worker will start without
proper-name correction capabilities.
This commit is contained in:
2026-04-16 17:27:09 +02:00
parent 1fd252f363
commit 5717b8f718
3 changed files with 36 additions and 3 deletions
+23
View File
@@ -10,6 +10,7 @@ use tracing_subscriber::EnvFilter;
use doctate_server::analyze;
use doctate_server::config::Config;
use doctate_server::gazetteer::Gazetteer;
use doctate_server::transcribe;
use doctate_server::AppState;
@@ -64,6 +65,27 @@ async fn main() {
.build()
.expect("reqwest client build failed");
// Gazetteer for pre-LLM proper-name correction. Missing / unreadable
// vocab directory is non-fatal — analysis falls back to plain prompts.
let vocab = Arc::new(match Gazetteer::load_dir(&config.vocab_dir).await {
Ok(g) => {
info!(
dir = %config.vocab_dir.display(),
entries = g.len(),
"Gazetteer loaded"
);
g
}
Err(e) => {
warn!(
dir = %config.vocab_dir.display(),
error = %e,
"Gazetteer not available; running without proper-name correction"
);
Gazetteer::empty()
}
});
// Transcription pipeline: channel + worker + recovery scan.
let (transcribe_tx, transcribe_rx) = transcribe::channel();
let transcribe_busy: doctate_server::WorkerBusy =
@@ -96,6 +118,7 @@ async fn main() {
config.clone(),
http_client.clone(),
analyze_busy.clone(),
vocab.clone(),
));
{
let tx = analyze_tx.clone();