sudachi::plugin::path_rewrite

Trait PathRewritePlugin

source
pub trait PathRewritePlugin: Sync + Send {
    // Required methods
    fn set_up(
        &mut self,
        settings: &Value,
        config: &Config,
        grammar: &Grammar<'_>,
    ) -> SudachiResult<()>;
    fn rewrite(
        &self,
        text: &InputBuffer,
        path: Vec<ResultNode>,
        lattice: &Lattice,
    ) -> SudachiResult<Vec<ResultNode>>;
}
Expand description

Trait of plugin to rewrite the path from lattice

Required Methods§

source

fn set_up( &mut self, settings: &Value, config: &Config, grammar: &Grammar<'_>, ) -> SudachiResult<()>

Loads necessary information for the plugin

source

fn rewrite( &self, text: &InputBuffer, path: Vec<ResultNode>, lattice: &Lattice, ) -> SudachiResult<Vec<ResultNode>>

Returns a rewritten path

Trait Implementations§

source§

impl PluginCategory for dyn PathRewritePlugin

source§

type BoxType = Box<dyn PathRewritePlugin + Sync + Send>

Boxed type of the plugin. Should be Box.
source§

type InitFnType = unsafe fn() -> Result<<dyn PathRewritePlugin as PluginCategory>::BoxType, SudachiError>

Type of the initialization function. It must take 0 arguments and return SudachiResult<Self::BoxType>.
source§

fn configurations(cfg: &Config) -> &[Value]

Extract plugin configurations from the config
source§

fn bundled_impl(name: &str) -> Option<Self::BoxType>

Create bundled plugin for plugin name Instead of full name like com.worksap.nlp.sudachi.ProlongedSoundMarkPlugin should handle only the short one: ProlongedSoundMarkPlugin Read more
source§

fn do_setup( ptr: &mut Self::BoxType, settings: &Value, config: &Config, grammar: &mut Grammar<'_>, ) -> SudachiResult<()>

Perform initial setup. We can’t call set_up of the plugin directly in the default implementation of this method because we do not know the specific type yet

Implementors§