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.
Token
s are typically stored as vertices in a
DepGraph
, so that their dependency heads
and dependents can be queried.
Implementations
sourceimpl Token
impl Token
sourcepub fn new(form: impl Into<String>) -> Token
pub fn new(form: impl Into<String>) -> Token
Create a new token where all the non-form fields are absent.
sourcepub fn features(&self) -> &Features
pub fn features(&self) -> &Features
Get the syntactic and/or morphological features of the token.
sourcepub fn features_mut(&mut self) -> &mut Features
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.
sourcepub fn deps(&self) -> Option<&str>
pub fn deps(&self) -> Option<&str>
Get enhanced dependencies.
Warning: this method will be removed once proper support for enhanced dependencies is added.
sourcepub fn misc_mut(&mut self) -> &mut Misc
pub fn misc_mut(&mut self) -> &mut Misc
Get miscellaneous token features.
Returns a mutable reference, so that the information can be updated.
sourcepub fn set_form(&mut self, form: impl Into<String>) -> String
pub fn set_form(&mut self, form: impl Into<String>) -> String
Set the word form or punctuation symbol.
Returns the form that is replaced.
sourcepub fn set_lemma<S>(&mut self, lemma: Option<S>) -> Option<String> where
S: Into<String>,
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.
sourcepub fn set_upos<S>(&mut self, upos: Option<S>) -> Option<String> where
S: Into<String>,
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.
sourcepub fn set_xpos<S>(&mut self, xpos: Option<S>) -> Option<String> where
S: Into<String>,
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.
sourcepub fn set_features(&mut self, features: Features) -> Features
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.
Trait Implementations
sourceimpl From<Token> for TokenBuilder
impl From<Token> for TokenBuilder
sourceimpl From<TokenBuilder> for Token
impl From<TokenBuilder> for Token
sourcefn from(builder: TokenBuilder) -> Self
fn from(builder: TokenBuilder) -> Self
Converts to this type from the input type.
sourceimpl FromIterator<Token> for Sentence
impl FromIterator<Token> for Sentence
sourcefn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = Token>,
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = Token>,
Creates a value from an iterator. Read more
impl Eq for Token
impl StructuralEq for Token
impl StructuralPartialEq for Token
Auto Trait Implementations
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more