diff --git a/grammars/resource/italian/MorphoIta.gf b/grammars/resource/italian/MorphoIta.gf new file mode 100644 index 000000000..c499f83df --- /dev/null +++ b/grammars/resource/italian/MorphoIta.gf @@ -0,0 +1,291 @@ +--# -path=.:../romance:../../prelude + +--1 A Simple Italian Resource Morphology +-- +-- Aarne Ranta 2002--2003 +-- +-- This resource morphology contains definitions needed in the resource +-- syntax. It moreover contains the most usual inflectional patterns. +-- The patterns for verbs contain the complete "Bescherelle" conjugation +-- tables. +-- +-- We use the parameter types and word classes defined in $TypesIta.gf$. + +resource MorphoIta = open (Predef=Predef), Prelude, TypesIta in { + +--2 Some phonology +-- +--3 Elision +-- +-- The phonological rule of *elision* can be defined as follows in GF. +-- In Italian it includes both vowels and the *impure 's'*. + +oper + vocale : Strs = strs { + "a" ; "e" ; "h" ; "i" ; "o" ; "u" + } ; + + sImpuro : Strs = strs { + "z" ; "sb" ; "sc" ; "sd" ; "sf" ; "sm" ; "sp" ; "sq" ; "sr" ; "st" ; "sv" + } ; + + elision : (_,_,_ : Str) -> Str = \il, l', lo -> + pre {il ; l' / vocale ; lo / sImpuro} ; + + +--2 Nouns +-- +-- The following macro is useful for creating the forms of number-dependent +-- tables, such as common nouns. + + numForms : (_,_ : Str) -> Number => Str = \vino, vini -> + table {Sg => vino ; Pl => vini} ; + +-- For example: + + nomVino : Str -> Number => Str = \vino -> let {vin = Predef.tk 1 vino} in + numForms vino (vin + "i") ; + + nomRana : Str -> Number => Str = \rana -> let {ran = Predef.tk 1 rana} in + numForms rana (ran + "e") ; + + nomSale : Str -> Number => Str = \sale -> let {sal = Predef.tk 1 sale} in + numForms sale (sal + "i") ; + + nomTram : Str -> Number => Str = \tram -> + numForms tram tram ; + +-- Common nouns are inflected in number and have an inherent gender. + + mkCNom : (Number => Str) -> Gender -> CNom = \mecmecs,gen -> + {s = mecmecs ; g = gen} ; + + mkCNomIrreg : Str -> Str -> Gender -> CNom = \mec,mecs -> + mkCNom (numForms mec mecs) ; + + + +--2 Adjectives +-- +-- Adjectives are conveniently seen as gender-dependent nouns. +-- Here are some patterns. First one that describes the worst case. + + mkAdj : (_,_,_,_ : Str) -> Adj = \solo,sola,soli,sole -> + {s = table { + Masc => numForms solo soli ; + Fem => numForms sola sole + } + } ; + +-- Then the regular and invariant patterns. + + adjSolo : Str -> Adj = \solo -> let {sol = Predef.tk 1 solo} in + mkAdj solo (sol + "a") (sol + "i") (sol + "e") ; + + adjTale : Str -> Adj = \tale -> let {tali = Predef.tk 1 tale + "i"} in + mkAdj tale tale tali tali ; + + adjBlu : Str -> Adj = \blu -> + mkAdj blu blu blu blu ; + +-- Adjectives themselves are records. Here the most common cases: + + +--2 Personal pronouns +-- +-- All the eight personal pronouns can be built by the following macro. +-- The use of "ne" as atonic genitive is debatable. +-- We follow the rule that the atonic nominative is empty. + + mkPronoun : (_,_,_,_,_,_,_,_ : Str) -> + PronGen -> Number -> Person -> ClitType -> Pronoun = + \il,le,lui,Lui,son,sa,ses,see,g,n,p,c -> + {s = table { + Ton Nom => il ; + Ton x => prepCase x ++ Lui ; + Aton Nom => [] ; + Aton Acc => le ; + Aton (CPrep P_di) => "ne" ; --- hmm + Aton (CPrep P_a) => lui ; + Aton (CPrep q) => strPrep q ++ Lui ; ---- GF bug with c or p! + Poss Sg Masc => son ; + Poss Sg Fem => sa ; + Poss Pl Masc => ses ; + Poss Pl Fem => see + } ; + g = g ; + n = n ; + p = p ; + c = c + } ; + + +--2 Reflexive pronouns +-- +-- It is simply a function depending on number and person. + + pronRefl : Number -> Person -> Str = \n,p -> case of { + => "mi" ; + => "ti" ; + <_, P3> => "si" ; + => "ci" ; + => "vi" + } ; + + +--2 Determiners +-- +-- Determiners, traditionally called indefinite pronouns, are inflected +-- in gender and number, like adjectives. + + pronForms : Adj -> Gender -> Number -> Str = \tale,g,n -> tale.s ! g ! n ; + + qualPron : Gender -> Number -> Str = pronForms (adjTale "quale") ; + + talPron : Gender -> Number -> Str = pronForms (adjTale "tale") ; + + tuttoPron : Gender -> Number -> Str = pronForms (adjSolo "tutto") ; + +--2 Articles +-- +-- The definite article has quite some variation: three parameters and +-- elision. This is the simples definition we have been able to find. + + artDefTable : Gender => Number => Case => Str = \\g,n,c => case of { + <_, _, CPrep P_di> => prepArt g n "de" ; + <_, _, CPrep P_da> => prepArt g n "da" ; + <_, _, CPrep P_a> => prepArt g n "a" ; + <_, _, CPrep P_in> => prepArt g n "ne" ; + <_, _, CPrep P_su> => prepArt g n "su" ; + <_, _, CPrep P_con> => prepArt g n "co" ; + => elision "il" "l'" "lo" ; + => elision "il" "l'" "lo" ; + + => elision "la" "l'" "la" ; + => elision "i" "gli" "gli" ; + => "le" + } ; + +-- This auxiliary expresses the uniform rule. + + prepArt : Gender -> Number -> Tok -> Tok = \g,n,de -> case of { + => elision (de + "l") (de + "ll'") (de + "llo") ; + => elision (de + "i") (de + "gli") (de + "gli") ; + => elision (de + "lla") (de + "ll'") (de + "lla") ; + => de + "lle" + } ; + +--2 Verbs +-- +--3 The present tense +-- +-- We first define some macros for the special case of present tense. +-- +-- The verb "essere" is often used in syntax. + + verbEssere = verbPres essere ; + +-- We very often form the verb stem by dropping out the infinitive ending. + + troncVerb : Tok -> Tok = Predef.tk 3 ; + + +oper mkVerbPres : (_,_,_,_,_,_,_,_ : Str) -> VerbPres = + \veng, viene, ven, venite, vengono, venga, vieni, venire -> + let {vien = Predef.tk 1 vieni} in + {s = table { + VFin Ind Sg P1 => veng + "o" ; + VFin Ind Sg P2 => vien + "i" ; + VFin Ind Sg P3 => viene ; + VFin Ind Pl P1 => ven + "iamo" ; + VFin Ind Pl P2 => venite ; + VFin Ind Pl P3 => vengono ; + VFin Con Sg _ => venga ; + VFin Con Pl P1 => ven + "iamo" ; + VFin Con Pl P2 => ven + "iate" ; + VFin Con Pl P3 => venga + "no" ; + VImper SgP2 => vieni ; + VImper PlP1 => ven + "iamo" ; + VImper PlP2 => venite ; + VInfin => venire + } + } ; + +-- The four main conjugations. + + verbAmare : Str -> VerbPres = \amare -> + let {am = troncVerb amare ; ama = am + "a"} in + mkVerbPres + am ama am (ama + "te") (ama + "no") + (am+"i") ama amare ; + + verbDormire : Str -> VerbPres = \dormire -> + let {dorm = troncVerb dormire} in + mkVerbPres + dorm (dorm + "e") dorm (dorm + "ite") (dorm + "ino") (dorm+"a") + (dorm + "i") dormire ; + + verbFinire : Str -> VerbPres = \finire -> + let {fin = troncVerb finire ; fini = fin + "i" ; finisc = fini + "sc"} in + mkVerbPres + finisc (finisc + "e") fin (fini + "te") (finisc + "ono") + (finisc + "a") (finisc + "i") finire ; + + verbCorrere : Str -> VerbPres = \correre -> + let {corr = troncVerb correre ; corre = corr + "e"} in + mkVerbPres corr corre corr (corre + "te") (corr + "ono") (corr+"a") (corr+"i") + correre ; + +-- Some irregular verbs. + + verbPresSpegnere : VerbPres = + mkVerbPres "speng" "spegne" "spegn" "spegnete" "spengono" + "spenga" "spegni" "spegnere" ; + + verbPresDire : VerbPres = + mkVerbPres "dic" "dice" "dic" "dite" "dicono" + "dica" "di" "dire" ; + + +essere = {s = table { + Inf => "essere" ; + Indi Pres Sg P1 => "sono" ; + Indi Pres Sg P2 => "sei" ; + Indi Pres Sg P3 => "è" ; + Indi Pres Pl P1 => "siamo" ; + Indi Pres Pl P2 => "siete" ; + Indi Pres Pl P3 => "sono" ; + Cong Pres Sg P1 => "sia" ; + Cong Pres Sg P2 => "sia" ; + Cong Pres Sg P3 => "sia" ; + Cong Pres Pl P1 => "siamo" ; + Cong Pres Pl P2 => "siate" ; + Cong Pres Pl P3 => "siano" ; + Imper SgP2 => "sii" ; + Imper PlP1 => "siamo" ; + Imper PlP2 => "siate" ; + _ => "essere" --- we just don't care + }} ; + + + avere = {s = table { + Inf => "avere" ; + Indi Pres Sg P1 => "ho" ; + Indi Pres Sg P2 => "hai" ; + Indi Pres Sg P3 => "ha" ; + Indi Pres Pl P1 => "abbiamo" ; + Indi Pres Pl P2 => "avete" ; + Indi Pres Pl P3 => "hanno" ; + Cong Pres Sg P1 => "abbia" ; + Cong Pres Sg P2 => "abbia" ; + Cong Pres Sg P3 => "abbia" ; + Cong Pres Pl P1 => "abbiamo" ; + Cong Pres Pl P2 => "abbiate" ; + Cong Pres Pl P3 => "abbiano" ; + Imper SgP2 => "abbi" ; + Imper PlP1 => "abbiamo" ; + Imper PlP2 => "abbiate" ; + _ => "avere" --- we just don't care + }} ; + +} diff --git a/grammars/resource/italian/ResIta.gf b/grammars/resource/italian/ResIta.gf new file mode 100644 index 000000000..de1995fa1 --- /dev/null +++ b/grammars/resource/italian/ResIta.gf @@ -0,0 +1,3 @@ +--# -path=.:../romance:../abstract:../../prelude + +concrete ResIta of ResAbs = ResRomance with (SyntaxRomance=SyntaxIta) ; diff --git a/grammars/resource/italian/SyntaxIta.gf b/grammars/resource/italian/SyntaxIta.gf new file mode 100644 index 000000000..c8fc00bed --- /dev/null +++ b/grammars/resource/italian/SyntaxIta.gf @@ -0,0 +1,286 @@ +--# -path=.:../../prelude + +instance SyntaxIta of SyntaxRomance = + TypesIta ** open Prelude, (CO=Coordination), MorphoIta in { +oper + nameNounPhrase = \jean -> + normalNounPhrase + (\\c => prepCase c ++ jean.s) + jean.g + Sg ; + + chaqueDet = mkDeterminer1 Sg "ogni" ; + tousDet = mkDeterminer Pl ["tutti i"] ["tutte le"] ; --- gli + plupartDet = mkDeterminer1 Pl ["la maggior parte di"] ; --- dei, degli, delle + unDet = mkDeterminer Sg artUno artUna ; + plDet = mkDeterminer1 Pl [] ; --- dei, degli, delle + + quelDet = mkDeterminer1 Sg "quale" ; + + npGenPoss = \n,ton,mec -> + \\c => artDef mec.g n c ++ ton.s ! Poss n mec.g ++ mec.s ! n ; --- mia madre + + mkAdjSolo : Str -> Bool -> Adjective = \adj,p -> + mkAdjective (adjSolo adj) p ; + + mkAdjTale : Str -> Bool -> Adjective = \adj,p -> + mkAdjective (adjTale adj) p ; + + mkAdjDegrSolo : Str -> Bool -> AdjDegr = \adj,p -> + mkAdjDegrLong (adjSolo adj) p ; + + mkAdjDegrTale : Str -> Bool -> AdjDegr = \adj,p -> + mkAdjDegrLong (adjTale adj) p ; + + comparConj = variants {"di" ; "che"} ; + +-- The commonest case for functions is common noun + "di". + + funDi : CommNounPhrase -> Function = \mere -> + mere ** complementCas genitive ; + +-- Chains of "cui" - "cui" do not arise. + + funRelPron = \mere,lequel -> + {s = table { + RComplex g n c => variants { + case mere.c of { + CPrep P_di => artDef mere.g n c ++ + lequel.s ! RSimple dative ++ mere.s ! n ; + _ => nonExist} ; + artDef mere.g n c ++ mere.s ! n ++ + mere.s2 ++ lequel.s ! RComplex g n mere.c + } ; + _ => nonExist + } ; + g = RG mere.g + } ; + +-- Verbs + + negVerb = \va -> "non" ++ va ; + + copula = \b -> \\v => (if_then_else Str b [] "non") ++ verbEssere.s ! v ; + + isTransVerbClit = \v -> case v.c of { + Acc => True ; + _ => False --- hmmm + } ; + +-- The negation of a verb. + + posNeg = \b,v,c -> + if_then_else Str b + (v ++ c) + ("non" ++ v ++ c) ; + + locativeNounPhrase = \jean -> + {s = "in" ++ jean.s ! Ton Acc} ; ---- + + embedConj = "che" ; + +-- Relative pronouns + + identRelPron = { + s = table { + RSimple c => relPronForms ! c ; + RComplex g n c => composRelPron g n c + } ; + g = RNoGen + } ; + + suchPron = talPron ; + + composRelPron = ilqualPron ; + + allRelForms = \lequel,g,n,c -> + variants { + lequel.s ! RSimple c ; + lequel.s ! RComplex g n c + } ; + +-- Interrogative pronouns + + nounIntPron = \n, mec -> + {s = \\c => prepCase c ++ qualPron mec.g n ++ mec.s ! n ; + g = mec.g ; + n = n + } ; + + intPronWho = \num -> { + s = \\c => prepCase c ++ "chi" ; + g = Masc ; --- can we decide this? + n = num + } ; + + intPronWhat = \num -> { + s = table { + c => prepCase c ++ "che" ++ optStr "cosa" + } ; + g = Masc ; --- can we decide this? + n = num + } ; + +-- Questions + + questVerbPhrase = \jean,dort -> + {s = table { + DirQ => (predVerbPhrase jean dort).s ! Ind ; + IndirQ => "se" ++ (predVerbPhrase jean dort).s ! Ind + } + } ; + + intVerbPhrase = \qui, dort -> + {s = table { + DirQ => qui.s ! Nom ++ + dort.s ! qui.g ! VFin Ind qui.n P3 ; + IndirQ => qui.s ! Nom ++ dort.s ! qui.g ! VFin Ind qui.n P3 + } + } ; + + intSlash = \Qui, Tuvois -> + let {qui = Tuvois.s2 ++ Qui.s ! Tuvois.c ; tuvois = Tuvois.s ! Ind} in + {s = table { + DirQ => qui ++ tuvois ; + IndirQ => ifCe Tuvois.c ++ qui ++ tuvois + } + } ; + +-- An auxiliary to distinguish between +-- "je ne sais pas" ("ce qui dort" / "ce que tu veux" / "à qui tu penses"). + + ifCe : Case -> Str = \c -> case c of { --- + Nom => "ciò" ; + Acc => "ciò" ; + _ => [] + } ; + + questAdverbial = \quand, jean, dort -> + let {jeandort = (predVerbPhrase jean dort).s ! Ind} in + {s = table { + DirQ => quand.s ++ jeandort ; --- inversion? + IndirQ => quand.s ++ jeandort + } + } ; + +---- moved from MorphoIta + +-- A macro for defining gender-dependent tables will be useful. +-- Its first application is in the indefinite article. + + genForms = \matto, matta -> + table {Masc => matto ; Fem => matta} ; + + artUno : Str = elision "un" "un" "uno" ; + artUna : Str = elision "una" "un'" "una" ; + + artIndef = \g,n,c -> case n of { + Sg => prepCase c ++ genForms artUno artUna ! g ; + _ => prepCase c ++ [] + } ; + + artDef = \g,n,c -> artDefTable ! g ! n ! c ; + +-- The composable pronoun "il quale" is inflected by varying the definite +-- article and the determiner "quale" in the expected way. + + ilqualPron : Gender -> Number -> Case -> Str = \g,n,c -> + artDef g n c ++ qualPron g n ; + + pronJe = mkPronoun + "io" + "mi" + "mi" + "me" + "mio" "mia" "miei" "mie" + PNoGen -- gender cannot be known from pronoun alone + Sg + P1 + Clit1 ; + + pronTu = mkPronoun + "tu" + "ti" + "ti" + "te" + "tuo" "tua" "tuoi" "tue" + PNoGen + Sg + P2 + Clit1 ; + + pronIl = mkPronoun + "lui" + "lo" + "gli" + "lui" + "suo" "sua" "suoi" "sue" + (PGen Masc) + Sg + P3 + Clit2 ; + + pronElle = mkPronoun + "lei" + "la" + "le" + "lei" + "suo" "sua" "suoi" "sue" + (PGen Fem) + Sg + P3 + Clit2 ; + + pronNous = mkPronoun + "noi" + "ci" + "ci" + "noi" + "nostro" "nostra" "nostri" "nostre" + PNoGen + Pl + P1 + Clit3 ; + + pronVous = mkPronoun + "voi" + "vi" + "vi" + "voi" + "vostro" "vostra" "vostri" "vostre" + PNoGen + Pl --- depends! + P2 + Clit3 ; + + pronIls = mkPronoun + "loro" + "loro" + "li" --- le ! + "loro" + "loro" "loro" "loro" "loro" + PNoGen + Pl + P3 + Clit1 ; + +-- moved from ResIta + + commentAdv = ss "comme" ; + quandAdv = ss "quando" ; + ouAdv = ss "o" ; + pourquoiAdv = ss "perché" ; + + etConj = ss "e" ** {n = Pl} ; + ouConj = ss "o" ** {n = Sg} ; + etetConj = sd2 "e" "e" ** {n = Pl} ; + ououConj = sd2 "o" "o" ** {n = Sg} ; + niniConj = sd2 "né" "né" ** {n = Sg} ; --- requires ne ! + siSubj = ss "se" ; + quandSubj = ss "quando" ; + + ouiPhr = ss ["Sì ."] ; + nonPhr = ss ["No ."] ; + +} + diff --git a/grammars/resource/italian/TestIta.gf b/grammars/resource/italian/TestIta.gf new file mode 100644 index 000000000..01d31d70d --- /dev/null +++ b/grammars/resource/italian/TestIta.gf @@ -0,0 +1,35 @@ +--# -path=.:../romance:../abstract:../../prelude + +concrete TestIta of TestAbs = + ResIta ** open Prelude, TypesIta, MorphoIta, SyntaxIta in { + +flags startcat=Phr ; lexer=text ; parser=chart ; unlexer=text ; + +lin + Big = mkAdjDegrTale "grande" adjPre ; + Small = mkAdjDegrSolo "piccolo" adjPre ; + Old = mkAdjDegrLong (mkAdj "vecchio" "vecchia" "vecchi" "vecchie") adjPre ; + Young = mkAdjDegrTale "giovane" adjPre ; + Man = mkCNom (numForms "uomo" "uomini") Masc ; + Woman = mkCNom (nomRana "donna") Fem ; + Car = mkCNom (nomRana "macchina") Fem ; + Light = mkCNom (nomSale "luce") Fem ; + House = mkCNom (nomRana "casa") Fem ; + Walk = verbAmare "camminare" ; + Run = verbCorrere "correre"; + Send = mkTransVerbDir (verbAmare "mandare") ; + Love = mkTransVerbDir (verbAmare "amare") ; + Wait = mkTransVerbDir (verbAmare "aspettare") ; + Say = verbSent verbPresDire Ind Ind ; + Prove = verbSent (verbAmare "dimostrare") Ind Ind ; + SwitchOn = mkTransVerbDir (verbAmare "allumare") ; + SwitchOff = mkTransVerbDir verbPresSpegnere ; + Mother = funDi (mkCNom (nomSale "madre") Fem) ; + Uncle = funDi (mkCNom (nomVino "zio") Masc) ; + + Well = ss "bene" ; + Always = ss "sempre" ; + + John = mkProperName "Giovanni" Masc ; + Mary = mkProperName "Maria" Fem ; +} diff --git a/grammars/resource/italian/TypesIta.gf b/grammars/resource/italian/TypesIta.gf new file mode 100644 index 000000000..15cab0bea --- /dev/null +++ b/grammars/resource/italian/TypesIta.gf @@ -0,0 +1,131 @@ +--1 Italian Word Classes and Morphological Parameters +-- +-- This is a resource module for Italian morphology, defining the +-- morphological parameters and word classes of Italian. +-- The morphology is so far only +-- complete w.r.t. the syntax part of the resource grammar. +-- It does not include those parameters that are not needed for +-- analysing individual words: such parameters are defined in syntax modules. + +instance TypesIta of TypesRomance = { + +-- First we give values to the abstract types. + +param + Case = Nom | Acc | CPrep Prep ; + + Prep = P_di | P_a | P_da | P_in | P_su | P_con ; + + NPForm = Ton Case | Aton Case | Poss Number Gender ; + +--2 Prepositions +-- +-- The type $Case$ in $types.Ita.gf$ has the dative and genitive +-- cases, which are relevant for pronouns and the definite article, +-- but which are otherwise expressed by prepositions. + +oper + prepCase = \c -> case c of { + Nom => [] ; + Acc => [] ; + CPrep p => strPrep p + } ; + + strPrep : Prep -> Str = \p -> case p of { + P_di => "di" ; + P_a => "a" ; + P_da => "da" ; + P_in => "in" ; + P_su => "su" ; + P_con => "con" + } ; + +oper + CaseA = Case ; + NPFormA = NPForm ; + + nominative = Nom ; + accusative = Acc ; + genitive = CPrep P_di ; + dative = CPrep P_a ; + + stressed = Ton ; + unstressed = Aton ; + +oper + pform2case = \p -> case p of { + Ton x => x ; + Aton x => x ; + Poss _ _ => genitive + } ; + + case2pform = \c -> case c of { + Nom => Aton Nom ; + Acc => Aton Acc ; + _ => Ton c + } ; + +-- Comparative adjectives are only sometimes formed morphologically +-- (actually: by different morphemes). + + mkAdjComp : (_,_ : Gender => Number => Str) -> AdjComp = + \buono, migliore -> + {s = table {Pos => buono ; _ => migliore}} ; + +-- Usually the comparison forms are built by prefixing the word +-- "più". The definite article needed in the superlative is provided in +-- $syntax.Ita.gf$. + + adjCompLong : Adj -> AdjComp = \caro -> + mkAdjComp + caro.s + (\\g,n => "più" ++ caro.s ! g ! n) ; + + +-- Relative pronouns: the case-dependent parameter type. + + param RelForm = RSimple Case | RComplex Gender Number Case ; + + oper RelFormA = RelForm ; + +--2 Relative pronouns +-- +-- The simple (atonic) relative pronoun shows genuine variation in all of the +-- cases. + + relPronForms = table { + Nom => "che" ; + Acc => "che" ; + CPrep P_a => "cui" ; --- variant a cui + CPrep p => strPrep p ++ "cui" + } ; + +-- Verbs: conversion from full verbs to present-tense verbs. + + verbPres = \amare -> {s = table { + VInfin => amare.s ! Inf ; + VFin Ind n p => amare.s ! Indi Pres n p ; + VFin Con n p => amare.s ! Cong Pres n p ; + VImper np => amare.s ! Imper np + }} ; + +-- The full conjunction is a table on $VForm$: + +param + Tempo = Pres | Imperf ; + TempoP = PresP | PassP ; + VForm = + Inf + | Indi Tempo Number Person + | Pass Number Person + | Fut Number Person + | Cong Tempo Number Person + | Cond Number Person + | Imper NumPersI + | Ger + | Part TempoP Gender Number ; + +-- This is the full verb type. + +oper Verbum = {s : VForm => Str} ; +}