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§
Source§impl 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>
pub fn set_lemma<S>(&mut self, lemma: Option<S>) -> Option<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>
pub fn set_upos<S>(&mut self, upos: Option<S>) -> Option<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>
pub fn set_xpos<S>(&mut self, xpos: Option<S>) -> Option<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§
Source§impl From<Token> for TokenBuilder
impl From<Token> for TokenBuilder
Source§impl From<TokenBuilder> for Token
impl From<TokenBuilder> for Token
Source§fn from(builder: TokenBuilder) -> Self
fn from(builder: TokenBuilder) -> Self
Source§impl FromIterator<Token> for Sentence
impl FromIterator<Token> for Sentence
impl Eq for Token
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.