Nasty.Statistics.Parsing.Grammar.Rule (Nasty v0.3.0)

View Source

Represents a single grammar rule with probability.

Fields

  • lhs - Left-hand side non-terminal (atom)
  • rhs - Right-hand side (list of terminals/non-terminals)
  • probability - Rule probability (float, 0.0-1.0)
  • language - Language code (atom, e.g., :en)

Summary

Types

symbol()

@type symbol() :: atom() | String.t()

t()

@type t() :: %Nasty.Statistics.Parsing.Grammar.Rule{
  language: atom(),
  lhs: atom(),
  probability: float(),
  rhs: [symbol()]
}

Functions

new(lhs, rhs, probability, language \\ :en)

@spec new(atom(), [symbol()], float(), atom()) :: t()

Creates a new grammar rule.

Examples

iex> Rule.new(:np, [:det, :noun], 0.35, :en)
%Rule{lhs: :np, rhs: [:det, :noun], probability: 0.35, language: :en}