Exception: Kotoshu::Models::EmptySuggestionsError

Inherits:
ArgumentError
  • Object
show all
Defined in:
lib/kotoshu/models/semantic_error.rb

Overview

Unified semantic error (NO artificial spelling/grammar split!).

Represents ANY kind of language error detected through semantic analysis. Uses semantic categories instead of traditional "spelling" vs "grammar" labels.

Error types (semantic categories):

  • :word_choice - Wrong word for context (e.g., "desert" vs "dessert")
  • :verb_agreement - Subject-verb mismatch (e.g., "they is" → "they are")
  • :tense - Temporal inconsistency (e.g., "Yesterday I will go")
  • :orthographic - Actual typo/misspelling (e.g., "wrold" → "world")
  • :preposition - Wrong preposition (e.g., "bored of" → "bored with")
  • :article - Wrong article (e.g., "a apple" → "an apple")
  • :morphology - Wrong word form (e.g., "goed" → "went")
  • :capitalization - Capitalization error (e.g., "i am" → "I am")
  • :punctuation - Punctuation error (e.g., "its" vs "it's")
  • :style - Style/usage suggestion

Raised by SemanticError#initialize when suggestions is empty and allow_empty_suggestions: is false. The analyzer rescues this so words with no close matches are silently dropped rather than producing noise.

Examples:

Creating a semantic error

error = SemanticError.new(
  id: "error_1",
  location: Location.new(line: 5, column: 12),
  original: "desert",
  suggestions: [Suggestion.new("dessert", confidence: 0.92)],
  error_type: :word_choice,
  confidence: 0.92,
  context: context
)