package eu.gaudian.translator.model.grammar

import kotlinx.serialization.Serializable

/**
 * Generic morphology models derived from local dictionary data.
 *
 * These models are UI-agnostic and can be rendered by different screens
 * (dictionary results, vocabulary cards, etc.).
 */

/**
 * Conjugation data for a single verb.
 *
 * @param infinitive The base form of the verb.
 * @param conjugations Map from an internal or display tense key to the list of
 * forms for each person (same order as [pronouns]).
 * @param pronouns List of pronouns corresponding to the persons in [conjugations] values.
 * @param auxiliary Optional auxiliary verb used by this verb (e.g., "haben/sein").
 */
@Serializable
data class VerbConjugation(
    val infinitive: String,
    val conjugations: Map<String, List<String>>, // tense -> list of forms
    val pronouns: List<String> = emptyList(),
    val auxiliary: String? = null
)

/**
 * Declension table for noun-like words.
 *
 * @param cases Ordered list of case keys (e.g., "nominative", "genitive", ...).
 * @param numbers Ordered list of number keys (e.g., "singular", "plural").
 * @param forms Mapping from (case, number) pair to the inflected form.
 */
@Serializable
data class NounDeclensionTable(
    val cases: List<String>,
    val numbers: List<String>,
    val forms: Map<Pair<String, String>, String>
)

/**
 * Comparison degrees for adjectives.
 */
@Serializable
data class AdjectiveComparison(
    val positive: String? = null,
    val comparative: String? = null,
    val superlative: String? = null
)

/**
 * High-level morphology classification for a word.
 */
sealed class WordMorphology {
    data class Verb(val conjugations: List<VerbConjugation>) : WordMorphology()
    data class Noun(val declension: NounDeclensionTable) : WordMorphology()
    data class Adjective(val comparison: AdjectiveComparison) : WordMorphology()

    /**
     * Generic inflections as provided by some dictionaries (e.g. Portuguese).
     */
    data class GenericInflections(val inflections: List<Inflection>) : WordMorphology()
}