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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user