Skip to main content

FeatureSet

Struct FeatureSet 

Source
pub struct FeatureSet { /* private fields */ }
Expand description

The groups of features a model uses.

A feature set is data of a model, as the template of the chunker is: the features of training and of parsing are made from the same value, and two sets are compared without a change of code. It is written as the names of its groups with commas, as in distance,source,target,gap.

A set can also limit the levels of the part of speech its features take (FeatureSet::with_part_of_speech_levels), written after the groups as in distance,source,pos-levels=2. Without a limit the features take every level of the schema.

Implementations§

Source§

impl FeatureSet

Source

pub fn new(groups: &[Group]) -> Result<Self>

Makes a feature set of groups.

§Arguments
  • groups - The groups, in any order.
§Returns

The set, or Error::Parser for no group or a group given twice.

Source

pub fn with_part_of_speech_levels(self, levels: usize) -> Result<Self>

Limits the levels of the part of speech the features take.

The features of a morpheme name the levels of its part of speech (HP0:名詞, HP1:普通名詞), and the feature of a bunsetsu that ends in a word without a conjugation form is its part of speech, the levels joined (A:名詞-普通名詞). With a limit, both stop at that many levels, though the schema has more: the chunker and the patterns of the schema still read all of them. CaboCha reads two levels of UniDic in its parser and four in its chunker.

§Arguments
  • levels - The number of levels, 1 or more.
§Returns

The set with the limit, or Error::Parser for 0.

§Examples
use lindera_dependency::parser::FeatureSet;

let set = FeatureSet::cabocha().with_part_of_speech_levels(2)?;
assert_eq!(set.part_of_speech_levels(), Some(2));
assert_eq!(
    set.to_string(),
    "distance,source,target,left,right,children,gap,pos-levels=2"
);
assert_eq!(FeatureSet::parse(&set.to_string())?, set);
Source

pub fn part_of_speech_levels(&self) -> Option<usize>

The limit of the levels of the part of speech.

§Returns

The number of levels the features take, or None for every level of the schema.

Source

pub fn cabocha() -> Self

The feature set of CaboCha: every group but Group::AfterHead.

§Returns

The set.

Source

pub fn parse(text: &str) -> Result<Self>

Reads a feature set from its text.

§Arguments
§Returns

The set, or Error::Parser for a name that is not a group, no group, a group given twice, or a limit that is not a number of 1 or more, or is given twice.

Source

pub fn groups(&self) -> &[Group]

The groups of the set.

§Returns

The groups, in the order distance, source, target, left, right, children, gap, after.

Source

pub fn has(&self, group: Group) -> bool

Whether the set has a group.

§Arguments
  • group - The group.
§Returns

Whether the features of the group are made.

Trait Implementations§

Source§

impl Clone for FeatureSet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FeatureSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FeatureSet

Source§

fn default() -> Self

Every group: the feature set of CaboCha and Group::AfterHead, which is what a model is trained with unless another set is given.

Source§

impl Display for FeatureSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Writes the names of the groups with commas, and the limit of the levels of the part of speech after them when the set has one: the text FeatureSet::parse reads.

Source§

impl Eq for FeatureSet

Source§

impl PartialEq for FeatureSet

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FeatureSet

Auto Trait Implementations§

§

impl Forget for FeatureSet

§

impl Freeze for FeatureSet

§

impl Move for FeatureSet

§

impl RefUnwindSafe for FeatureSet

§

impl Send for FeatureSet
where RawVecInner: Send,

§

impl Sync for FeatureSet
where RawVecInner: Sync,

§

impl Unpin for FeatureSet
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for FeatureSet

§

impl UnwindSafe for FeatureSet
where RawVecInner: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.