Deterministic Chinese Pinyin normalization and text matching toolkit for MoonBit
pub struct AlignmentStep {
kind_value : AlignmentKind
left_start_value : Int
left_end_value : Int
right_start_value : Int
right_end_value : Int
left_fragment_value : String
right_fragment_value : String
cost_value : Double
} derive(Eq, Debug)pub(all) enum BatchOutcome {
BatchSucceeded(ConversionResult)
BatchFailed(PinyinError)
} derive(Eq, Debug)pub struct BatchResult {
item_values : Array[BatchItemResult]
summary_value : ConversionSummary
} derive(Eq, Debug)pub struct ConversionResult {
source_value : String
rendered_value : String
token_values : Array[ConvertedToken]
diagnostic_values : Array[Diagnostic]
} derive(Eq, Debug)pub struct ConvertOptions {
output_style : ToneStyle
token_separator : String
output_case : TextCase
unknown_behavior : UnknownPolicy
ambiguity_behavior : AmbiguityPolicy
} derive(Eq, Debug)pub struct ConvertedToken {
original_value : String
rendered_value : String
token_kind : TokenKind
decision_value : DecisionSource
source_span : SourceSpan
candidate_values : Array[String]
} derive(Eq, Debug)pub struct Diagnostic {
code_value : String
message_value : String
source_span : SourceSpan?
} derive(Eq, Debug)pub struct FuzzyProfile {
insertion_value : Double
deletion_value : Double
substitution_value : Double
equivalence_value : Double
rule_values : FuzzyRules
} derive(Eq, Debug)pub struct IndexKey {
key_text : String
profile_value : IndexProfile
segment_values : Array[IndexSegment]
} derive(Eq, Debug)pub struct IndexSegment {
value_text : String
source_span : SourceSpan
source_kind : TokenKind
} derive(Eq, Debug)fn LexiconBuilder::add(self : LexiconBuilder, phrase : String, readings : Array[String]) -> Result[Unit, PinyinError]pub struct MatchExplanation {
query_text : String
full_key_text : String
initials_key_text : String
exact_value : Double
prefix_value : Double
initials_value : Double
fuzzy_value : Double
final_value : Double
distance_value : DistanceResult
} derive(Eq, Debug)pub struct PinyinAlignment {
left_normalized_value : String
right_normalized_value : String
step_values : Array[AlignmentStep]
total_cost_value : Double
match_count : Int
insertion_count : Int
deletion_count : Int
substitution_count : Int
equivalence_count : Int
} derive(Eq, Debug)pub(all) enum PinyinError {
InvalidSeparator(String)
InvalidSyllable(String, String)
UnknownCharacter(Int)
AmbiguousCharacter(Int, Int)
InvalidSourceSpan(Int, Int)
InvalidLexiconEntry(String, String)
ConflictingLexiconEntry(String)
InvalidLexiconText(String)
InvalidBatchItem(String, String)
InvalidSearchDocument(String, String)
InvalidSearchOptions(String, String)
InvalidSearchQuery(String)
InvalidVariantLimit(Int)
InvalidConversionResult(String)
InvalidAlignment(String)
InvalidWeight(String, Double)
InvalidGeneratedData(String)
} derive(Eq, Debug)pub struct PinyinProcessor {
lexicon_value : Lexicon
conversion_value : ConvertOptions
fuzzy_value : FuzzyProfile
}fn PinyinProcessor::candidate(self : PinyinProcessor, identifier : String, source : String) -> Result[MatchCandidate, PinyinError]fn PinyinProcessor::compare(self : PinyinProcessor, left : String, right : String) -> Result[TextComparison, PinyinError]fn PinyinProcessor::convert(self : PinyinProcessor, source : String) -> Result[ConversionResult, PinyinError]fn PinyinProcessor::variants(self : PinyinProcessor, source : String, style : ToneStyle, separator : String, limit : Int) -> Result[VariantExpansion, PinyinError]pub struct RankedCandidate {
candidate_value : MatchCandidate
explanation_value : MatchExplanation
caller_position : Int
} derive(Eq, Debug)pub struct ReadingInspection {
entry_values : Array[ScalarReadingEvidence]
known_value : Int
unknown_value : Int
ambiguous_value : Int
} derive(Eq, Debug)pub struct ScalarReadingEvidence {
code_value : Int
original_value : String
source_span : SourceSpan
candidate_values : Array[String]
} derive(Eq, Debug)pub struct SearchHit {
identifier_value : String
source_value : String
explanation_value : MatchExplanation
source_position : Int
} derive(Eq, Debug)fn SearchIndex::search(self : SearchIndex, query : String, options : SearchOptions, profile : FuzzyProfile) -> Result[Array[SearchHit], PinyinError]fn SearchIndexBuilder::add(self : SearchIndexBuilder, identifier : String, source : String, lexicon : Lexicon, options : ConvertOptions) -> Result[Unit, PinyinError]pub struct Syllable {
base_value : String
initial_value : String
final_value : String
tone_value : Int
input_form : Orthography
} derive(Eq, Debug)pub struct TextComparison {
left_result : ConversionResult
right_result : ConversionResult
left_key_value : String
right_key_value : String
left_initials_value : String
right_initials_value : String
distance_value : DistanceResult
similarity_value : Double
forward_score_value : MatchExplanation
reverse_score_value : MatchExplanation
} derive(Eq, Debug)fn align_pinyin(left_input : String, right_input : String, profile : FuzzyProfile) -> PinyinAlignmentfn compare_texts(left_source : String, right_source : String, lexicon : Lexicon, options : ConvertOptions, profile : FuzzyProfile) -> Result[TextComparison, PinyinError]fn convert_batch(items : Array[BatchItem], lexicon : Lexicon, options : ConvertOptions) -> BatchResultfn convert_options(style : ToneStyle, separator : String, text_case : TextCase, unknown_policy : UnknownPolicy, ambiguity_policy : AmbiguityPolicy) -> Result[ConvertOptions, PinyinError]fn convert_text(source : String, lexicon : Lexicon, options : ConvertOptions) -> Result[ConversionResult, PinyinError]fn expand_conversion_variants(result : ConversionResult, style : ToneStyle, separator : String, limit : Int) -> Result[VariantExpansion, PinyinError]fn fuzzy_profile(insertion : Double, deletion : Double, substitution : Double, equivalence : Double) -> Result[FuzzyProfile, PinyinError]fn fuzzy_profile_with_rules(insertion : Double, deletion : Double, substitution : Double, equivalence : Double, rules : FuzzyRules) -> Result[FuzzyProfile, PinyinError]fn pinyin_processor(lexicon : Lexicon, options : ConvertOptions, fuzzy : FuzzyProfile) -> PinyinProcessorfn rank_matches(query : String, candidates : Array[MatchCandidate], profile : FuzzyProfile) -> Array[RankedCandidate]fn score_match(query_input : String, candidate : MatchCandidate, profile : FuzzyProfile) -> MatchExplanationfn unihan_data_license() -> Stringfn unihan_entry_total() -> Intfn unihan_source_sha256() -> Stringfn unihan_version() -> Stringfn validate_conversion_result(result : ConversionResult) -> Result[ConversionIntegrity, PinyinError]fn validate_pinyin_alignment(alignment : PinyinAlignment, profile : FuzzyProfile) -> Result[AlignmentIntegrity, PinyinError]fn weighted_pinyin_distance(left_input : String, right_input : String, profile : FuzzyProfile) -> DistanceResultDeterministic Chinese Pinyin normalization and text matching toolkit for MoonBit