diff --git a/lib/resource/russian/CategoriesRus.gf b/lib/resource/russian/CategoriesRus.gf index 50461f0d1..d225c59ef 100644 --- a/lib/resource/russian/CategoriesRus.gf +++ b/lib/resource/russian/CategoriesRus.gf @@ -47,7 +47,7 @@ lincat Det = Determiner ; -- = Adjective ** {n: Number; g: PronGen; c: Case} ; - NDet = Adjective ** {g: PronGen; c: Case} ; + NDet = NoNumberDeterminer ; -- "Det" without "Number" field N2 = Function ; @@ -95,9 +95,9 @@ lincat -- = {s : Bool => ClForm => Str} ; S = Sentence ; -- = {s : Str} ; - Slash = SentenceSlashNounPhrase ; - -- sentence without NP, e.g. "John waits for (...)" - -- = Sentence ** Complement ; + Slash = SlashNounPhrase ; + -- = Clause ** Complement ; + -- = {s : Bool => ClForm => Str; s2: Str; c: Case} ; RP = RelPron ; -- = {s : GenNum => Case => Animacy => Str} ; @@ -109,13 +109,14 @@ lincat -- = NounPhrase ; IDet = Determiner ; -- = Adjective ** {n: Number; g: PronGen; c: Case} ; - + IAdv = Adverb ; -- = {s : Str} ; QS = Question ; -- question w. fixed tense -- = {s : QuestForm => Str} ; - QCl = {s :Bool => ClForm => QuestForm => Str}; + QCl = QuestionCl ; + -- = {s :Bool => ClForm => QuestForm => Str}; Imp = Imperative ; -- = { s: Gender => Number => Str } ; @@ -132,7 +133,8 @@ lincat ListNP = ListNounPhrase ; -- = { s1,s2 : PronForm => Str ; g: Gender ; anim : Animacy ; -- n : Number ; p : Person ; pron : Bool } ; - ListAdv= {s1 : Str ; s2 : Str} ; + ListAdv= ListAdverb ; + -- = {s1, s2 : Str} ; Phr = Utterance ; -- = {s : Str} ; @@ -153,7 +155,7 @@ lincat AS = Adverb ; -- = {s : Str} ; A2S = Adverb ** Complement; - AV = Adjective ; + AV = Adjective ; --- "eager to leave" -- = {s : AdjForm => Str} ; A2V = AdjCompl ; -- = Adjective ** Complement ; diff --git a/lib/resource/russian/RulesRus.gf b/lib/resource/russian/RulesRus.gf index 16b3684f7..5a99d3fd7 100644 --- a/lib/resource/russian/RulesRus.gf +++ b/lib/resource/russian/RulesRus.gf @@ -5,9 +5,8 @@ lin UsePN = nameNounPhrase ; ComplA2 = complAdj ; --- ComplAV : AV -> VPI -> AP ; -- "eager to leave" --- ComplObjA2V : A2V -> NP -> VPI -> AP ; -- "easy for us to convince" - PredVP = predVerbPhrase ; + ComplAV = complVerbAdj ; + ComplObjA2V = complObjA2V ; UseA = adj2adjPhrase ; ModAP = modCommNounPhrase ; UseN = noun2CommNounPhrase ; @@ -18,8 +17,7 @@ lin AppN3 = appFun2 ; PositADeg = positAdjPhrase ; ComparADeg = comparAdjPhrase ; - --- SuperlNP = superlNounPhrase ; --- SuperlADeg : ADeg -> AP ; -- "the oldest" + SuperlADeg = superlAdjPhrase ; CNthatS = nounThatSentence ; @@ -33,23 +31,23 @@ lin DefOneNP = indefNounPhrase Sg ; DefNumNP = indefNounPhraseNum Pl ; MassNP = indefNounPhrase Sg; --- NDetNP : NDet -> Num -> CN -> NP ; -- "these (5) cars" --- NDetNum : NDet -> Num -> NP ; -- "these (5)" + NDetNP = nDetNP ; + NDetNum = nDetNum ; - PosVG = predVerbGroup True Present ; - NegVG = predVerbGroup False Present ; - - PredV = predVerb ; - PredAP = predAdjective ; - PredCN = predCommNoun ; - PredV2 = complTransVerb ; - PredV3 = complDitransVerb ; - PredPassV = predPassVerb ; - PredNP = predNounPhrase ; - PredPP = predAdverb ; - PredVS = complSentVerb ; - PredVV = complVerbVerb ; - VTrans = verbOfTransVerb ; +--- PosVG = predVerbGroup True Present ; +--- NegVG = predVerbGroup False Present ; +--- PredVP = predVerbPhrase ; +--- PredV = predVerb ; +--- PredAP = predAdjective ; +--- PredCN = predCommNoun ; +--- PredV2 = complTransVerb ; +--- PredV3 = complDitransVerb ; +--- PredPassV = predPassVerb ; +--- PredNP = predNounPhrase ; +--- PredPP = predAdverb ; +--- PredVS = complSentVerb ; +--- PredVV = complVerbVerb ; +--- VTrans = verbOfTransVerb ; -- The main uses of verbs and verb phrases have been moved to the -- module $Verbphrase$ (deep $VP$ nesting) and its alternative, @@ -97,65 +95,67 @@ lin PNeg = {s = [] ; p = False} ; --- AdvPP : PP -> Adv ; -- "in London", "after the war" --- AdvAdv : AdA -> Adv -> Adv ; -- "very well" + AdvPP x = x ; + AdvAdv = advAdv ; AdjAdv a = mkAdverb (a.s ! AdvF) ; PrepNP p = prepPhrase p ; AdvVPI = adVerbPhraseInf ; - ---AdvVP = adVerbPhrase ; - ---LocNP = locativeNounPhrase ; AdvCN = advCommNounPhrase ; AdvAP = advAdjPhrase ; + AdvCl = advClause ; + AdCPhr = advSentencePhr ; + AdvPhr = advSentencePhr ; + +---AdvVP = adVerbPhrase ; +---LocNP = locativeNounPhrase ; + + + IdRP = identRelPron ; + FunRP = funRelPron ; + + RelCl = relCl; + RelSlash = relSlash ; + +--- ModRC = modRelClause ; +--- RelSuch = relSuch ; +--- RelVP = relVerbPhrase ; +--- PosSlashV2 = slashTransVerb True ; +--- NegSlashV2 = slashTransVerb False ; +--- OneVP = predVerbPhrase (pron2NounPhrase pronKtoTo Animate) ; +--- ThereNP = thereIs ; + +--- WhoOne = intPronKto Sg ; +--- WhoMany = intPronKto Pl ; +--- WhatOne = intPronChto Sg ; +--- WhatMany = intPronChto Pl ; +--- NounIPOne = nounIntPron Sg ; +--- NounIPMany = nounIntPron Pl ; +--- SuperlNP = superlNounPhrase ; +--- QuestVP = questVerbPhrase ; +--- IntVP = intVerbPhrase ; +--- ImperVP = imperVerbPhrase ; + + FunIP = funIntPron ; + QuestAdv = questAdverbial ; + + IndicPhrase = indicUtt ; + QuestPhrase = interrogUtt ; + ImperOne = imperUtterance Masc Sg ; + ImperMany = imperUtterance Masc Pl ; + +-- IDetCN : IDet -> CN -> IP ; -- "which car", "which cars" -- SlashV2 : NP -> V2 -> Slash ; -- "(whom) John doesn't love" -- SlashVV2 : NP -> VV -> V2 -> Slash ; -- "(which song do you) want to play" -- SlashAdv : Cl -> Prep -> Slash ; -- "(whom) John walks with" - PosSlashV2 = slashTransVerb True ; - NegSlashV2 = slashTransVerb False ; - OneVP = predVerbPhrase (pron2NounPhrase pronKtoTo Animate) ; - ThereNP = thereIs ; +-- IntSlash = intSlash ; +-- QuestCl : Cl -> QCl ; -- "does John walk"; "doesn't John walk" - IdRP = identRelPron ; - FunRP = funRelPron ; - RelVP = relVerbPhrase ; - RelSlash = relSlash ; - ModRC = modRelClause ; - RelSuch = relSuch ; --- RelCl : Cl -> RCl ; -- "such that it is even" - - - WhoOne = intPronKto Sg ; - WhoMany = intPronKto Pl ; - WhatOne = intPronChto Sg ; - WhatMany = intPronChto Pl ; - FunIP = funIntPron ; --- IDetCN : IDet -> CN -> IP ; -- "which car", "which cars" - - NounIPOne = nounIntPron Sg ; - NounIPMany = nounIntPron Pl ; - - QuestVP = questVerbPhrase ; - ---IntVP = intVerbPhrase ; - IntSlash = intSlash ; --- QuestCl : Cl -> QCl ; -- "does John walk"; "doesn't John walk" - - - QuestAdv = questAdverbial ; - - - ---ImperVP = imperVerbPhrase ; -- PosImpVP, NegImpVP : VCl -> Imp ; -- "(don't) be a man" - IndicPhrase = indicUtt ; - QuestPhrase = interrogUtt ; - ImperOne = imperUtterance Masc Sg ; - ImperMany = imperUtterance Masc Pl ; - AdvCl = advClause ; --- AdCPhr : AdC -> S -> Phr ; -- "Therefore, 2 is prime." --- AdvPhr : Adv -> S -> Phr ; -- "In India, there are tigers." TwoS = twoSentence ; ConsS = consSentence ; @@ -172,23 +172,24 @@ lin ConjNP = conjunctNounPhrase ; ConjDNP = conjunctDistrNounPhrase ; --- ConjAdv : Conj -> ListAdv -> Adv ; -- "quickly or slowly" --- ConjDAdv : ConjD -> ListAdv -> Adv ; -- "both badly and slowly" --- TwoAdv : Adv -> Adv -> ListAdv ; --- ConsAdv : ListAdv -> Adv -> ListAdv ; + ConjAdv = conjAdverb ; + ConjDAdv = conjDAdverb ; + TwoAdv = twoAdverb ; + ConsAdv = consAdverb ; - SubjS = subjunctSentence ; - SubjImper = subjunctImperative ; - SubjQu = subjunctQuestion ; --- SubjQS : Subj -> S -> QS -> QS ; -- "if you are new, who are you?" - SubjVP = subjunctVerbPhrase ; + SubjQS = subjQS ; -- This rule makes a subordinate clause into a sentence adverb, which -- can be attached to e.g. noun phrases. It might even replace the -- previous subjunction rules. --- AdvSubj : Subj -> S -> Adv ; -- "when he arrives" + AdvSubj = advSubj ; + +--- SubjS = subjunctSentence ; +--- SubjImper = subjunctImperative ; +--- SubjQu = subjunctQuestion ; +--- SubjVP = subjunctVerbPhrase ; PhrNP = useNounPhrase ; PhrOneCN = useCommonNounPhrase Sg ; @@ -197,8 +198,7 @@ lin PhrIAdv ia = postfixSS "?" ia ; OnePhr p = p ; ConsPhr = cc2 ; - --- PhrVPI : VPI -> Phr ; -- "Tnda ljus." + PhrVPI = phrVPI ; --2 Special constructs. -- @@ -210,12 +210,5 @@ lin OneNP = npOne ; ---New in the "lib"-version from Swedish: - - AdvPP p = p ; - PredSuperl a = predAdjective (superlAdjPhrase a) ; - PrepS p = ss (p.s ++ ",") ; - PredVG = predVerbGroupClause ; - } ; diff --git a/lib/resource/russian/SyntaxRus.gf b/lib/resource/russian/SyntaxRus.gf index 4312775ae..a4991f89e 100644 --- a/lib/resource/russian/SyntaxRus.gf +++ b/lib/resource/russian/SyntaxRus.gf @@ -108,8 +108,57 @@ Numeral : Type = {s : Case => Gender => Str} ; -- The determined noun has the case parameter specific for the determiner: Determiner : Type = Adjective ** { n: Number; g: PronGen; c : Case } ; + NoNumberDeterminer = Adjective ** {g: PronGen; c: Case} ; anyPlDet = kakojNibudDet ** {n = Pl; c= Nom} ; + + iDetCN : Determiner -> CommNounPhrase -> IntPron = \kakoj, okhotnik -> + {s = \\c => case kakoj.c of { + Nom => + kakoj.s ! AF (extCase c) okhotnik.anim (gNum okhotnik.g kakoj.n) ++ + okhotnik.s ! kakoj.n ! (extCase c) ; + _ => + kakoj.s ! AF (extCase c) okhotnik.anim (gNum okhotnik.g kakoj.n) ++ + okhotnik.s ! kakoj.n ! kakoj.c }; + n = kakoj.n ; + p = P3 ; + pron = False; + g = kakoj.g ; + anim = okhotnik.anim + } ; + +nDetNP : NoNumberDeterminer -> Numeral -> CommNounPhrase -> NounPhrase =\eti,pyat, okhotnik -> + { s=\\c => case eti.c of { + Nom => + eti.s ! AF (extCase c) Inanimate (gNum (pgen2gen eti.g) Pl) ++ + pyat.s ! (extCase c) ! (pgen2gen eti.g)++ okhotnik.s ! Pl ! (extCase c); + _ => + eti.s ! AF (extCase c) Inanimate (gNum (pgen2gen eti.g) Pl) ++ + pyat.s ! eti.c ! (pgen2gen eti.g) ++ okhotnik.s ! Pl ! eti.c }; + + n = Pl ; + p = P3 ; + pron = False; + g = eti.g ; + anim = okhotnik.anim + }; + + nDetNum: NoNumberDeterminer -> Numeral -> NounPhrase =\eti,pyat -> + { s=\\c => case eti.c of { + Nom => + eti.s ! AF (extCase c) Inanimate (gNum (pgen2gen eti.g) Pl) ++ + pyat.s ! (extCase c) ! (pgen2gen eti.g); + _ => + eti.s ! AF (extCase c) Inanimate (gNum (pgen2gen eti.g) Pl) ++ + pyat.s ! eti.c ! (pgen2gen eti.g) }; + + n = Pl ; + p = P3 ; + pron = False; + g = eti.g ; + anim = Inanimate + }; + mkDeterminerNum : Determiner -> Numeral -> Determiner = \vse,dva -> {s =\\af => vse.s ! af ++ dva.s ! (caseAF af) ! (genAF af) ; @@ -279,6 +328,18 @@ pgNum : PronGen -> Number -> GenNum = \g,n -> p = True } ; + complVerbAdj : Adjective -> VerbPhraseInf -> AdjPhrase = \zhazhduuchii,zhit -> + {s = \\af => zhazhduuchii.s ! af ++ zhit.s2 ++ zhit.s ; + p = True + } ; + + +complObjA2V: AdjCompl -> NounPhrase -> VerbPhraseInf -> AdjPhrase = +\ legkii, mu, zapomnit -> +{ s = \\af => legkii.s ! AdvF ++ zapomnit.s2 ++ zapomnit.s ++ + mu. s ! (mkPronForm legkii.c No NonPoss); + p = True + }; --3 Complements -- @@ -547,6 +608,9 @@ let {n = ivan.n ; nf = if_then_else Number coll Sg n} in locativeNounPhrase : NounPhrase -> Adverb = \ivan -> {s = "в" ++ ivan.s ! (mkPronForm Prepos Yes NonPoss) } ; + advAdv : Adverb -> Adverb -> Adverb =\ochen, khorosho -> + {s = ochen.s ++ khorosho.s}; + mkAdverb : Str -> Adverb = \well -> ss well ; -- This is a source of the "man with a telescope" ambiguity, and may produce -- strange things, like "машины всегда". @@ -563,6 +627,8 @@ let {n = ivan.n ; nf = if_then_else Number coll Sg n} in p = khorosho.p } ; + + --2 Sentences -- -- We do not introduce the word order parameter for sentences in Russian @@ -574,8 +640,8 @@ oper -- This is the traditional $S -> NP VP$ rule. - predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = - \Ya, tebyaNeVizhu -> { s = + predVerbPhrase : NounPhrase -> VerbPhrase -> SlashNounPhrase = + \Ya, tebyaNeVizhu -> { s = \\b,clf => let { ya = Ya.s ! (mkPronForm Nom No NonPoss); ne = tebyaNeVizhu.s2; @@ -585,20 +651,20 @@ oper in if_then_else Str tebyaNeVizhu.negBefore (ya ++ ne ++ vizhu ++ tebya) - (ya ++ vizhu ++ ne ++ tebya) - } ; + (ya ++ vizhu ++ ne ++ tebya) ; + s2= ""; + c = Nom +} ; param Anteriority = Simul | Anter ; -- for compatibility with Rules.gf: ClTense = ClPresent | ClPast | ClFuture | ClConditional; - ClForm = ClIndic RusTense Anteriority | ClCondit | ClInfinit ; -- "naked infinitive" clauses oper Clause = {s : Bool => ClForm => Str} ; - predVerbGroupClause : NounPhrase -> VerbGroup -> Clause = \Ya, tebyaNeVizhu -> { s = \\b,c => let { @@ -623,7 +689,7 @@ oper -- This is a macro for simultaneous predication and complementation. predTransVerb : Bool -> TransVerb -> NounPhrase -> NounPhrase -> Sentence = - \b,vizhu,ya,tu -> predVerbPhrase ya (predVerbGroup b Present (complTransVerb vizhu tu)) ; + \b,vizhu,ya,tu -> {s= (predVerbPhrase ya (predVerbGroup b Present (complTransVerb vizhu tu))).s!True!ClIndic Present Simul}; --3 Sentence-complement verbs -- @@ -678,9 +744,9 @@ oper -- Notice that the slash category has the same relation to sentences as -- transitive verbs have to verbs: it's like a *sentence taking a complement*. - SentenceSlashNounPhrase = Sentence ** Complement ; + SlashNounPhrase = Clause ** Complement ; - slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase = + slashTransVerb : Bool -> NounPhrase -> TransVerb -> SlashNounPhrase = \b,ivan,lubit -> predVerbPhrase ivan (predVerbGroup b Present ((verbOfTransVerb lubit)** { s2 = table{True => ""; False => "не"}; @@ -709,7 +775,7 @@ thereIs : NounPhrase -> Sentence = \bar -> -- -- Coordinated phrases are built by using conjunctions, which are either -- simple ("и", "или") or distributed ("как - так", "либо - либо"). --- +--f -- The conjunction has an inherent number, which is used when conjoining -- noun phrases: "Иван и Маша поют" vs. "Иван или Маша поет"; in the -- case of "или", the result is however plural if any of the disjuncts is. @@ -742,10 +808,10 @@ oper gulyaet.s3 ! genGNum gn ! nu } ; - relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = + relSlash : RelPron -> SlashNounPhrase -> RelClause = \kotoruj, yaVizhu -> {s = \\b,clf,gn, _ , anim => yaVizhu.s2 ++ kotoruj.s ! gn ! yaVizhu.c ! anim - ++ yaVizhu.s + ++ yaVizhu.s!b!clf } ; -- A 'degenerate' relative clause is the one often used in mathematics, e.g. @@ -754,6 +820,9 @@ oper relSuch : Sentence -> RelClause = \A -> {s = \\b,clf,gn,c, anim => takoj.s ! AF c anim gn ++ "что" ++ A.s } ; +relCl : Clause -> RelClause =\ A -> + {s = \\b,clf,gn,c, anim => takoj.s ! AF c anim gn ++ "что" ++ A.s !b!clf}; + -- The main use of relative clauses is to modify common nouns. -- The result is a common noun, out of which noun phrases can be formed -- by determiners. A comma is used before the relative clause. @@ -843,6 +912,12 @@ oper indicUtt : Sentence -> Utterance = \x -> postfixSS "." (defaultSentence x) ; interrogUtt : Question -> Utterance = \x -> postfixSS "?" (defaultQuestion x) ; +advSentencePhr : Adverb -> Sentence -> Utterance =\ a,sen -> +{s = a.s ++ ","++ sen.s}; + +phrVPI: VerbPhraseInf -> Utterance = \v -> +{s = v.s ++ v.s2 ++ v.s3!Masc!Sg} ; + --2 Questions -- -- Questions are either direct ("Ты счастлив?") @@ -851,8 +926,10 @@ oper param QuestForm = DirQ | IndirQ ; + oper Question = SS1 QuestForm ; + QuestionCl = {s :Bool => ClForm => QuestForm => Str}; --3 Yes-no questions -- @@ -885,12 +962,12 @@ isThere : NounPhrase -> Question = \bar -> -- others that are like $S/NP - NP$ sentences. intVerbPhrase : IntPron -> VerbPhrase -> Question = \kto,spit -> - {s = table { _ => (predVerbPhrase kto spit).s } + {s = table { _ => (predVerbPhrase kto spit).s!True!ClIndic Present Simul} } ; - intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \Kto, yaGovoru -> - let { kom = Kto.s ! (mkPronForm yaGovoru.c No NonPoss) ; o = yaGovoru.s2 } in - {s = table { _ => o ++ kom ++ yaGovoru.s } + intSlash : IntPron -> SlashNounPhrase -> QuestionCl = \Kto, yaGovoruO -> + let { kom = Kto.s ! (mkPronForm yaGovoruO.c No NonPoss) ; o = yaGovoruO.s2 } in + {s = \\b,clf,_ => o ++ kom ++ yaGovoruO.s ! b ! clf } ; --3 Interrogative adverbials @@ -907,12 +984,16 @@ isThere : NounPhrase -> Question = \bar -> -- A question adverbial can be applied to anything, and whether this makes -- sense is a semantic question. - questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question = + questAdverbial_1 : IntAdverb -> NounPhrase -> VerbPhrase -> Question = \kak, tu, pozhivaesh -> {s = \\q => kak.s ++ tu.s ! (mkPronForm Nom No NonPoss) ++ pozhivaesh.s2 ++ pozhivaesh.s ! VFin (gNum (pgen2gen tu.g) tu.n) tu.p ++ pozhivaesh.s3 ! (pgen2gen tu.g) ! tu.n } ; + questAdverbial : IntAdverb -> Clause -> QuestionCl = + \kak, tuPozhivaesh -> + {s = \\b,clf,q => kak.s ++ tuPozhivaesh.s!b!clf } ; + --2 Imperatives -- -- We only consider second-person imperatives. @@ -951,7 +1032,7 @@ isThere : NounPhrase -> Question = \bar -> -- To coordinate a list of sentences by a simple conjunction, we place -- it between the last two elements; commas are put in the other slots, --- e.g. "ты куришь, вы пьете и я ем". +-- e.g. "ты куришь, вы пьете и я ем". conjunctSentence : Conjunction -> ListSentence -> Sentence = \c,xs -> ss (CO.conjunctX c xs) ; @@ -965,6 +1046,20 @@ isThere : NounPhrase -> Question = \bar -> \c,xs -> ss (CO.conjunctDistrX c xs) ; +--3 Coordinating adverbs +-- + ListAdverb : Type = CO.ListX ; + + twoAdverb : (_,_ : Adverb) -> ListAdverb = CO.twoSS; + + consAdverb : ListAdverb -> Adverb -> ListAdverb = + CO.consSS CO.comma ; + + conjAdverb : Conjunction -> ListAdverb -> Adverb = \c,xs -> + ss (CO.conjunctX c xs) ; + conjDAdverb : ConjunctionDistr -> ListAdverb -> Adverb = \c,xs -> + ss (CO.conjunctDistrX c xs) ; + --3 Coordinating adjective phrases -- -- The structure is the same as for sentences. The result is a prefix adjective @@ -1074,13 +1169,20 @@ isThere : NounPhrase -> Question = \bar -> \if, A, B -> {s = \\q => subjunctVariants if A.s (B.s ! q)} ; + subjQS : Subjunction -> Sentence -> Question -> Question = + \ if, sen, que -> + {s = \\qf => if.s ++ sen.s ++ que.s ! qf }; + subjunctVerbPhrase: VerbPhrase -> Subjunction -> Sentence -> VerbPhrase = \V, if, A -> adVerbPhrase V (mkAdverb (if.s ++ A.s)) ; subjunctVariants : Subjunction -> Str -> Str -> Str = \if,A,B -> variants {if.s ++ A ++ "," ++ B ; B ++ "," ++ if.s ++ A} ; ---2 One-word utterances + advSubj : Subjunction -> Sentence -> Adverb = \ if, sen -> + {s = if.s ++ sen.s} ; + + --2 One-word utterances -- -- An utterance can consist of one phrase of almost any category, -- the limiting case being one-word utterances. These