Document

Struct Document 

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

A document containing some amount of lexed and parsed English text.

Implementations§

Source§

impl Document

Source

pub fn token_indices_intersecting(&self, span: Span<char>) -> Vec<usize>

Locate all the tokens that intersect a provided span.

Desperately needs optimization.

Source

pub fn fat_tokens_intersecting(&self, span: Span<char>) -> Vec<FatToken>

Locate all the tokens that intersect a provided span and convert them to FatTokens.

Desperately needs optimization.

Source

pub fn new( text: &str, parser: &impl Parser, dictionary: &impl Dictionary, ) -> Self

Lexes and parses text to produce a document using a provided language parser and dictionary.

Source

pub fn new_curated(text: &str, parser: &impl Parser) -> Self

Lexes and parses text to produce a document using a provided language parser and the included curated dictionary.

Source

pub fn new_from_vec( source: Lrc<Vec<char>>, parser: &impl Parser, dictionary: &impl Dictionary, ) -> Self

Lexes and parses text to produce a document using a provided language parser and dictionary.

Source

pub fn new_plain_english_curated(text: &str) -> Self

Parse text to produce a document using the built-in PlainEnglish parser and curated dictionary.

Source

pub fn new_plain_english(text: &str, dictionary: &impl Dictionary) -> Self

Parse text to produce a document using the built-in PlainEnglish parser and a provided dictionary.

Source

pub fn new_markdown_curated( text: &str, markdown_options: MarkdownOptions, ) -> Self

Parse text to produce a document using the built-in Markdown parser and curated dictionary.

Source

pub fn new_markdown_default_curated(text: &str) -> Self

Parse text to produce a document using the built-in Markdown parser and curated dictionary with the default Markdown configuration.

Source

pub fn new_markdown( text: &str, markdown_options: MarkdownOptions, dictionary: &impl Dictionary, ) -> Self

Parse text to produce a document using the built-in PlainEnglish parser and the curated dictionary.

Source

pub fn new_markdown_default(text: &str, dictionary: &impl Dictionary) -> Self

Parse text to produce a document using the built-in PlainEnglish parser and the curated dictionary with the default Markdown configuration.

Source

pub fn get_token_at_char_index(&self, char_index: usize) -> Option<&Token>

Source

pub fn get_token(&self, index: usize) -> Option<&Token>

Defensively attempt to grab a specific token.

Source

pub fn get_token_offset(&self, base: usize, offset: isize) -> Option<&Token>

Get a token at a signed offset from a base index, or None if out of bounds.

Source

pub fn tokens(&self) -> impl Iterator<Item = &Token> + '_

Get an iterator over all the tokens contained in the document.

Source

pub fn iter_nominal_phrases(&self) -> impl Iterator<Item = &[Token]>

Source

pub fn fat_tokens(&self) -> impl Iterator<Item = FatToken> + '_

Get an iterator over all the tokens contained in the document.

Source

pub fn get_next_word_from_offset( &self, base: usize, offset: isize, ) -> Option<&Token>

Get the next or previous word token relative to a base index, if separated by whitespace. Returns None if the next/previous token is not a word or does not exist.

Source

pub fn fat_string_tokens(&self) -> impl Iterator<Item = FatStringToken> + '_

Get an iterator over all the tokens contained in the document.

Source

pub fn get_span_content(&self, span: &Span<char>) -> &[char]

Source

pub fn get_span_content_str(&self, span: &Span<char>) -> String

Source

pub fn get_full_string(&self) -> String

Source

pub fn get_full_content(&self) -> &[char]

Source

pub fn get_source(&self) -> &[char]

Source

pub fn get_tokens(&self) -> &[Token]

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

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 Document

Source§

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

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

impl Default for Document

Source§

fn default() -> Self

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

impl Display for Document

Source§

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

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

impl TokenStringExt for Document

Source§

fn first_adjective(&self) -> Option<&Token>

Source§

fn last_adjective(&self) -> Option<&Token>

Source§

fn last_adjective_index(&self) -> Option<usize>

Source§

fn iter_adjective_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_adjectives(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_apostrophe(&self) -> Option<&Token>

Source§

fn last_apostrophe(&self) -> Option<&Token>

Source§

fn last_apostrophe_index(&self) -> Option<usize>

Source§

fn iter_apostrophe_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_apostrophes(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_at(&self) -> Option<&Token>

Source§

fn last_at(&self) -> Option<&Token>

Source§

fn last_at_index(&self) -> Option<usize>

Source§

fn iter_at_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_ats(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_chunk_terminator(&self) -> Option<&Token>

Source§

fn last_chunk_terminator(&self) -> Option<&Token>

Source§

fn last_chunk_terminator_index(&self) -> Option<usize>

Source§

fn iter_chunk_terminator_indices( &self, ) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_chunk_terminators(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_comma(&self) -> Option<&Token>

Source§

fn last_comma(&self) -> Option<&Token>

Source§

fn last_comma_index(&self) -> Option<usize>

Source§

fn iter_comma_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_commas(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_conjunction(&self) -> Option<&Token>

Source§

fn last_conjunction(&self) -> Option<&Token>

Source§

fn last_conjunction_index(&self) -> Option<usize>

Source§

fn iter_conjunction_indices( &self, ) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_conjunctions(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_currency(&self) -> Option<&Token>

Source§

fn last_currency(&self) -> Option<&Token>

Source§

fn last_currency_index(&self) -> Option<usize>

Source§

fn iter_currency_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_currencys(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_ellipsis(&self) -> Option<&Token>

Source§

fn last_ellipsis(&self) -> Option<&Token>

Source§

fn last_ellipsis_index(&self) -> Option<usize>

Source§

fn iter_ellipsis_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_ellipsiss(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_hostname(&self) -> Option<&Token>

Source§

fn last_hostname(&self) -> Option<&Token>

Source§

fn last_hostname_index(&self) -> Option<usize>

Source§

fn iter_hostname_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_hostnames(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_likely_homograph(&self) -> Option<&Token>

Source§

fn last_likely_homograph(&self) -> Option<&Token>

Source§

fn last_likely_homograph_index(&self) -> Option<usize>

Source§

fn iter_likely_homograph_indices( &self, ) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_likely_homographs(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_noun(&self) -> Option<&Token>

Source§

fn last_noun(&self) -> Option<&Token>

Source§

fn last_noun_index(&self) -> Option<usize>

Source§

fn iter_noun_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_nouns(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_number(&self) -> Option<&Token>

Source§

fn last_number(&self) -> Option<&Token>

Source§

fn last_number_index(&self) -> Option<usize>

Source§

fn iter_number_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_numbers(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_paragraph_break(&self) -> Option<&Token>

Source§

fn last_paragraph_break(&self) -> Option<&Token>

Source§

fn last_paragraph_break_index(&self) -> Option<usize>

Source§

fn iter_paragraph_break_indices( &self, ) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_paragraph_breaks(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_pipe(&self) -> Option<&Token>

Source§

fn last_pipe(&self) -> Option<&Token>

Source§

fn last_pipe_index(&self) -> Option<usize>

Source§

fn iter_pipe_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_pipes(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_preposition(&self) -> Option<&Token>

Source§

fn last_preposition(&self) -> Option<&Token>

Source§

fn last_preposition_index(&self) -> Option<usize>

Source§

fn iter_preposition_indices( &self, ) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_prepositions(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_punctuation(&self) -> Option<&Token>

Source§

fn last_punctuation(&self) -> Option<&Token>

Source§

fn last_punctuation_index(&self) -> Option<usize>

Source§

fn iter_punctuation_indices( &self, ) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_punctuations(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_quote(&self) -> Option<&Token>

Source§

fn last_quote(&self) -> Option<&Token>

Source§

fn last_quote_index(&self) -> Option<usize>

Source§

fn iter_quote_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_quotes(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_sentence_terminator(&self) -> Option<&Token>

Source§

fn last_sentence_terminator(&self) -> Option<&Token>

Source§

fn last_sentence_terminator_index(&self) -> Option<usize>

Source§

fn iter_sentence_terminator_indices( &self, ) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_sentence_terminators(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_space(&self) -> Option<&Token>

Source§

fn last_space(&self) -> Option<&Token>

Source§

fn last_space_index(&self) -> Option<usize>

Source§

fn iter_space_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_spaces(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_unlintable(&self) -> Option<&Token>

Source§

fn last_unlintable(&self) -> Option<&Token>

Source§

fn last_unlintable_index(&self) -> Option<usize>

Source§

fn iter_unlintable_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_unlintables(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_verb(&self) -> Option<&Token>

Source§

fn last_verb(&self) -> Option<&Token>

Source§

fn last_verb_index(&self) -> Option<usize>

Source§

fn iter_verb_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_verbs(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_word(&self) -> Option<&Token>

Source§

fn last_word(&self) -> Option<&Token>

Source§

fn last_word_index(&self) -> Option<usize>

Source§

fn iter_word_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_words(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_word_like(&self) -> Option<&Token>

Source§

fn last_word_like(&self) -> Option<&Token>

Source§

fn last_word_like_index(&self) -> Option<usize>

Source§

fn iter_word_like_indices(&self) -> impl DoubleEndedIterator<Item = usize> + '_

Source§

fn iter_word_likes(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn first_sentence_word(&self) -> Option<&Token>

Source§

fn first_non_whitespace(&self) -> Option<&Token>

Source§

fn span(&self) -> Option<Span<char>>

Grab the span that represents the beginning of the first element and the end of the last element.
Source§

fn iter_linking_verb_indices(&self) -> impl Iterator<Item = usize> + '_

Source§

fn iter_linking_verbs(&self) -> impl Iterator<Item = &Token> + '_

Source§

fn iter_chunks(&self) -> impl Iterator<Item = &[Token]> + '_

Iterate over chunks. Read more
Source§

fn iter_paragraphs(&self) -> impl Iterator<Item = &[Token]> + '_

Get an iterator over token slices that represent the individual paragraphs in a document.
Source§

fn iter_sentences(&self) -> impl Iterator<Item = &[Token]> + '_

Get an iterator over token slices that represent the individual sentences in a document.
Source§

fn iter_sentences_mut(&mut self) -> impl Iterator<Item = &mut [Token]> + '_

Get an iterator over mutable token slices that represent the individual sentences in a document.

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> ErasedDestructor for T
where T: 'static,

Source§

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