///|
/// MoonSearch is a MoonBit-native embedded full-text search kernel.
///
/// M5b aligns the analysis boundary with Tantivy: Tokenizer and TokenFilter
/// compose lazy TokenStreams, TextAnalyzer is itself a Tokenizer pipeline, and
/// TokenizerManager stores named Tokenizers used consistently by indexing and
/// query-time analysis. M5b-2 adds an `en_stem` pipeline with Porter2 English
/// stemming plus an optional stop-word filter. M5b-4a adds an optional,
/// dictionary-backed Chinese tokenizer package, and M5b-4b adds weighted DAG
/// routing without HMM. M5b-4c-1 adds portable, line-diagnosed dictionary text
/// resources, while M5b-4c-2 adds optional injected B/M/E/S HMM recognition;
/// M5c-1 adds validated Token Graph finite-string expansion for graph-aware
/// Boolean and Phrase query construction, and M5c-2 adds dictionary-gated
/// Chinese search-mode subword graphs. M5c-3 closes M5 with an index-flat
/// position policy that preserves precise cross-word phrases without changing
/// Segment persistence. N-gram remains a generic tool rather than Chinese word
/// segmentation.
///
/// The root package is a compatibility facade over responsibility-focused
/// core, schema, analysis, index, query, and store packages.
///|
/// Stable root-package facade for MoonSearch's foundational value types.
pub using @core {
type FieldId,
type DocId,
type DocAddress,
type Document,
type StoredDocument,
type Term,
type PersistenceError,
}
///|
/// Stable root-package facade for schema construction and field options.
pub using @schema {type TextOptions, type Schema, type SchemaBuilder}
///|
/// Stable root-package facade for text analysis.
pub using @analysis {
type Token,
type TokenGraph,
type TokenGraphPath,
type AnalysisError,
trait TokenStream,
trait Tokenizer,
type WhitespaceAnalyzer,
type RawTokenizer,
type WhitespaceTokenizer,
type SimpleTokenizer,
type NgramTokenizer,
trait TokenFilter,
type LowerCaseFilter,
type RemoveLongFilter,
type StopWordFilter,
type EnglishStemmerFilter,
type TextAnalyzer,
type TokenizerManager,
}
///|
/// Creates the English stemming pipeline exposed as the `en_stem` preset.
pub fn english_stem_analyzer() -> TextAnalyzer {
@analysis.english_stem_analyzer()
}
///|
/// Stable root-package facade for optional dictionary-backed Chinese analysis.
pub using @chinese {
type ChineseDictionaryResourceError,
type ChineseHmmModelError,
type ChineseHmmState,
type ChineseLexiconError,
type ChineseLexiconEntry,
type ChineseWordMatch,
trait ChineseDictionary,
trait ChineseHmmModel,
type ChineseLexicon,
type ChineseSearchModeFilter,
type ChineseTokenizer,
type TableChineseHmmModel,
}
///|
/// Creates a lowercase Chinese analyzer around an injected dictionary.
pub fn chinese_analyzer(dictionary : &ChineseDictionary) -> TextAnalyzer {
@chinese.chinese_analyzer(dictionary)
}
///|
/// Creates a longest-match Chinese analyzer with search-mode subwords.
pub fn chinese_search_analyzer(dictionary : &ChineseDictionary) -> TextAnalyzer {
@chinese.chinese_search_analyzer(dictionary)
}
///|
/// Creates a longest-match Chinese search expansion for indexing.
pub fn chinese_search_index_analyzer(
dictionary : &ChineseDictionary,
) -> TextAnalyzer {
@chinese.chinese_search_index_analyzer(dictionary)
}
///|
/// Creates a lowercase Chinese analyzer using frequency-DAG routing.
pub fn chinese_dag_analyzer(dictionary : &ChineseDictionary) -> TextAnalyzer {
@chinese.chinese_dag_analyzer(dictionary)
}
///|
/// Creates a Chinese DAG analyzer with search-mode subwords.
pub fn chinese_dag_search_analyzer(
dictionary : &ChineseDictionary,
) -> TextAnalyzer {
@chinese.chinese_dag_search_analyzer(dictionary)
}
///|
/// Creates a Chinese DAG search expansion for indexing.
pub fn chinese_dag_search_index_analyzer(
dictionary : &ChineseDictionary,
) -> TextAnalyzer {
@chinese.chinese_dag_search_index_analyzer(dictionary)
}
///|
/// Creates a lowercase Chinese DAG analyzer with injected HMM recognition.
pub fn chinese_dag_hmm_analyzer(
dictionary : &ChineseDictionary,
model : &ChineseHmmModel,
) -> TextAnalyzer {
@chinese.chinese_dag_hmm_analyzer(dictionary, model)
}
///|
/// Creates a Chinese DAG/HMM analyzer with search-mode subwords.
pub fn chinese_dag_hmm_search_analyzer(
dictionary : &ChineseDictionary,
model : &ChineseHmmModel,
) -> TextAnalyzer {
@chinese.chinese_dag_hmm_search_analyzer(dictionary, model)
}
///|
/// Creates a Chinese DAG/HMM search expansion for indexing.
pub fn chinese_dag_hmm_search_index_analyzer(
dictionary : &ChineseDictionary,
model : &ChineseHmmModel,
) -> TextAnalyzer {
@chinese.chinese_dag_hmm_search_index_analyzer(dictionary, model)
}
///|
/// Stable root-package facade for immutable Segment construction and access.
pub using @index {type Posting, type SegmentWriter, type Segment}
///|
/// Stable root-package facade for query construction, scoring, and search.
pub using @query {
trait Query,
trait Weight,
trait Scorer,
type TermQuery,
type BoostQuery,
type Occur,
type BooleanClause,
type BooleanQuery,
type PhraseQuery,
type QueryParser,
type SearchStatistics,
type Bm25Scorer,
type SearchHit,
type TopKCollector,
type Searcher,
}
///|
/// Stable root-package facade for directory-backed index lifecycle APIs.
pub using @store {
trait Directory,
type MemoryDirectory,
type FsDirectory,
type IndexWriter,
type IndexReader,
}