TokenKind

Enum TokenKind 

Source
pub enum TokenKind {
    Word(Option<WordMetadata>),
    Punctuation(Punctuation),
    Decade,
    Number(Number),
    Space(usize),
    Newline(usize),
    EmailAddress,
    Url,
    Hostname,
    Unlintable,
    ParagraphBreak,
    Regexish,
}
Expand description

The parsed value of a Token. Has a variety of queries available. If there is a query missing, it may be easy to implement by just calling the delegate_to_metadata macro.

Variants§

§

Word(Option<WordMetadata>)

None if the word does not exist in the dictionary.

§

Punctuation(Punctuation)

§

Decade

§

Number(Number)

§

Space(usize)

A sequence of “ “ spaces.

§

Newline(usize)

A sequence of “\n” newlines

§

EmailAddress

§

Url

§

Hostname

§

Unlintable

A special token used for things like inline code blocks that should be ignored by all linters.

§

ParagraphBreak

§

Regexish

Implementations§

Source§

impl TokenKind

Source

pub const fn is_word(&self) -> bool

Returns true if self is of variant Word.

Source

pub fn as_word(&self) -> Option<&Option<WordMetadata>>

Returns Some if self is a reference of variant Word, and None otherwise.

Source

pub fn as_mut_word(&mut self) -> Option<&mut Option<WordMetadata>>

Returns Some if self is a mutable reference of variant Word, and None otherwise.

Source

pub fn expect_word(self) -> Option<WordMetadata>
where Self: Debug,

Unwraps the value, yielding the content of Word.

§Panics

Panics if the value is not Word, with a panic message including the content of self.

Source

pub fn word(self) -> Option<Option<WordMetadata>>

Returns Some if self is of variant Word, and None otherwise.

Source

pub const fn is_punctuation(&self) -> bool

Returns true if self is of variant Punctuation.

Source

pub fn as_punctuation(&self) -> Option<&Punctuation>

Returns Some if self is a reference of variant Punctuation, and None otherwise.

Source

pub fn as_mut_punctuation(&mut self) -> Option<&mut Punctuation>

Returns Some if self is a mutable reference of variant Punctuation, and None otherwise.

Source

pub fn expect_punctuation(self) -> Punctuation
where Self: Debug,

Unwraps the value, yielding the content of Punctuation.

§Panics

Panics if the value is not Punctuation, with a panic message including the content of self.

Source

pub fn punctuation(self) -> Option<Punctuation>

Returns Some if self is of variant Punctuation, and None otherwise.

Source

pub const fn is_decade(&self) -> bool

Returns true if self is of variant Decade.

Source

pub const fn is_number(&self) -> bool

Returns true if self is of variant Number.

Source

pub fn as_number(&self) -> Option<&Number>

Returns Some if self is a reference of variant Number, and None otherwise.

Source

pub fn as_mut_number(&mut self) -> Option<&mut Number>

Returns Some if self is a mutable reference of variant Number, and None otherwise.

Source

pub fn expect_number(self) -> Number
where Self: Debug,

Unwraps the value, yielding the content of Number.

§Panics

Panics if the value is not Number, with a panic message including the content of self.

Source

pub fn number(self) -> Option<Number>

Returns Some if self is of variant Number, and None otherwise.

Source

pub const fn is_space(&self) -> bool

Returns true if self is of variant Space.

Source

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

Returns Some if self is a reference of variant Space, and None otherwise.

Source

pub fn as_mut_space(&mut self) -> Option<&mut usize>

Returns Some if self is a mutable reference of variant Space, and None otherwise.

Source

pub fn expect_space(self) -> usize
where Self: Debug,

Unwraps the value, yielding the content of Space.

§Panics

Panics if the value is not Space, with a panic message including the content of self.

Source

pub fn space(self) -> Option<usize>

Returns Some if self is of variant Space, and None otherwise.

Source

pub const fn is_newline(&self) -> bool

Returns true if self is of variant Newline.

Source

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

Returns Some if self is a reference of variant Newline, and None otherwise.

Source

pub fn as_mut_newline(&mut self) -> Option<&mut usize>

Returns Some if self is a mutable reference of variant Newline, and None otherwise.

Source

pub fn expect_newline(self) -> usize
where Self: Debug,

Unwraps the value, yielding the content of Newline.

§Panics

Panics if the value is not Newline, with a panic message including the content of self.

Source

pub fn newline(self) -> Option<usize>

Returns Some if self is of variant Newline, and None otherwise.

Source

pub const fn is_email_address(&self) -> bool

Returns true if self is of variant EmailAddress.

Source

pub const fn is_url(&self) -> bool

Returns true if self is of variant Url.

Source

pub const fn is_hostname(&self) -> bool

Returns true if self is of variant Hostname.

Source

pub const fn is_unlintable(&self) -> bool

Returns true if self is of variant Unlintable.

Source

pub const fn is_paragraph_break(&self) -> bool

Returns true if self is of variant ParagraphBreak.

Source

pub const fn is_regexish(&self) -> bool

Returns true if self is of variant Regexish.

Source§

impl TokenKind

Source

pub fn is_nominal(&self) -> bool

Delegates to WordMetadata::is_nominal when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_noun(&self) -> bool

Delegates to WordMetadata::is_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_pronoun(&self) -> bool

Delegates to WordMetadata::is_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_proper_noun(&self) -> bool

Delegates to WordMetadata::is_proper_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_singular_nominal(&self) -> bool

Delegates to WordMetadata::is_singular_nominal when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_plural_nominal(&self) -> bool

Delegates to WordMetadata::is_plural_nominal when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_possessive_nominal(&self) -> bool

Delegates to WordMetadata::is_possessive_nominal when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_non_plural_nominal(&self) -> bool

Delegates to WordMetadata::is_non_plural_nominal when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_singular_noun(&self) -> bool

Delegates to WordMetadata::is_singular_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_plural_noun(&self) -> bool

Delegates to WordMetadata::is_plural_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_non_plural_noun(&self) -> bool

Delegates to WordMetadata::is_non_plural_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_countable_noun(&self) -> bool

Delegates to WordMetadata::is_countable_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_non_countable_noun(&self) -> bool

Delegates to WordMetadata::is_non_countable_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_mass_noun(&self) -> bool

Delegates to WordMetadata::is_mass_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_mass_noun_only(&self) -> bool

Delegates to WordMetadata::is_mass_noun_only when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_non_mass_noun(&self) -> bool

Delegates to WordMetadata::is_non_mass_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_singular_pronoun(&self) -> bool

Delegates to WordMetadata::is_singular_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_plural_pronoun(&self) -> bool

Delegates to WordMetadata::is_plural_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_non_plural_pronoun(&self) -> bool

Delegates to WordMetadata::is_non_plural_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_reflexive_pronoun(&self) -> bool

Delegates to WordMetadata::is_reflexive_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_first_person_singular_pronoun(&self) -> bool

Delegates to WordMetadata::is_first_person_singular_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_first_person_plural_pronoun(&self) -> bool

Delegates to WordMetadata::is_first_person_plural_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_second_person_pronoun(&self) -> bool

Delegates to WordMetadata::is_second_person_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_third_person_pronoun(&self) -> bool

Delegates to WordMetadata::is_third_person_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_third_person_singular_pronoun(&self) -> bool

Delegates to WordMetadata::is_third_person_singular_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_third_person_plural_pronoun(&self) -> bool

Delegates to WordMetadata::is_third_person_plural_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_object_pronoun(&self) -> bool

Delegates to WordMetadata::is_object_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_possessive_noun(&self) -> bool

Delegates to WordMetadata::is_possessive_noun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_possessive_pronoun(&self) -> bool

Delegates to WordMetadata::is_possessive_pronoun when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_verb(&self) -> bool

Delegates to WordMetadata::is_verb when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_auxiliary_verb(&self) -> bool

Delegates to WordMetadata::is_auxiliary_verb when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_linking_verb(&self) -> bool

Delegates to WordMetadata::is_linking_verb when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_verb_lemma(&self) -> bool

Delegates to WordMetadata::is_verb_lemma when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_verb_past_form(&self) -> bool

Delegates to WordMetadata::is_verb_past_form when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_verb_progressive_form(&self) -> bool

Delegates to WordMetadata::is_verb_progressive_form when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_verb_third_person_singular_present_form(&self) -> bool

Delegates to WordMetadata::is_verb_third_person_singular_present_form when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_adjective(&self) -> bool

Delegates to WordMetadata::is_adjective when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_comparative_adjective(&self) -> bool

Delegates to WordMetadata::is_comparative_adjective when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_superlative_adjective(&self) -> bool

Delegates to WordMetadata::is_superlative_adjective when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_positive_adjective(&self) -> bool

Delegates to WordMetadata::is_positive_adjective when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_adverb(&self) -> bool

Delegates to WordMetadata::is_adverb when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_determiner(&self) -> bool

Delegates to WordMetadata::is_determiner when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_demonstrative_determiner(&self) -> bool

Delegates to WordMetadata::is_demonstrative_determiner when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_possessive_determiner(&self) -> bool

Delegates to WordMetadata::is_possessive_determiner when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_quantifier(&self) -> bool

Delegates to WordMetadata::is_quantifier when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_non_quantifier_determiner(&self) -> bool

Delegates to WordMetadata::is_non_quantifier_determiner when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_conjunction(&self) -> bool

Delegates to WordMetadata::is_conjunction when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_swear(&self) -> bool

Delegates to WordMetadata::is_swear when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_likely_homograph(&self) -> bool

Delegates to WordMetadata::is_likely_homograph when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_lowercase(&self) -> bool

Delegates to WordMetadata::is_lowercase when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_titlecase(&self) -> bool

Delegates to WordMetadata::is_titlecase when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_allcaps(&self) -> bool

Delegates to WordMetadata::is_allcaps when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_lower_camel(&self) -> bool

Delegates to WordMetadata::is_lower_camel when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_upper_camel(&self) -> bool

Delegates to WordMetadata::is_upper_camel when this token is a word.

Returns false if the token is not a word.

Source

pub fn is_preposition(&self) -> bool

Source

pub fn is_common_word(&self) -> bool

Source

pub fn is_oov(&self) -> bool

Checks whether a word token is out-of-vocabulary (not found in the dictionary).

Returns true if the token is a word that was not found in the dictionary, false if the token is a word found in the dictionary or is not a word token.

Source

pub fn is_open_square(&self) -> bool

Source

pub fn is_close_square(&self) -> bool

Source

pub fn is_open_round(&self) -> bool

Source

pub fn is_close_round(&self) -> bool

Source

pub fn is_pipe(&self) -> bool

Source

pub fn is_currency(&self) -> bool

Source

pub fn is_ellipsis(&self) -> bool

Source

pub fn is_hyphen(&self) -> bool

Source

pub fn is_quote(&self) -> bool

Source

pub fn is_apostrophe(&self) -> bool

Source

pub fn is_period(&self) -> bool

Source

pub fn is_at(&self) -> bool

Source

pub fn is_comma(&self) -> bool

Source

pub fn is_semicolon(&self) -> bool

Source

pub fn is_ampersand(&self) -> bool

Source

pub fn is_word_like(&self) -> bool

Checks whether a token is word-like–meaning it is more complex than punctuation and can hold semantic meaning in the way a word does.

Source

pub fn is_case_separator(&self) -> bool

Used by crate::parsers::CollapseIdentifiers TODO: Separate this into two functions and add OR functionality to pattern matching

Source

pub fn is_whitespace(&self) -> bool

Checks whether the token is whitespace.

Source

pub fn is_upos(&self, upos: UPOS) -> bool

Source

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

Checks that self is the same enum variant as other, regardless of whether the inner metadata is also equal.

Source

pub fn with_default_data(&self) -> Self

Produces a copy of self with any inner data replaced with its default value. Useful for making comparisons on just the variant of the enum.

Source

pub fn blank_word() -> Self

Construct a TokenKind::Word with no metadata.

Source

pub fn as_mut_quote(&mut self) -> Option<&mut Quote>

Source

pub fn as_quote(&self) -> Option<&Quote>

Trait Implementations§

Source§

impl Clone for TokenKind

Source§

fn clone(&self) -> TokenKind

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 TokenKind

Source§

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

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

impl Default for TokenKind

Source§

fn default() -> TokenKind

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TokenKind

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for TokenKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TokenKind

Source§

fn eq(&self, other: &TokenKind) -> 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 PartialOrd for TokenKind

Source§

fn partial_cmp(&self, other: &TokenKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for TokenKind

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for TokenKind

Source§

impl StructuralPartialEq for TokenKind

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> 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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> LSend for T
where T: ?Sized,