Nasty.Language.Spanish.SentenceParser (Nasty v0.3.0)
View SourceSentence and clause parser for Spanish.
Builds Clause and Sentence structures from phrases.
Spanish-Specific Features
- Flexible word order: SVO is default, but VSO and VOS are common
- Pro-drop: subject pronouns often omitted ("Voy" not "Yo voy")
- Question syntax: inverted word order with ¿?
- Subordination: que, porque, cuando, si, aunque, mientras
Examples
iex> tokens = [...] # "El gato se sentó."
iex> SentenceParser.parse_sentences(tokens)
{:ok, [sentence]}
Summary
Functions
Parses a Spanish clause from tokens, detecting coordination and subordination.
Parses a single Spanish sentence from tokens.
Parses tokens into a list of sentences.
Rule-based sentence parsing for Spanish.
Functions
@spec parse_clause([Nasty.AST.Token.t()]) :: {:ok, Nasty.AST.Clause.t() | [Nasty.AST.Clause.t()]} | :error
Parses a Spanish clause from tokens, detecting coordination and subordination.
Grammar: Simple: (NP) VP or VP (NP) -- flexible word order Coordinated: Clause CoordConj Clause Subordinate: SubordConj Clause
@spec parse_sentence([Nasty.AST.Token.t()]) :: Nasty.AST.Sentence.t() | nil
Parses a single Spanish sentence from tokens.
Grammar: (NP) VP (flexible word order)
@spec parse_sentences( [Nasty.AST.Token.t()], keyword() ) :: {:ok, [Nasty.AST.Sentence.t()]} | {:error, term()}
Parses tokens into a list of sentences.
Identifies sentence boundaries and parses each sentence separately.
Options
:model- Model type::rule_based(default, only option for now)
Returns
{:ok, sentences}- List of parsed sentences{:error, reason}- Parsing failed
@spec parse_sentences_rule_based([Nasty.AST.Token.t()]) :: {:ok, [Nasty.AST.Sentence.t()]} | {:error, term()}
Rule-based sentence parsing for Spanish.