Skip to main content

HanjaDictionary

Trait HanjaDictionary 

Source
pub trait HanjaDictionary {
    // Required method
    fn matches_at<'a>(
        &'a self,
        s: &'a str,
    ) -> Box<dyn Iterator<Item = Match> + 'a>;

    // Provided methods
    fn max_word_chars(&self) -> Option<usize> { ... }
    fn entries<'a>(
        &'a self,
    ) -> Option<Box<dyn Iterator<Item = DictionaryRecord> + 'a>> { ... }
    fn has_homophone(&self, hanja: &str, reading: &str) -> bool { ... }
}
Expand description

A hanja dictionary queried by the conversion engine.

The key operation returns every entry that starts at the beginning of the supplied string. This shape supports lattice segmentation because the engine must consider every candidate path through a hanja run.

Required Methods§

Source

fn matches_at<'a>(&'a self, s: &'a str) -> Box<dyn Iterator<Item = Match> + 'a>

Yields every dictionary match that starts at the beginning of s.

Provided Methods§

Source

fn max_word_chars(&self) -> Option<usize>

Returns the greatest dictionary entry length in Unicode scalar values.

Source

fn entries<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = DictionaryRecord> + 'a>>

Enumerates complete dictionary entries when the backend supports it.

The default returns None, which keeps custom lookup-only dictionaries valid. Homophone-aware middlewares use this as an optional batch path so built-in backends can avoid per-token full-dictionary scans.

Source

fn has_homophone(&self, hanja: &str, reading: &str) -> bool

Returns whether another hanja spelling has the same hangul reading.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<D> HanjaDictionary for &D
where D: HanjaDictionary + ?Sized,

Source§

fn matches_at<'a>(&'a self, s: &'a str) -> Box<dyn Iterator<Item = Match> + 'a>

Source§

fn max_word_chars(&self) -> Option<usize>

Source§

fn entries<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = DictionaryRecord> + 'a>>

Source§

fn has_homophone(&self, hanja: &str, reading: &str) -> bool

Source§

impl<D> HanjaDictionary for Box<D>
where D: HanjaDictionary + ?Sized,

Source§

fn matches_at<'a>(&'a self, s: &'a str) -> Box<dyn Iterator<Item = Match> + 'a>

Source§

fn max_word_chars(&self) -> Option<usize>

Source§

fn entries<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = DictionaryRecord> + 'a>>

Source§

fn has_homophone(&self, hanja: &str, reading: &str) -> bool

Implementors§