use crate::capabilities::Capabilities;
use crate::types::{EntityType, Language};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ContextTerms {
pub window_tokens: usize,
pub boost: f32,
pub terms: Vec<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LanguageProfile {
pub language: Language,
pub capabilities: Capabilities,
pub context: HashMap<EntityType, ContextTerms>,
}
impl LanguageProfile {
pub fn new(language: Language, capabilities: Capabilities) -> Self {
Self {
language,
capabilities,
context: HashMap::new(),
}
}
pub fn with_context(mut self, entity: EntityType, terms: ContextTerms) -> Self {
self.context.insert(entity, terms);
self
}
}
#[derive(Clone, Debug, Default)]
pub struct LanguageRegistry {
profiles: HashMap<Language, LanguageProfile>,
}
impl LanguageRegistry {
pub fn insert(&mut self, profile: LanguageProfile) {
self.profiles.insert(profile.language.clone(), profile);
}
pub fn get(&self, language: &Language) -> Option<&LanguageProfile> {
self.profiles.get(language)
}
}