Struct TokenBuilder

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

A builder for Tokens.

The Token type stores a CoNLL-U token. However, since this format permits a large number of fields, construction of a token can get tedious. This builder provides a fluent interface for creating Token instances.

Implementations§

Source§

impl TokenBuilder

Source

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

Create a TokenBuilder with all non-form fields set to absent.

Source

pub fn form(self, form: impl Into<String>) -> TokenBuilder

Set the word form or punctuation symbol.

Source

pub fn lemma(self, lemma: impl Into<String>) -> TokenBuilder

Set the lemma or stem of the word form.

Source

pub fn upos(self, upos: impl Into<String>) -> TokenBuilder

Set the universal part-of-speech tag.

Source

pub fn xpos(self, xpos: impl Into<String>) -> TokenBuilder

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

Source

pub fn features(self, features: Features) -> TokenBuilder

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

Source

pub fn deps(self, deps: impl Into<String>) -> TokenBuilder

Set UD enhanced dependencies.

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

Source

pub fn misc(self, misc: Misc) -> TokenBuilder

Set miscellaneous token features.

Trait Implementations§

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.

Auto Trait Implementations§

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.