diff --git a/lib/resource/abstract/AllResource.gf b/lib/resource/abstract/AllResource.gf new file mode 100644 index 000000000..2ba1fa33a --- /dev/null +++ b/lib/resource/abstract/AllResource.gf @@ -0,0 +1,2 @@ +abstract AllResource = Rules, Structural ** {} ; + diff --git a/lib/resource/abstract/Resource.gf b/lib/resource/abstract/Resource.gf new file mode 100644 index 000000000..fd68f4393 --- /dev/null +++ b/lib/resource/abstract/Resource.gf @@ -0,0 +1 @@ +interface Resource = reuse AllResource ; \ No newline at end of file diff --git a/lib/resource/abstract/Rules.gf b/lib/resource/abstract/Rules.gf index 25a71230f..1967b1bfa 100644 --- a/lib/resource/abstract/Rules.gf +++ b/lib/resource/abstract/Rules.gf @@ -19,6 +19,7 @@ fun SymbPN : String -> PN ; -- "x" SymbCN : CN -> String -> CN ; -- "number x" + IntCN : CN -> Int -> CN ; -- "number 53" IndefOneNP : CN -> NP ; -- "a car", "cars" IndefNumNP : Num -> CN -> NP ; -- "houses", "86 houses" diff --git a/lib/resource/abstract/Structural.gf b/lib/resource/abstract/Structural.gf index 0c1b4626f..e61170a4b 100644 --- a/lib/resource/abstract/Structural.gf +++ b/lib/resource/abstract/Structural.gf @@ -18,6 +18,7 @@ fun -- pronouns "we" and "you". EveryDet, WhichDet, AllMassDet, -- every, sg which, sg all + HowManyDet, --- should actually be interrogative SomeDet, AnyDet, NoDet, -- sg some, any, no MostDet, MostsDet, ManyDet, MuchDet : Det ; -- sg most, pl most, many, much ThisDet, ThatDet : Det ; -- this, that @@ -31,6 +32,7 @@ fun INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular WeNumNP, YeNumNP : Num -> NP ; -- these pronouns can take numeral TheyNP : NP ; YouNP : NP ; -- they, the polite you + TheyFemNP : NP ; EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing diff --git a/lib/resource/abstract/TestResource.gf b/lib/resource/abstract/TestResource.gf index 55dda45e0..0e454e78f 100644 --- a/lib/resource/abstract/TestResource.gf +++ b/lib/resource/abstract/TestResource.gf @@ -6,7 +6,7 @@ fun Big, Happy, Small, Old, Young : ADeg ; American, Finnish : A1 ; Married : A2 ; - Man, Woman, Car, House, Light, Bar, Bottle, Wine : N ; + Man, Woman, Car, House, Light, Bar, Bottle, Wine, Level : N ; Walk, Run : V ; Send, Wait, Love, Drink, SwitchOn, SwitchOff : V2 ; Give, Prefer : V3 ; diff --git a/lib/resource/italian/SyntaxIta.gf b/lib/resource/italian/SyntaxIta.gf index e7dbf4b18..7e03f8c6b 100644 --- a/lib/resource/italian/SyntaxIta.gf +++ b/lib/resource/italian/SyntaxIta.gf @@ -301,7 +301,7 @@ oper commentAdv = ss "comme" ; quandAdv = ss "quando" ; - ouAdv = ss "o" ; + ouAdv = ss "dove" ; pourquoiAdv = ss "perché" ; etConj = ss "e" ** {n = Pl} ; diff --git a/lib/resource/romance/RulesRomance.gf b/lib/resource/romance/RulesRomance.gf index fafcd93a5..b9dccf45f 100644 --- a/lib/resource/romance/RulesRomance.gf +++ b/lib/resource/romance/RulesRomance.gf @@ -31,6 +31,9 @@ lin SymbCN cn s = {s = \\n => cn.s ! n ++ s.s ; g = cn.g} ; + IntCN cn i = + {s = \\n => cn.s ! n ++ i.s ; + g = cn.g} ; CNthatS = nounThatSentence ; diff --git a/lib/resource/romance/SyntaxRomance.gf b/lib/resource/romance/SyntaxRomance.gf index 26eabc17e..9f957c9a8 100644 --- a/lib/resource/romance/SyntaxRomance.gf +++ b/lib/resource/romance/SyntaxRomance.gf @@ -407,6 +407,11 @@ oper VPF _ f => nombreVerb f } ; + isNotImperative : VPForm -> Bool = \v -> case v of { + VPF _ (VImper _) => False ; + _ => True + } ; + -- Predication is language-dependent in the negative case. predVerb : Verb -> VerbGroup = \aller -> @@ -520,7 +525,7 @@ oper Jean = jean.s ! (case2pformClit aime.c) ; AAime = formVerb2 aime g w ; A = AAime.verb ; - clit = (andB (isNounPhraseClit jean) (isTransVerbClit aime)) ; + clit = (andB (isNounPhraseClit jean) (andB (isTransVerbClit aime) (isNotImperative w))) ; Aime = if_then_Str clit (AAime.part ! pgen2gen jean.g ! jean.n) (AAime.part ! Masc ! Sg) diff --git a/lib/resource/spanish/AllResourceSpa.gf b/lib/resource/spanish/AllResourceSpa.gf new file mode 100644 index 000000000..9073a97c2 --- /dev/null +++ b/lib/resource/spanish/AllResourceSpa.gf @@ -0,0 +1,2 @@ +concrete AllResourceSpa of AllResource = RulesSpa, StructuralSpa ** {} ; + diff --git a/lib/resource/spanish/MorphoSpa.gf b/lib/resource/spanish/MorphoSpa.gf index dfa535eb2..145879f72 100644 --- a/lib/resource/spanish/MorphoSpa.gf +++ b/lib/resource/spanish/MorphoSpa.gf @@ -646,7 +646,7 @@ oper haber_10 : Str -> Verbum = \haber -> VI Part => h_ + "abido" ; VP (Pres Ind Sg P1) => h_ + "e" ; VP (Pres Ind Sg P2) => h_ + "as" ; - VP (Pres Ind Sg P3) => variants {h_ + "a" ; h_ + "ay"} ; + VP (Pres Ind Sg P3) => variants {h_ + "a"} ; ---- h_ + "ay"} ; VP (Pres Ind Pl P1) => h_ + "emos" ; VP (Pres Ind Pl P2) => h_ + "abéis" ; VP (Pres Ind Pl P3) => h_ + "an" ; diff --git a/lib/resource/spanish/ParadigmsSpa.gf b/lib/resource/spanish/ParadigmsSpa.gf new file mode 100644 index 000000000..9ce38b348 --- /dev/null +++ b/lib/resource/spanish/ParadigmsSpa.gf @@ -0,0 +1,238 @@ +--# -path=.:../romance:../abstract:../../prelude + +--1 Spanish Lexical Paradigms +-- +-- Aarne Ranta 2003 +-- +-- This is an API to the user of the resource grammar +-- for adding lexical items. It give shortcuts for forming +-- expressions of basic categories: nouns, adjectives, verbs. +-- +-- Closed categories (determiners, pronouns, conjunctions) are +-- accessed through the resource syntax API, $resource.Abs.gf$. +-- +-- The main difference with $MorphoIta.gf$ is that the types +-- referred to are compiled resource grammar types. We have moreover +-- had the design principle of always having existing forms, not stems, as string +-- arguments of the paradigms. +-- +-- The following modules are presupposed: + +resource ParadigmsSpa = + open Prelude, (Types = TypesSpa), SyntaxSpa, MorphoSpa, + ResourceSpa in { + +--2 Parameters +-- +-- To abstract over gender names, we define the following identifiers. + +oper + Bool : Type ; + Gender : Type ; + + masculine : Gender ; + feminine : Gender ; + +-- To abstract over number names, we define the following. + + Number : Type ; + + singular : Number ; + plural : Number ; + +-- To abstract over case names, we define the following. (Except for +-- some pronouns, the accusative is equal to the nominative, the +-- dative is formed by the preposition "a", and the genitive by the +-- preposition "di".) + + Case : Type ; + + nominative : Case ; + accusative : Case ; + dative : Case ; + genitive : Case ; + + prep_a : Case ; + prep_de : Case ; + + +--2 Nouns + +-- Worst case: two forms (singular + plural), +-- and the gender. + + mkN : (_,_ : Str) -> Gender -> N ; -- uomo, uomini, masculine + +-- Often it is enough with one form. If it ends with +-- "o" or "a", no gender is needed; if with something else, +-- the gender must be given. + + nVino : Str -> N ; -- vino (, vinos, masculine) + nRana : Str -> N ; -- rana (, ranas, feminine) + nPilar : Str -> Gender -> N ; -- pilar (, pilares), masculine + nTram : Str -> Gender -> N ; -- tram (, tram), masculine + +-- Nouns used as functions need a case and a preposition. The most common is "di". +-- Recall that the prepositions "a", "di", "da", "in", "su", "con" are treated +-- as part of the case (cf. above). + + funPrep : N -> Preposition -> N2 ; + funCase : N -> Case -> N2 ; + funDe : N -> N2 ; + +-- Proper names, with their gender. + + mkPN : Str -> Gender -> PN ; -- Giovanni, masculine + +-- On the top level, it is maybe $CN$ that is used rather than $N$, and +-- $NP$ rather than $PN$. + + mkCN : N -> CN ; + mkNP : Str -> Gender -> NP ; + + +--2 Adjectives + +-- Non-comparison one-place adjectives need four forms in the worst case. +-- A parameter tells if they are pre- or postpositions in modification. + + Position : Type ; + prepos : Position ; + postpos : Position ; + + mkA1 : (solo,sola,soli,sole,solamente : Str) -> Position -> A1 ; + +-- Adjectives ending with "o" and "e", and invariable adjectives, +-- are the most important regular patterns. + + adj1Solo : (solo : Str) -> Bool -> A1 ; + adj1Util : (a,b : Str) -> Bool -> A1 ; + adj1Blu : (blu : Str) -> Bool -> A1 ; + + +-- Two-place adjectives need a preposition and a case as extra arguments. + + mkA2 : A1 -> Preposition -> Case -> A2 ; -- divisibile per + +-- Comparison adjectives may need two adjectives, corresponding to the +-- positive and other forms. + + mkADeg : (buono, migliore : A1) -> ADeg ; + +-- In the completely regular case, the comparison forms are constructed by +-- the particle "più". + + aSolo : Str -> Position -> ADeg ; -- lento (, più lento) + aUtil : Str -> Str -> Position -> ADeg ; -- grave (, più grave) + aBlu : Str -> Position -> ADeg ; -- blu (, più blu) + +-- On top level, there are adjectival phrases. The most common case is +-- just to use a one-place adjective. + + apSolo : Str -> Position -> AP ; + apUtil : Str -> Str -> Position -> AP ; + apBlu : Str -> Position -> AP ; + + +--2 Verbs +-- +-- The fragment only has present tense so far, but in all persons. +-- The worst case needs nine forms (and is not very user-friendly). + +---- mkV : (_,_,_,_,_,_,_,_,_ : Str) -> V ; + +-- These are examples of standard conjugations. Other conjugations +-- can be extracted from the Italian functional morphology, which has full +-- "Bescherelle" tables. + + vAmar : Str -> V ; + vVender : Str -> V ; +---- vFinire : Str -> V ; +---- vCorrere : (_,_ : Str) -> V ; + +-- The verbs 'be' and 'have' are special. + + vSer : V ; + vHaber : V ; + +-- Two-place verbs, and the special case with direct object. Notice that +-- a particle can be included in a $V$. + + mkV2 : V -> Preposition -> Case -> V2 ; + tvDir : V -> V2 ; + +-- The idiom with "avere" and an invariable noun, such as "paura", "fame", +-- and a two-place variant with "di" + complement. + + averCosa : Str -> V ; + averCosaDe : Str -> V2 ; + +-- The definitions should not bother the user of the API. So they are +-- hidden from the document. +--. + Bool = Prelude.Bool ; + Gender = SyntaxSpa.Gender ; + Case = SyntaxSpa.Case ; + Number = SyntaxSpa.Number ; + + masculine = Masc ; + feminine = Fem ; + nominative = Types.nominative ; + accusative = Types.accusative ; + genitive = Types.genitive ; + dative = Types.dative ; + + singular = Types.singular ; + plural = Types.plural ; + prep_a = Types.CPrep P_a ; + prep_de = Types.CPrep Types.P_de ; + + singular = Types.singular ; + plural = Types.plural ; + + mkN a b g = mkCNomIrreg a b g ** {lock_N = <>} ; + + nVino = \vino -> mkCNom (nomVino vino) masculine ** {lock_N = <>} ; + nRana = \rana -> mkCNom (nomVino rana) feminine ** {lock_N = <>} ; + nPilar = \x,g -> mkCNom (nomPilar x) g ** {lock_N = <>} ; + nTram = \tram,g -> mkCNom (nomTram tram) g ** {lock_N = <>} ; + + funPrep = \n,p -> n ** complement p ** {lock_N2 = <>} ; + funCase = \n,p -> n ** complementCas p ** {lock_N2 = <>} ; + funDe a = funGen a ** {lock_N2 = <>} ; + mkPN s g = mkProperName s g ** {lock_PN = <>} ; + mkCN = UseN ; + mkNP s g = UsePN (mkPN s g) ; + + Position = Bool ; + prepos = adjPre ; + postpos = adjPost ; + mkA1 = \x,y,z,u,v,p -> mkAdjective (mkAdj x y z u v) p ** {lock_A1 = <>} ; + adj1Solo = \a,p -> mkAdjective (adjSolo a) p ** {lock_A1 = <>} ; + adj1Util = \a,b,p -> mkAdjective (adjUtil a b) p ** {lock_A1 = <>} ; + adj1Blu = \a,p -> mkAdjective (adjBlu a) p ** {lock_A1 = <>} ; + mkA2 = \a,p,c -> mkAdjCompl a postpos {s2 = p ; c = c} ** {lock_A2 = <>} ; + mkADeg = \b,m -> mkAdjDegr (mkAdjComp b.s m.s) b.p ** {lock_ADeg = <>} ; + aSolo = \a,p -> mkAdjDegrLong (adjSolo a) p ** {lock_ADeg = <>} ; + aUtil = \a,b,p -> mkAdjDegrLong (adjUtil a b) p ** {lock_ADeg = <>} ; + aBlu = \a,p -> mkAdjDegrLong (adjBlu a) p ** {lock_ADeg = <>} ; + apSolo a p = adj1Solo a p ** {lock_AP = <>} ; + apUtil a b p = adj1Util a b p ** {lock_AP = <>} ; + apBlu a p = adj1Blu a p ** {lock_AP = <>} ; + +-- mkV a b c d e f g h i = mkVerbPres a b c d e f g h i ** {lock_V = <>} ; + vAmar x = verbPres (zurrar_3 x) AHabere ** {lock_V = <>} ; + vVender x = verbPres (vender_4 x) AHabere ** {lock_V = <>} ; +-- vFinire x = verbFinire x ** {lock_V = <>} ; +-- vCorrere x y = verbCorrere x y ** {lock_V = <>} ; + vSer = verbSer ** {lock_V = <>} ; + vHaber = verbHaber ** {lock_V = <>} ; + mkV2 a b c = mkTransVerb a b c ** {lock_V2 = <>} ; + tvDir c = mkTransVerbDir c ** {lock_V2 = <>} ; + + averCosa = \fame -> + {s = let {aver = vHaber.s} in \\v => aver ! v ++ fame} ** + {aux=AHabere ; lock_V = <>} ; + averCosaDe = \fame -> mkV2 (averCosa fame) [] prep_de ** {lock_TV = <>} ; + +} diff --git a/lib/resource/spanish/ResourceSpa.gf b/lib/resource/spanish/ResourceSpa.gf new file mode 100644 index 000000000..01163edc7 --- /dev/null +++ b/lib/resource/spanish/ResourceSpa.gf @@ -0,0 +1,3 @@ +--# -path=.:../romance:../abstract:../../prelude + +instance ResourceSpa of Resource = reuse AllResourceSpa ; diff --git a/lib/resource/spanish/StructuralSpa.gf b/lib/resource/spanish/StructuralSpa.gf index 21ee7135c..b81f9a317 100644 --- a/lib/resource/spanish/StructuralSpa.gf +++ b/lib/resource/spanish/StructuralSpa.gf @@ -12,6 +12,7 @@ lin YeNumNP n = pronNounPhrase (pronWithNum pronVous n) ; YouNP = pronNounPhrase pronVous ; TheyNP = pronNounPhrase pronIls ; + TheyFemNP = pronNounPhrase pronElles ; -- Here is a point where the API is really inadequate for French, -- which distinguishes between masculine and feminine "they". @@ -31,6 +32,7 @@ lin AllNumDet = mkDeterminerNum plural ["todos los"] ["todas las"] ; WhichDet = quelDet ; WhichNumDet = mkDeterminerNum plural "cuales" "cuales" ; + HowManyDet = mkDeterminer plural "cuántos" "cuántas" ; MostsDet = plupartDet ; MostDet = mkDeterminer1 singular (["la mayor parte"] ++ elisDe) ; --- de SomeDet = mkDeterminer singular "alguno" "alguna" ; @@ -76,10 +78,11 @@ lin SomethingNP = mkNameNounPhrase ["algo"] Masc ; NothingNP = mkNameNounPhrase ["nada"] Masc ; --- ne ----- CanVV = mkVerbVerbDir (verbPres (potere_72 "potere") AHabere) ; ----- CanKnowVV = mkVerbVerbDir (verbPres (sapere_81 "sapere") AHabere) ; ----- MustVV = mkVerbVerbDir (verbPres (dovere_50 "dovere") AHabere) ; ----- WantVV = mkVerbVerbDir (verbPres (volere_99 "volere") AHabere) ; +---- provisory, for completeness + CanVV = mkVerbVerbDir (verbPres (vender_4 "poder") AHabere) ; ---- + CanKnowVV = mkVerbVerbDir (verbPres (vender_4 "saber") AHabere) ; ---- + MustVV = mkVerbVerbDir (verbPres (vender_4 "deber") AHabere) ; ---- + WantVV = mkVerbVerbDir (verbPres (vender_4 "quierer") AHabere) ; ---- EverywhereNP = ss ["en todas partes"] ; SomewhereNP = ss ["en ninguna parte"] ; diff --git a/lib/resource/spanish/SyntaxSpa.gf b/lib/resource/spanish/SyntaxSpa.gf index a98452454..1353f53b3 100644 --- a/lib/resource/spanish/SyntaxSpa.gf +++ b/lib/resource/spanish/SyntaxSpa.gf @@ -277,19 +277,30 @@ oper Clit3 ; pronIls = mkPronoun - "ellos" ---- ellas + "ellos" "los" "les" "ellos" "su" "su" "sus" "sus" - PNoGen + (PGen Masc) + Pl + P3 + Clit1 ; + + pronElles = mkPronoun + "ellas" + "las" + "les" + "ellas" + "su" "su" "sus" "sus" + (PGen Fem) Pl P3 Clit1 ; commentAdv = ss "como" ; quandAdv = ss "cuando" ; - ouAdv = ss "o" ; + ouAdv = ss "donde" ; pourquoiAdv = ss "porqué" ; etConj = ss "y" ** {n = Pl} ; diff --git a/lib/resource/spanish/TestResourceSpa.gf b/lib/resource/spanish/TestResourceSpa.gf index 82f99d868..e648ab793 100644 --- a/lib/resource/spanish/TestResourceSpa.gf +++ b/lib/resource/spanish/TestResourceSpa.gf @@ -17,7 +17,8 @@ lin Man = mkCNom (nomVino "hombre") Masc ; Woman = mkCNom (nomPilar "mujer") Fem ; Car = mkCNom (nomVino "coche") Masc ; - Light = mkCNom (nomPilar "luz") Fem ; + Light = mkCNom (numForms "luz" "luces") Fem ; + Level = mkCNom (nomPilar "nivel") Masc ; House = mkCNom (nomVino "casa") Fem ; Wine = mkCNom (nomVino "vino") Masc ; Bottle = mkCNom (nomVino "botella") Fem ; @@ -32,7 +33,7 @@ lin Prefer = mkDitransVerb (verbPres (zurrir_5 "preferir") AHabere) [] accusative [] dative ; ---- Say = verbSent (verbPres (dire_44 "dire") AHabere) Ind Ind ; Prove = verbSent (verbPres (zurrar_3 "demonstrar") AHabere) Ind Ind ; ----- SwitchOn = mkTransVerbDir (verbPres (zurrar_3 "encender") AHabere) ; + SwitchOn = mkTransVerbDir (verbPres (vender_4 "enciender") AHabere) ; ---- SwitchOff = mkTransVerbDir (verbPres (zurrar_3 "apagar") AHabere) ; Mother = funGen (mkCNom (nomVino "madre") Fem) ; Uncle = funGen (mkCNom (nomVino "zio") Masc) ; diff --git a/lib/resource/swedish/AllResourceSwe.gf b/lib/resource/swedish/AllResourceSwe.gf new file mode 100644 index 000000000..e1a391358 --- /dev/null +++ b/lib/resource/swedish/AllResourceSwe.gf @@ -0,0 +1,2 @@ +concrete AllResourceSwe of AllResource = RulesSwe, StructuralSwe ** {} ; + diff --git a/lib/resource/swedish/ParadigmsSwe.gf b/lib/resource/swedish/ParadigmsSwe.gf new file mode 100644 index 000000000..3e1c0389d --- /dev/null +++ b/lib/resource/swedish/ParadigmsSwe.gf @@ -0,0 +1,365 @@ +--# -path=.:../abstract:../../prelude + +--1 Swedish Lexical Paradigms +-- +-- Aarne Ranta 2003 +-- +-- This is an API to the user of the resource grammar +-- for adding lexical items. It give shortcuts for forming +-- expressions of basic categories: nouns, adjectives, verbs. +-- +-- Closed categories (determiners, pronouns, conjunctions) are +-- accessed through the resource syntax API, $Structural.gf$. +-- +-- The main difference with $MorphoSwe.gf$ is that the types +-- referred to are compiled resource grammar types. We have moreover +-- had the design principle of always having existing forms, not stems, as string +-- arguments of the paradigms. +-- +-- The following modules are presupposed: + +resource ParadigmsSwe = open (Predef=Predef), Prelude, SyntaxSwe, ResourceSwe in { + +--2 Parameters +-- +-- To abstract over gender names, we define the following identifiers. + +oper + Gender : Type ; + utrum : Gender ; + neutrum : Gender ; + + Sex : Type ; + + masculine : Sex ; + nonmasculine : Sex ; + +-- To abstract over case names, we define the following. + + Case : Type ; + + nominative : Case ; + genitive : Case ; + +-- To abstract over number names, we define the following. + Number : Type ; + + singular : Number ; + plural : Number ; + + + +--2 Nouns + +-- Worst case: give all nominative forms and the gender. +-- The genitive is formed automatically, even when the nominative +-- ends with an "s". + + mkN : (_,_,_,_ : Str) -> Gender -> Sex -> N ; + -- man, mannen, män, männen + +-- Here are some common patterns, corresponding to school-gramamr declensions. +-- Except $nPojke$, $nKarl$, and $nMurare$, +-- they are defined to be $nonmasculine$, which means that they don't create +-- the definite adjective form with "e" but with "a". + + nApa : Str -> N ; -- apa (apan, apor, aporna) ; utrum + nBil : Str -> N ; -- bil (bilen, bilar, bilarna) ; utrum + nKarl : Str -> N ; -- karl (karlen, karlar, karlarna) ; utrum ; masculine + nPojke : Str -> N ; -- pojke (pojken, pojkar, pojkarna) ; utrum ; masculine + nNyckel : Str -> N ; -- nyckel (nyckeln, nycklar, nycklarna) ; utrum + nRisk : Str -> N ; -- risk (risken, risker, riskerna) ; utrum + nDike : Str -> N ; -- dike (diket, diken, dikena) ; neutrum + nRep : Str -> N ; -- rep (repet, rep, repen) ; neutrum + nPapper : Str -> N ; -- papper (pappret, papper, pappren) ; neutrum + nMurare : Str -> N ; -- murare (muraren, murare, murarna) ; utrum ; masculine + nKikare : Str -> N ; -- kikare (kikaren, kikare, kikarna) ; utrum + +-- Nouns used as functions need a preposition. The most common ones are "av", +-- "på", and "till". A preposition is a string. + + mkN2 : N -> Str -> N2 ; + funAv : N -> N2 ; + funPaa : N -> N2 ; + funTill : N -> N2 ; + +-- Proper names, with their possibly +-- irregular genitive. The regular genitive is "s", omitted after "s". + + mkPN : (_,_ : Str) -> Gender -> Sex -> PN ; -- Karolus, Karoli + pnReg : Str -> Gender -> Sex -> PN ; -- Johan,Johans ; Johannes, Johannes + pnS : Str -> Gender -> Sex -> PN ; -- "Burger King(s)" + +-- On the top level, it is maybe $CN$ that is used rather than $N$, and +-- $NP$ rather than $PN$. + + mkCN : N -> CN ; + mkNP : (Karolus, Karoli : Str) -> Gender -> NP ; + + npReg : Str -> Gender -> NP ; -- Johann, Johanns + + +--2 Adjectives + +-- Non-comparison one-place adjectives need four forms in the worst case: +-- strong singular, weak singular, plural. + + mkA1 : (_,_,_,_ : Str) -> A1 ; -- liten, litet, lilla, små + +-- Special cases needing one form each are: regular adjectives, +-- adjectives with unstressed "e" in the last syllable, those +-- ending with "n" as a further special case, and invariable +-- adjectives. + + adjReg : Str -> A1 ; -- billig (billigt, billiga, billiga) + adjNykter : Str -> A1 ; -- nykter (nyktert, nyktra, nyktra) + adjGalen : Str -> A1 ; -- galen (galet, galna, galna) + adjInvar : Str -> A1 ; -- bra + +-- Two-place adjectives need a preposition and a case as extra arguments. + + mkA2 : A1 -> Str -> A2 ; -- delbar, med + mkA2Reg : Str -> Str -> A2 ; -- + +-- Comparison adjectives may need the three four forms for the positive case, plus +-- three more forms for the comparison cases. + + mkADeg : (liten, litet, lilla, sma, mindre, minst, minsta : Str) -> ADeg ; + +-- Some comparison adjectives are completely regular. + + aReg : Str -> ADeg ; + +-- On top level, there are adjectival phrases. The most common case is +-- just to use a one-place adjective. The variation in $adjGen$ is taken +-- into account. + + apReg : Str -> AP ; + +--2 Adverbs + +-- Adverbs are not inflected. Most lexical ones have position not +-- before the verb. Some can be preverbal (e.g. "alltid"). + + mkAdv : Str -> Adv ; + mkAdvPre : Str -> Adv ; + +-- Adverbs modifying adjectives and sentences can also be formed. + + mkAdA : Str -> AdA ; + mkAdS : Str -> AdS ; + +-- Prepositional phrases are another productive form of adverbials. + + mkPP : Str -> NP -> Adv ; + + +--2 Verbs +-- +-- The fragment only has present tense so far. +-- The worst case needs three forms: the infinitive, the indicative, and the +-- imperative. + + Voice: Type; + + passive : Voice; + active: Voice; + + mkV : (_,_,_,_,_,_ : Str) -> V ; -- vara, är, var; trivas, trivs, trivs + +-- The main conjugations need one string each. + + vKoka : Str -> V ; -- tala (talar, tala) + vSteka : Str -> V ; -- leka (leker, lek) +---- vBo : Str -> V ; -- bo (bor, bo) + +---- vAndas : Str -> V ; -- andas [all forms the same: also "slåss"] +---- vTrivas : Str -> V ; -- trivas (trivs, trivs) + +-- The verbs 'be' and 'have' are special. + + vVara : V ; + vHa : V ; + +-- Particle verbs are formed by putting together a verb and a particle. +-- If the verb already has a particle, it is replaced by the new one. + + mkPartV : V -> Str -> V ; -- stänga av ; + +-- Two-place verbs, and the special case with direct object. + + mkV2 : V -> Str -> V2 ; -- tycka, om + tvDir : V -> V2 ; -- gilla + +-- Ditransitive verbs. + + mkV3 : V -> Str -> Str -> V3 ; -- prata, med, om + v3Dir : V -> Str -> V3 ; -- ge,_,till + v3DirDir : V -> V3 ; -- ge,_,_ + +-- Sentence complement verbs. + + mkVS : V -> VS ; -- säga (att ...) + +-- Verb phrase complement verbs. + + vvInf : V -> VV ; -- orka (spela) + vvAtt : V -> VV ; -- gilla (att spela) + vvBoth : V -> VV ; -- försöka (spela | att spela) + + +-- The definitions should not bother the user of the API. So they are +-- hidden from the document. +--. + + Gender = SyntaxSwe.Gender ; + Sex = SyntaxSwe.Sex ; + Case = SyntaxSwe.Case ; + Number = SyntaxSwe.Number ; + Voice = SyntaxSwe.Voice ; + + utrum = Utr ; + neutrum = Neutr ; + masculine = Masc ; + nonmasculine = NoMasc ; + nominative = Nom ; + genitive = Gen ; + singular = Sg ; + plural = Pl ; + + active = Act; + passive = Pass; + + mkN = \apa, apan, apor, aporna, g, x -> let + {nom = table { + SF Sg Indef _ => apa ; + SF Sg Def _ => apan ; + SF Pl Indef _ => apor ; + SF Pl Def _ => aporna + } + } in + {s = \\n,d,c => mkCase c (nom ! SF n d Nom) ; + g = g ; x = x ; lock_N = <> + } ; + + -- auxiliaries + mkGenit : Tok -> Tok = \s -> ifTok Tok (Predef.dp 1 s) "s" s (s + "s") ; + mkCase : Case -> Tok -> Tok = \c,t -> case c of { + Nom => t ; + Gen => mkGenit t + } ; + + nApa = \apa -> + let {apor = Predef.tk 1 apa + "or"} in + mkN apa (apa + "n") apor (apor + "na") utrum nonmasculine ; + + nBil = \bil -> + mkN bil (bil + "en") (bil + "ar") (bil + "arna") utrum nonmasculine ; + nKarl = \bil -> + mkN bil (bil + "en") (bil + "ar") (bil + "arna") utrum masculine ; + nPojke = \pojke -> + let {bil = Predef.tk 1 pojke} in + mkN pojke (bil + "en") (bil + "ar") (bil + "arna") utrum masculine ; + nNyckel = \cykel -> + let {cykl = Predef.tk 2 cykel + Predef.dp 1 cykel} in + mkN cykel (cykel + "n") (cykl + "ar") (cykl + "arna") utrum nonmasculine ; + nRisk = \bil -> + mkN bil (bil + "en") (bil + "er") (bil + "erna") utrum nonmasculine ; + nDike = \dike -> + mkN dike (dike + "t") (dike + "n") (dike + "na") neutrum nonmasculine ; + nRep = \rep -> + mkN rep (rep + "et") rep (rep + "en") neutrum nonmasculine ; + nPapper = \cykel -> + let {cykl = Predef.tk 2 cykel + Predef.dp 1 cykel} in + mkN cykel (cykl + "et") cykel (cykl + "en") neutrum nonmasculine ; + nMurare = \murare -> + let {murar = Predef.tk 1 murare} in + mkN murare (murar + "en") murare (murar + "na") utrum masculine ; + nKikare = \murare -> + let {murar = Predef.tk 1 murare} in + mkN murare (murar + "en") murare (murar + "na") utrum nonmasculine ; + + + mkN2 x y = mkFun x y ** {lock_N2 = <>} ; + funAv = \f -> mkN2 f "av" ; + funPaa = \f -> mkN2 f "på" ; + funTill = \f -> mkN2 f "till" ; + + mkPN = \karolus, karoli, g, x -> + {s = table {Gen => karoli ; _ => karolus} ; g = g ; x = x ; lock_PN = <>} ; + pnReg = \horst -> + mkPN horst (ifTok Tok (Predef.dp 1 horst) "s" horst (horst + "s")) ; + pnS = \bk -> + mkPN bk (bk + "s") ; + + mkCN = UseN ; + mkNP = \a,b,g -> UsePN (mkPN a b g nonmasculine) ; -- gender irrelevant in NP + npReg = \s,g -> UsePN (pnReg s g nonmasculine) ; + + mkA1 = \liten, litet, lilla, små -> + {s = table { + Strong (ASg Utr) => \\c => mkCase c liten ; + Strong (ASg Neutr) => \\c => mkCase c litet ; + Strong APl => \\c => mkCase c små ; + Weak (AxSg Masc) => \\c => mkCase c (Predef.tk 1 lilla + "e") ; + Weak _ => \\c => mkCase c lilla + } ; + lock_A1 = <> + } ; + + adjReg = \billig -> mkA1 billig (billig + "t") (billig + "a") (billig + "a") ; + adjNykter = \nykter -> + let {nyktr = Predef.tk 2 nykter + Predef.dp 1 nykter} in + mkA1 nykter (nykter + "t") (nyktr + "a") (nyktr + "a") ; + adjGalen = \galen -> + let {gal = Predef.tk 2 galen} in + mkA1 galen (gal + "et") (gal + "na") (gal + "na") ; + adjInvar = \bra -> {s = \\_,_ => bra ; lock_A1 = <>} ; + + mkA2 = \a,p -> a ** {s2 = p ; lock_A2 = <>} ; + mkA2Reg = \a -> mkA2 (adjReg a) ; + + mkADeg = \liten, litet, lilla, sma, mindre, minst, minsta -> + let {lit = (mkA1 liten litet lilla sma).s} in + {s = table { + AF (Posit f) c => lit ! f ! c ; + AF Compar c => mkCase c mindre ; + AF (Super SupStrong) c => mkCase c minst ; + AF (Super SupWeak) c => mkCase c minsta --- masculine! + } ; + lock_ADeg = <> + } ; + + aReg = \fin -> mkADeg fin + (fin + "t") (fin + "a") (fin + "a") (fin + "are") (fin + "ast") (fin + "aste") ; + + apReg = \s -> UseA1 (adjReg s) ; + + mkAdv a = advPost a ** {lock_Adv = <>} ; + mkAdvPre a = advPre a ** {lock_Adv = <>} ; + mkPP x y = prepPhrase x y ** {lock_Adv = <>} ; + mkAdA a = ss a ** {lock_AdA = <>} ; + mkAdS a = ss a ** {lock_AdS = <>} ; + + mkV x y z a b c = mkVerb x y z a b c ** {lock_V = <>} ; + vKoka = \tala -> vTala (Predef.tk 1 tala) ** {s1 = [] ; lock_V = <>} ; + vSteka = \leka -> vLeka (Predef.tk 1 leka) ** {s1 = [] ; lock_V = <>} ; +---- vBo = \bo -> mkV bo (bo+"r") bo ; +---- vAndas = \andas -> mkV andas andas andas ; +---- vTrivas = \trivas -> +---- let {trivs = Predef.tk 1 trivas + "s"} in mkV trivas trivs trivs ; + vVara = verbVara ** {s1 = [] ; lock_V = <>} ; + vHa = verbHava ** {s1 = [] ; lock_V = <>} ; + mkPartV v p = {s = v.s ; s1 = p ; lock_V = <>} ; + mkV2 x y = mkTransVerb x y ** {lock_V2 = <>} ; + tvDir = \v -> mkV2 v [] ; + mkV3 x y z = mkDitransVerb x y z ** {lock_V3 = <>} ; + v3Dir x y = mkV3 x [] y ; + v3DirDir x = v3Dir x [] ; + + mkVS v = v ** {lock_VS = <>} ; + vvInf v = v ** {isAux = True ; lock_VV = <>} ; + vvAtt v = v ** {isAux = False ; lock_VV = <>} ; + vvBoth v = v ** {isAux = variants {False ; True} ; lock_VV = <>} ; + +} ; diff --git a/lib/resource/swedish/ResourceSwe.gf b/lib/resource/swedish/ResourceSwe.gf new file mode 100644 index 000000000..2c692c437 --- /dev/null +++ b/lib/resource/swedish/ResourceSwe.gf @@ -0,0 +1,3 @@ +--# -path=.:../abstract:../../prelude + +instance ResourceSwe of Resource = reuse AllResourceSwe ; diff --git a/lib/resource/swedish/RulesSwe.gf b/lib/resource/swedish/RulesSwe.gf index 987464b1f..7f2e801ce 100644 --- a/lib/resource/swedish/RulesSwe.gf +++ b/lib/resource/swedish/RulesSwe.gf @@ -31,6 +31,12 @@ lin x = cn.x ; p = cn.p } ; + IntCN cn s = + {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; + g = cn.g ; + x = cn.x ; + p = cn.p + } ; CNthatS = nounThatSentence ; diff --git a/lib/resource/swedish/StructuralSwe.gf b/lib/resource/swedish/StructuralSwe.gf index 1ad63bc07..1956a7d96 100644 --- a/lib/resource/swedish/StructuralSwe.gf +++ b/lib/resource/swedish/StructuralSwe.gf @@ -15,6 +15,7 @@ concrete StructuralSwe of Structural = WeNumNP n = pronNounPhrase (pronWithNum vi_36 n) ; YeNumNP n = pronNounPhrase (pronWithNum ni_37 n) ; TheyNP = pronNounPhrase de_38 ; + TheyFemNP = pronNounPhrase de_38 ; YouNP = let {ni = pronNounPhrase ni_37 } in {s = ni.s ; g = ni.g ; n = Sg} ; @@ -34,6 +35,7 @@ concrete StructuralSwe of Structural = SomeDet = mkDeterminerSgGender2 "någon" "något" IndefP ; SomeNumDet = mkDeterminerPlNum "några" IndefP ; ManyDet = mkDeterminerPl "många" IndefP ; + HowManyDet = mkDeterminerPl ["hur många"] IndefP ; NoDet = mkDeterminerSgGender2 "ingen" "inget" IndefP ; NoNumDet = mkDeterminerPlNum "inga" IndefP ; WhichNumDet = mkDeterminerPlNum "vilka" IndefP ;