Skip to main content

Module domain

Module domain 

Source
Expand description

Domain overlay dictionary: stack multiple UserDictionary instances by priority.

§Design

Multiple dictionaries can coexist with explicit priority ordering (0 = highest). Searches across all domains are performed in priority order; higher-priority domain entries appear first in results. This enables domain-specific vocabulary to shadow or augment lower-priority entries without merging the underlying data.

§Example

use std::sync::Arc;
use mecab_ko_dict::domain::{DomainId, DomainStack};
use mecab_ko_dict::user_dict::UserDictionary;

let mut stack = DomainStack::new();

let mut news = UserDictionary::new();
news.add_entry("뉴스피드", "NNG", Some(-1000), None);

let mut finance = UserDictionary::new();
finance.add_entry("코스피", "NNP", Some(-1000), None);

stack.add_domain(DomainId("news".into()), 0, Arc::new(news), None);
stack.add_domain(DomainId("finance".into()), 1, Arc::new(finance), None);

assert_eq!(stack.len(), 2);

Structs§

DomainDictionary
A single domain overlay paired with its priority and metadata.
DomainId
Opaque identifier for a domain.
DomainStack
Ordered stack of domain dictionaries searched in priority order.