Skip to main content

Lattice

Struct Lattice 

Source
pub struct Lattice<'a> { /* private fields */ }
Expand description

A MeCab lattice representing a search space for morphological analysis. It wraps C mecab_lattice_t.

The lifetime parameter is bound to Model.

Implementations§

Source§

impl<'a> Lattice<'a>

Source

pub fn as_ptr(&self) -> *mut mecab_lattice_t

Returns the raw pointer to the underlying mecab_lattice_t.

The pointer is guaranteed to be NonNull.

Source

pub fn new(model: &'a Model) -> Result<Self, Error>

Creates a new Lattice from a Model.

It wraps mecab_model_new_lattice(), the wrapper of MeCab::Model::createLattice().

Source

pub fn set_sentence<'l, 's>( &'l mut self, s: &'s str, ) -> LatticeGuard<'a, 'l, 's>

Sets the sentence to be analyzed and returns a LatticeGuard.

It wraps mecab_lattice_set_sentence2(), the wrapper of MeCab::Lattice::set_sentence(sentence, len).

Since the analysis result is borrowed from the input s, the input should be captured in a LatticeGuard during analysis.

Source

pub fn clear(&mut self)

Clears the lattice.

It wraps mecab_lattice_clear(), the wrapper of MeCab::Lattice::clear().

Source

pub fn is_available(&self) -> bool

Returns true if the lattice is available.

It wraps mecab_lattice_is_available(), the wrapper of MeCab::Lattice::is_available().

Source

pub fn crf_norm_factor(&self) -> f64

Returns the CRF normalization factor.

It wraps mecab_lattice_get_z(), the wrapper of MeCab::Lattice::Z().

Source

pub fn set_crf_norm_factor(&mut self, z: f64)

Sets the CRF normalization factor.

It wraps mecab_lattice_set_z(), the wrapper of MeCab::Lattice::set_Z().

Source

pub fn temparature(&self) -> f64

Returns the temperature parameter.

It wraps mecab_lattice_get_theta(), the wrapper of MeCab::Lattice::theta().

Source

pub fn set_temparature(&mut self, theta: f64)

Sets the temperature parameter.

It wraps mecab_lattice_set_theta(), the wrapper of MeCab::Lattice::set_theta().

Source

pub fn request_type(&self) -> RequestType

Returns the request type flags.

It wraps mecab_lattice_get_request_type(), the wrapper of MeCab::Lattice::request_type().

Source

pub fn set_request_type(&mut self, request_type: RequestType)

Sets the request type flags.

It wraps mecab_lattice_set_request_type(), the wrapper of MeCab::Lattice::set_request_type().

Source

pub fn boundary_constraint(&self, pos: usize) -> BoundaryConstraintType

Returns the boundary constraint at the given position.

It wraps mecab_lattice_get_boundary_constraint(), the wrapper of MeCab::Lattice::boundary_constraint(pos).

Source

pub fn set_boundary_constraint( &mut self, pos: usize, constraint: BoundaryConstraintType, )

Sets the boundary constraint at the given position.

It wraps mecab_lattice_set_boundary_constraint(), the wrapper of MeCab::Lattice::boundary_constraint(pos, type).

Trait Implementations§

Source§

impl<'a> AsMut<Lattice<'a>> for LatticeGuard<'a, '_, '_>

Source§

fn as_mut(&mut self) -> &mut Lattice<'a>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<'a> AsRef<Lattice<'a>> for LatticeGuard<'a, '_, '_>

Source§

fn as_ref(&self) -> &Lattice<'a>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Drop for Lattice<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for Lattice<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for Lattice<'a>

§

impl<'a> RefUnwindSafe for Lattice<'a>

§

impl<'a> !Sync for Lattice<'a>

§

impl<'a> Unpin for Lattice<'a>

§

impl<'a> UnsafeUnpin for Lattice<'a>

§

impl<'a> UnwindSafe for Lattice<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.