Nasty.Language.Spanish.QuestionAnalyzer (Nasty v0.3.0)

View Source

Analyzes Spanish questions and finds answers in documents.

Identifies question type, expected answer type, and searches for matching answer spans in the provided context.

Spanish Question Types

  • ¿Quién? (who) → person names
  • ¿Qué? (what) → entities, objects
  • ¿Dónde? (where) → locations
  • ¿Cuándo? (when) → dates, times
  • ¿Por qué? (why) → reasons, causes
  • ¿Cómo? (how) → manner, methods
  • ¿Cuánto? (how much/many) → quantities

Example

iex> context = parse("Juan García nació en Madrid en 1990")
iex> question = "¿Quién nació en Madrid?"
iex> answer = QuestionAnalyzer.answer(question, context)
%{
  answer: "Juan García",
  confidence: 0.95,
  type: :person,
  span: %{start_pos: {1, 1}, end_pos: {1, 12}}
}

Summary

Functions

Analyzes a Spanish question and extracts its type, focus, and keywords.

Answers a Spanish question given a context document.

Identifies the type of a Spanish question.

Functions

analyze(tagged_tokens)

@spec analyze(list()) :: {:ok, map()} | {:error, term()}

Analyzes a Spanish question and extracts its type, focus, and keywords.

Returns a question analysis struct for answer extraction.

answer(question, context)

@spec answer(String.t(), Nasty.AST.Document.t()) :: map() | nil

Answers a Spanish question given a context document.

Returns a map with answer text, confidence, type, and span.

classify(question)

@spec classify(String.t()) :: atom() | nil

Identifies the type of a Spanish question.