Nasty.AST.Paragraph (Nasty v0.3.0)
View SourceParagraph node representing a sequence of related sentences.
A paragraph is a unit of text containing one or more sentences that deal with a single topic or idea. Paragraphs provide discourse structure and cohesion markers.
Summary
Functions
Returns the first sentence of the paragraph.
Returns the last sentence of the paragraph.
Creates a new paragraph.
Counts the number of sentences in the paragraph.
Types
@type t() :: %Nasty.AST.Paragraph{ language: Nasty.AST.Node.language(), sentences: [Nasty.AST.Sentence.t()], span: Nasty.AST.Node.span(), topic_sentence: Nasty.AST.Sentence.t() | nil }
Functions
@spec first_sentence(t()) :: Nasty.AST.Sentence.t() | nil
Returns the first sentence of the paragraph.
Often the topic sentence in English writing.
Examples
iex> paragraph = %Nasty.AST.Paragraph{sentences: [s1, s2, s3], ...}
iex> Nasty.AST.Paragraph.first_sentence(paragraph)
s1
@spec last_sentence(t()) :: Nasty.AST.Sentence.t() | nil
Returns the last sentence of the paragraph.
Examples
iex> paragraph = %Nasty.AST.Paragraph{sentences: [s1, s2, s3], ...}
iex> Nasty.AST.Paragraph.last_sentence(paragraph)
s3
@spec new( [Nasty.AST.Sentence.t()], Nasty.AST.Node.language(), Nasty.AST.Node.span(), keyword() ) :: t()
Creates a new paragraph.
Examples
iex> span = Nasty.AST.Node.make_span({1, 0}, 0, {5, 0}, 100)
iex> sentences = [s1, s2, s3]
iex> paragraph = Nasty.AST.Paragraph.new(sentences, :en, span)
iex> length(paragraph.sentences)
3
@spec sentence_count(t()) :: non_neg_integer()
Counts the number of sentences in the paragraph.
Examples
iex> paragraph = %Nasty.AST.Paragraph{sentences: [s1, s2, s3], ...}
iex> Nasty.AST.Paragraph.sentence_count(paragraph)
3