Struct Token

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

Token

The Token type stores a CoNLL-U token. Various information can be associated with a token, such as its lemma, (universal) part-of-speech, morphological features, and other (miscellaneous) features.

Tokens are typically stored as vertices in a DepGraph, so that their dependency heads and dependents can be queried.

Implementations§

Source§

impl Token

Source

pub fn new(form: impl Into<String>) -> Token

Create a new token where all the non-form fields are absent.

Source

pub fn form(&self) -> &str

Get the word form or punctuation symbol.

Source

pub fn lemma(&self) -> Option<&str>

Get the lemma or stem of the word form.

Source

pub fn upos(&self) -> Option<&str>

Get the universal part-of-speech tag.

Source

pub fn xpos(&self) -> Option<&str>

Get the language-specific part-of-speech tag.

Source

pub fn features(&self) -> &Features

Get the syntactic and/or morphological features of the token.

Source

pub fn features_mut(&mut self) -> &mut Features

Get the syntactic and/or morphological features of the token.

Returns a mutable reference, so that the features can be updated.

Source

pub fn deps(&self) -> Option<&str>

Get enhanced dependencies.

Warning: this method will be removed once proper support for enhanced dependencies is added.

Source

pub fn misc(&self) -> &Misc

Get miscellaneous token features.

Source

pub fn misc_mut(&mut self) -> &mut Misc

Get miscellaneous token features.

Returns a mutable reference, so that the information can be updated.

Source

pub fn set_form(&mut self, form: impl Into<String>) -> String

Set the word form or punctuation symbol.

Returns the form that is replaced.

Source

pub fn set_lemma<S>(&mut self, lemma: Option<S>) -> Option<String>
where S: Into<String>,

Set the lemma or stem of the word form.

Returns the lemma that is replaced.

Source

pub fn set_upos<S>(&mut self, upos: Option<S>) -> Option<String>
where S: Into<String>,

Set the universal part-of-speech tag.

Returns the universal part-of-speech tag that is replaced.

Source

pub fn set_xpos<S>(&mut self, xpos: Option<S>) -> Option<String>
where S: Into<String>,

Set the language-specific part-of-speech tag.

Returns the language-specific part-of-speech tag that is replaced.

Source

pub fn set_features(&mut self, features: Features) -> Features

Set the syntactic and/or morphological features of the token.

Returns the features that are replaced.

Source

pub fn set_deps(&mut self, deps: Option<impl Into<String>>) -> Option<String>

Set UD enhanced dependencies.

Warning: this method will be removed once proper support for enhanced dependencies is added.

Source

pub fn set_misc(&mut self, misc: Misc) -> Misc

Set miscellaneous token features.

Returns the features that are replaced.

Trait Implementations§

Source§

impl Clone for Token

Source§

fn clone(&self) -> Token

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Token

Source§

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

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

impl From<Token> for TokenBuilder

Source§

fn from(token: Token) -> Self

Converts to this type from the input type.
Source§

impl From<TokenBuilder> for Token

Source§

fn from(builder: TokenBuilder) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Token> for Sentence

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = Token>,

Creates a value from an iterator. Read more
Source§

impl PartialEq for Token

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Token

Source§

impl StructuralPartialEq for Token

Auto Trait Implementations§

§

impl Freeze for Token

§

impl RefUnwindSafe for Token

§

impl Send for Token

§

impl Sync for Token

§

impl Unpin for Token

§

impl UnwindSafe for Token

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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, 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.