*** empty log message ***

This commit is contained in:
janna
2003-11-25 16:34:42 +00:00
parent 77deae8f4a
commit 0f03b4aeb8
10 changed files with 2974 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
concrete DatabaseRus of Database = open Prelude,Syntax,English,Predication,Paradigms in {
flags lexer=text ; unlexer=text ; coding=utf8 ;
lincat
Phras = SS1 Bool ; -- long or short form
Subject = NP ;
Noun = CN ;
Property = AP ;
Comparison = AdjDeg ;
Relation = Adj2 ;
Feature = Fun ;
Value = NP ;
Name = ProperName ;
lin
LongForm sent = ss (sent.s ! True ++ "?") ;
ShortForm sent = ss (sent.s ! False ++ "?") ;
oper
mkSent : SS -> SS -> SS1 Bool = \long, short ->
{s = table {b => if_then_else Str b long.s short.s}} ;
mkSentPrel : Str -> SS -> SS1 Bool = \prel, matter ->
mkSent (ss (prel ++ matter.s)) matter ;
mkSentSame : SS -> SS1 Bool = \s ->
mkSent s s ;
lin
WhichAre A B = mkSent (defaultQuestion (IntVP (NounIPMany A) (PosA B)))
(defaultNounPhrase (IndefManyNP (ModAdj B A))) ;
IsIt Q A = mkSentSame (defaultQuestion (QuestVP Q (PosA A))) ;
MoreThan = ComparAdjP ;
TheMost = SuperlNP ;
Relatively C _ = PositAdjP C ;
RelatedTo = ComplAdj ;
FeatureOf = appFun1 ;
ValueOf F V = appFun1 F (UsePN V) ;
WithProperty A B = ModAdj B A ;
Individual = UsePN ;
AllN = DetNP AllDet ;
MostN = DetNP MostDet ;
EveryN = DetNP EveryDet ;
-- only these are language-dependent
Any = detNounPhrase anyPlDet ; --- in the sense "some", not "all"
IsThere A = mkSentPrel ["есть ли"] (defaultNounPhrase (IndefOneNP A)) ;
AreThere A = mkSentPrel ["есть ли"] (defaultNounPhrase (IndefManyNP A)) ;
WhatIs V = mkSentPrel ["какой"] (defaultNounPhrase V) ;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,362 @@
--# -path=.:../abstract:../../prelude
--1 Russian Lexical Paradigms
--
-- Aarne Ranta, Janna Khegai 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 following files are presupposed:
resource Paradigms = open (Predef=Predef), Prelude, Syntax, Russian in {
flags coding=utf8 ;
--2 Parameters
--
-- To abstract over gender names, we define the following identifiers.
oper
masculine : Gender ;
feminine : Gender ;
neuter : Gender ;
-- To abstract over case names, we define the following.
nominative : Case ;
genitive : Case ;
dative : Case ;
accusative : Case ;
instructive : Case ;
prepositional : Case ;
-- In some (written in English) textbooks accusative case
-- is put on the second place. However, we follow the case order
-- standard for Russian textbooks.
-- To abstract over number names, we define the following.
singular : Number ;
plural : Number ;
--2 Nouns
-- Best case: indeclinabe nouns: "кофе", "пальто", "ВУЗ".
mkIndeclinableNoun: Str -> Gender -> Animacy -> N ;
-- Worst case - give six singular forms:
-- Nominative, Genetive, Dative, Accusative, Instructive and Prepositional;
-- corresponding six plural forms and the gender.
-- May be the number of forms needed can be reduced,
-- but this requires a separate investigation.
-- Animacy parameter (determining whether the Accusative form is equal
-- to the Nominative or the Genetive one) is actually of no help,
-- since there are a lot of exceptions and the gain is just one form less.
mkN : (_,_,_,_,_,_,_,_,_,_,_,_ : Str) -> Gender -> Animacy -> N ;
-- мужчина, мужчины, мужчине, мужчину, мужчиной, мужчине
-- мужчины, мужчин, мужчинам, мужчин, мужчинами, мужчинах
-- Here are some common patterns. The list is far from complete.
-- Feminine patterns.
nMashina : Str -> N ; -- feminine, inanimate, ending with "-а", Inst -"машин-ой"
nEdinica : Str -> N ; -- feminine, inanimate, ending with "-а", Inst -"единиц-ей"
nZhenchina : Str -> N ; -- feminine, animate, ending with "-a"
nNoga : Str -> N ; -- feminine, inanimate, ending with "г_к_х-a"
nMalyariya : Str -> N ; -- feminine, inanimate, ending with "-ия"
nTetya : Str -> N ; -- feminine, animate, ending with "-я"
nBol : Str -> N ; -- feminine, inanimate, ending with "-ь"(soft sign)
-- Neuter patterns.
nObezbolivauchee : Str -> N ; -- neutral, inanimate, ending with "-ee"
nProizvedenie : Str -> N ; -- neutral, inanimate, ending with "-e"
nChislo : Str -> N ; -- neutral, inanimate, ending with "-o"
-- Masculine patterns.
nStomatolog : Str -> N ; -- masculine, animate, ending with consonant
-- the next two differ only in
-- plural nominative (= accusative) form(s) :
nAdres : Str -> N ; -- адрес-а
nTelefon : Str -> N ; -- телефон-ы
-- masculine, inanimate, ending with consonant
nNol : Str -> N ; -- masculine, inanimate, ending with "-ь" (soft sign)
nUroven : Str -> N ; -- masculine, inanimate, ending with "-ень"
-- Nouns used as functions need a preposition. The most common is with Genitive.
mkFun : N -> Preposition -> Case -> Fun ;
funGen : N -> Fun ;
-- Proper names.
mkPN : Str -> Gender -> Animacy -> PN ; -- "Иван", "Маша"
-- 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 -> Animacy -> NP ;
--2 Adjectives
-- Non-comparison (only positive degree) one-place adjectives need 28 (4 by 7)
-- forms in the worst case:
-- Masculine | Feminine | Neutral | Plural
-- Nominative
-- Genitive
-- Dative
-- Accusative Inanimate
-- Accusative Animate
-- Instructive
-- Prepositional
-- Notice that 4 short forms, which exist for some adjectives are not included
-- in the current description, otherwise there would be 32 forms for
-- positive degree.
-- mkAdj1 : ( : Str) -> Adj1 ;
-- Invariable adjective is a special case.
adjInvar : Str -> Adj1 ; -- khaki, mini, hindi, netto
-- Some regular patterns depending on the ending.
adj1Staruyj : Str -> Adj1 ; -- ending with "-ый"
adj1Malenkij : Str -> Adj1 ; -- endign with "-ий"
adj1Molodoj : Str -> Adj1 ; -- ending with "-ой",
-- plural - молод-ые"
adj1Kakoj_Nibud : Str -> Str -> Adj1 ; -- ending with "-ой",
-- plural - "как-ие"
-- Two-place adjectives need a preposition and a case as extra arguments.
mkAdj2 : Adj1 -> Str -> Case -> Adj2 ; -- "делим на"
-- Comparison adjectives need a positive adjective
-- (28 forms without short forms).
-- Taking only one comparative form (non-syntaxic) and
-- only one superlative form (syntaxic) we can produce the
-- comparison adjective with only one extra argument -
-- non-syntaxic comparative form.
-- Syntaxic forms are based on the positive forms.
mkAdjDeg : Adj1 -> Str -> AdjDeg ;
-- On top level, there are adjectival phrases. The most common case is
-- just to use a one-place adjective.
ap : Adj1 -> IsPostfixAdj -> AP ;
--2 Verbs
--
-- In our lexicon description ("Verbum") there are 62 forms:
-- 2 (Voice) by { 1 (infinitive) + [2(number) by 3 (person)](imperative) +
-- [ [2(Number) by 3(Person)](present) + [2(Number) by 3(Person)](future) +
-- 4(GenNum)(past) ](indicative)+ 4 (GenNum) (subjunctive) }
-- Participles (Present and Past) and Gerund forms are not included,
-- since they fuction more like Adjectives and Adverbs correspondingly
-- rather than verbs. Aspect regarded as an inherent parameter of a verb.
-- Notice, that some forms are never used for some verbs. Actually,
-- the majority of verbs do not have many of the forms.
-- The worst case need 6 forms of the present tense in indicative mood
-- ("я бегу", "ты бежишь", "он бежит", "мы бежим", "вы бежите", "они бегут"),
-- a past form (singular, masculine: "я бежал"), an imperative form
-- (singular, second person: "беги"), an infinitive ("бежать").
-- Inherent aspect should also be specified.
mkVerbum : Aspect -> (_,_,_,_,_,_,_,_,_ : Str) -> Verbum ;
-- Common conjugation patterns are two conjugations:
-- first - verbs ending with "-ать/-ять" and second - "-ить/-еть".
-- Instead of 6 present forms of the worst case, we only need
-- a present stem and one ending (singular, first person):
-- "я люб-лю", "я жд-у", etc. To determine where the border
-- between stem and ending lies it is sufficient to compare
-- first person from with second person form:
-- "я люб-лю", "ты люб-ишь". Stems shoud be the same.
-- So the definition for verb "любить" looks like:
-- mkRegVerb Imperfective Second "люб" "лю" "любил" "люби" "любить";
mkRegVerb :Aspect -> Conjugation -> (_,_,_,_,_ : Str) -> Verbum ;
-- For writing an application grammar one usualy doesn't need
-- the whole inflection table, since each verb is used in
-- a particular context that determines some of the parameters
-- (Tense and Voice while Aspect is fixed from the beginning) for certain usage.
-- The "V" type, that have these parameters fixed.
-- We can extract the "V" from the lexicon.
mkV: Verbum -> Voice -> Tense -> V ;
mkPresentV: Verbum -> Voice -> V ;
-- Two-place verbs, and the special case with direct object. Notice that
-- a particle can be included in a $V$.
mkTV : V -> Str -> Case -> TV ; -- "войти в дом"; "в", accusative
tvDir : V -> TV ; -- "видеть", "любить"
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
--.
masculine = Masc ;
feminine = Fem ;
neuter = Neut ;
nominative = Nom ;
accusative = Acc ;
dative = Dat ;
genitive = Gen ;
instructive = Inst ;
prepositional = Prepos ;
singular = Sg ;
plural = Pl ;
-- Noun definitions
mkIndeclinableNoun = \s,g, anim ->
{
s = table { SF _ _ => s } ;
g = g ;
anim = anim
} ;
mkN = \nomSg, genSg, datSg, accSg, instSg, preposSg,
nomPl, genPl, datPl, accPl, instPl, preposPl, g, anim ->
{
s = table {
SF Sg Nom => nomSg ;
SF Sg Gen => genSg ;
SF Sg Dat => datSg ;
SF Sg Acc => accSg ;
SF Sg Inst => instSg ;
SF Sg Prepos => preposSg ;
SF Pl Nom => nomPl ;
SF Pl Gen => genPl ;
SF Pl Dat => datPl ;
SF Pl Acc => accPl ;
SF Pl Inst => instPl ;
SF Pl Prepos => preposPl
} ;
g = g ;
anim = anim
} ;
nMashina = \s -> aEndInanimateDecl s;
nEdinica = \s -> ej_aEndInanimateDecl s;
nZhenchina = \s -> (aEndAnimateDecl s) ** { g = Fem } ;
nNoga = \s -> aEndG_K_KH_Decl s ;
nMalyariya = \s -> i_yaEndDecl s ;
nTetya = \s -> (yaEndAnimateDecl s) ** {g = Fem} ;
nBol = \s -> softSignEndDeclFem s ;
-- Neuter patterns.
nObezbolivauchee = \s -> eeEndInAnimateDecl s ;
nProizvedenie = \s -> eEndInAnimateDecl s ;
nChislo = \s -> oEndInAnimateDecl s ;
-- Masculine patterns.
nStomatolog = \s -> nullEndAnimateDecl s ;
nAdres = \s -> nullEndInAnimateDecl2 s ;
nTelefon = \s -> nullEndInAnimateDecl1 s ;
nNol = \s -> softSignEndDeclMasc s ;
nUroven = \s -> EN_softSignEndDeclMasc s ;
-- mkFun defined in syntax.RusU
-- funGen defined in syntax.RusU
mkPN = \ivan, g, anim ->
case g of {
Masc => mkProperNameMasc ivan anim ;
_ => mkProperNameFem ivan anim
} ;
mkCN = UseN ;
mkNP = \x,y,z -> UsePN (mkPN x y z) ;
-- Adjective definitions
adjInvar = \s -> { s = \\af => s };
adj1Staruyj = uy_j_EndDecl ;
adj1Malenkij = ij_EndK_G_KH_Decl ;
adj1Molodoj = uy_oj_EndDecl ;
adj1Kakoj_Nibud = i_oj_EndDecl ;
mkAdj2 = \a,p,c -> a ** {s2 = p ; c = c} ;
-- mkAdjDeg defined in morpho.RusU
ap = \a,p -> a ** { p = p } ;
-- Verb definitions
mkVerbum = \asp, sgP1, sgP2, sgP3, plP1, plP2, plP3,
sgMascPast, imperSgP2, inf -> case asp of {
Perfective =>
mkVerb (perfectiveActivePattern inf imperSgP2
(presentConj sgP1 sgP2 sgP3 plP1 plP2 plP3) (pastConj sgMascPast))
(pastConj sgMascPast);
Imperfective =>
mkVerb (imperfectiveActivePattern inf imperSgP2
(presentConj sgP1 sgP2 sgP3 plP1 plP2 plP3) (pastConj sgMascPast))
(pastConj sgMascPast)
};
oper presentConj: (_,_,_,_,_,_: Str) -> PresentVerb =
\sgP1, sgP2, sgP3, plP1, plP2, plP3 ->
table {
PRF Sg P1 => sgP1 ;
PRF Sg P2 => sgP2 ;
PRF Sg P3 => sgP3 ;
PRF Pl P1 => plP1 ;
PRF Pl P2 => plP2 ;
PRF Pl P3 => plP3
};
mkRegVerb = verbDecl ; -- defined in morpho.RusU.gf
mkV = extVerb ; -- defined in types.RusU.gf
mkPresentV = \aller, vox ->
{ s = table {
VFin gn p => aller.s ! VFORM vox (VIND (VPresent (numGNum gn) p)) ;
VImper n p => aller.s ! VFORM vox (VIMP n p) ;
VInf => aller.s ! VFORM vox VINF ;
VSubj gn => aller.s ! VFORM vox (VSUB gn)
}; t = Present ; a = aller.asp ; v = vox } ;
mkTV = mkTransVerb ; -- defined in syntax.RusU.gf
tvDir = mkDirectVerb; -- defined in syntax.RusU.gf
} ;

View File

@@ -0,0 +1,35 @@
-- predication library, built on resource grammar. AR 2002--2003
-- Users of the library should *not* look into this file, but only into
-- $predication.Types.gf$.
resource Predication = open Russian in {
oper
predV1 = \F, x -> PredVP x (PosV F) ;
predV2 = \F, x, y -> PredVP x (PosTV F y) ;
predVColl = \F, x, y -> PredVP (conjNP x y) (PosV F) ;
predA1 = \F, x -> PredVP x (PosA F) ;
predA2 = \F, x, y -> PredVP x (PosA (ComplAdj F y)) ;
predAComp = \F, x, y -> PredVP x (PosA (ComparAdjP F y)) ;
predAColl = \F, x, y -> PredVP (conjNP x y) (PosA F) ;
predN1 = \F, x -> PredVP x (PosCN (UseN F)) ;
predN2 = \F, x, y -> PredVP x (PosCN (AppFun F y)) ;
predNColl = \F, x, y -> PredVP (conjNP x y) (PosCN (UseN F)) ;
appFun1 = \f, x -> DefOneNP (AppFun f x) ;
appFunColl = \f, x, y -> DefOneNP (AppFun f (conjNP x y)) ;
appFam1 = \F, x -> AppFun F x ;
appFamColl = \F, x, y -> AppFun F (conjNP x y) ;
conjS = \A, B -> ConjS AndConj (TwoS A B) ;
disjS = \A, B -> ConjS OrConj (TwoS A B) ;
implS = \A, B -> SubjS IfSubj A B ;
constrTyp1 = \F, A -> AppFun F (IndefManyNP A) ;
conjNP = \x, y -> ConjNP AndConj (TwoNP x y) ;
};

View File

@@ -0,0 +1,230 @@
--# -path=.:../abstract:../../prelude
--1 The Top-Level Russian Resource Grammar
--
-- Janna Khegai 2003
-- on the basis of code for other languages by Aarne Ranta
--
-- This is the Russian concrete syntax of the multilingual resource
-- grammar. Most of the work is done in the file $syntax.RusU.gf$.
-- However, for the purpose of documentation, we make here explicit the
-- linearization types of each category, so that their structures and
-- dependencies can be seen.
-- Another substantial part is the linearization rules of some
-- structural words.
--
-- The users of the resource grammar should not look at this file for the
-- linearization rules, which are in fact hidden in the document version.
-- They should use $resource.Abs.gf$ to access the syntactic rules.
-- This file can be consulted in those, hopefully rare, occasions in which
-- one has to know how the syntactic categories are
-- implemented. The parameter types are defined in $types.RusU.gf$.
concrete ResRus of ResAbs = open Prelude, Syntax in {
flags
coding=utf8 ;
startcat=Phr ;
lexer=text ;
unlexer=text ;
lincat
N = CommNoun ;
-- = {s : SubstForm => Str ; g : Gender ; anim : Animacy } ;
CN = CommNounPhrase ;
-- = {s : Number => Case => Str; g : Gender; anim : Animacy} ;
NP = NounPhrase ;
-- = { s : PronForm => Str ; n : Number ; p : Person ;
-- g: Gender ; anim : Animacy ; pron: Bool} ;
PN = ProperName ;
-- = {s : Case => Str ; g : Gender ; anim : Animacy} ;
Adj1 = Adjective ;
-- = {s : AdjForm => Str} ;
Det = Determiner ;
-- = Adjective ** { n: Number; c : Case } ;
Adj2 = AdjCompl ;
-- = Adjective ** Complement ;
AdjDeg = AdjDegr ;
-- = {s : Degree => AdjForm => Str} ;
AP = AdjPhrase ;
-- = Adjective ** {p : IsPostfixAdj} ;
Fun = Function ;
-- = CommNounPhrase ** Complement ;
V = Verb ;
-- = {s : VF => Str ; t: Tense ; a : Aspect ; v: Voice} ;
VP = VerbPhrase ;
-- = Verb ** {s2 : Str ; s3 : Gender => Number => Str ;
-- negBefore: Bool} ;
TV = TransVerb ;
-- = Verb ** {s2 : Preposition ; c: Case } ;
VS = SentenceVerb ;
-- = Verb ;
AdV = Adverb ;
-- = {s : Str} ;
S = Sentence ;
-- = {s : Str} ;
Slash = SentenceSlashNounPhrase ;
-- = Sentence ** Complement ;
RP = RelPron ;
-- = {s : GenNum => Case => Animacy => Str} ;
RC = RelClause ;
-- = RelPron ;
IP = IntPron ;
-- = NounPhrase ;
Qu = Question ;
-- = {s : QuestForm => Str} ;
Imp = Imperative ;
-- = { s: Gender => Number => Str } ;
Phr = Utterance ;
-- = {s : Str} ;
Conj = Conjunction ;
-- = {s : Str ; n : Number} ;
ConjD = ConjunctionDistr ;
-- = {s1,s2 : Str ; n : Number} ;
ListS = ListSentence ;
-- = {s1,s2 : Mode => Str} ;
ListAP = ListAdjPhrase ;
-- = {s1,s2 : AdjForm => Str ; p : Bool} ;
ListNP = ListNounPhrase ;
-- = { s1,s2 : PronForm => Str ; g: Gender ; anim : Animacy ;
-- n : Number ; p : Person ; pron : Bool } ;
--.
lin
UsePN = nameNounPhrase ;
ComplAdj = complAdj ;
PredVP = predVerbPhrase ;
PosTV = complTransVerb True ;
NegTV = complTransVerb False ;
AdjP1 = adj2adjPhrase ;
ModAdj = modCommNounPhrase ;
PosA = predAdjective True ;
NegA = predAdjective False ;
UseN = noun2CommNounPhrase ;
ModGenOne = npGenDet Sg ;
ModGenMany = npGenDet Pl ;
UseFun = funAsCommNounPhrase ;
AppFun = appFunComm ;
PositAdjP = positAdjPhrase ;
ComparAdjP = comparAdjPhrase ;
SuperlNP = superlNounPhrase ;
DetNP = detNounPhrase ;
IndefOneNP = indefNounPhrase Sg ;
IndefManyNP = indefNounPhrase Pl ;
DefOneNP = defNounPhrase Sg ;
DefManyNP = defNounPhrase Pl ;
PosV = predVerb True ;
NegV = predVerb False ;
PosCN = predCommNoun True ;
NegCN = predCommNoun False ;
PosNP = predNounPhrase True ;
NegNP = predNounPhrase False ;
PosVS = complSentVerb True ;
NegVS = complSentVerb False ;
AdvVP = adVerbPhrase ;
LocNP = locativeNounPhrase ;
AdvCN = advCommNounPhrase ;
PosSlashTV = slashTransVerb True ;
NegSlashTV = slashTransVerb False ;
IdRP = identRelPron ;
FunRP = funRelPron ;
RelVP = relVerbPhrase ;
RelSlash = relSlash ;
ModRC = modRelClause ;
RelSuch = relSuch ;
WhoOne = intPronKto Sg ;
WhoMany = intPronKto Pl ;
WhatOne = intPronChto Sg ;
WhatMany = intPronChto Pl ;
FunIP = funIntPron ;
NounIPOne = nounIntPron Sg ;
NounIPMany = nounIntPron Pl ;
QuestVP = questVerbPhrase ;
IntVP = intVerbPhrase ;
IntSlash = intSlash ;
QuestAdv = questAdverbial ;
ImperVP = imperVerbPhrase ;
IndicPhrase = indicUtt ;
QuestPhrase = interrogUtt ;
ImperOne = imperUtterance Masc Sg ;
ImperMany = imperUtterance Masc Pl ;
TwoS = twoSentence ;
ConsS = consSentence ;
ConjS = conjunctSentence ;
ConjDS = conjunctDistrSentence ;
TwoAP = twoAdjPhrase ;
ConsAP = consAdjPhrase ;
ConjAP = conjunctAdjPhrase ;
ConjDAP = conjunctDistrAdjPhrase ;
TwoNP = twoNounPhrase ;
ConsNP = consNounPhrase ;
ConjNP = conjunctNounPhrase ;
ConjDNP = conjunctDistrNounPhrase ;
SubjS = subjunctSentence ;
SubjImper = subjunctImperative ;
SubjQu = subjunctQuestion ;
PhrNP = useNounPhrase ;
PhrOneCN = useCommonNounPhrase Sg ;
PhrManyCN = useCommonNounPhrase Pl ;
PhrIP ip = postfixSS "?" ip ;
PhrIAdv ia = postfixSS "?" ia ;
INP = pron2NounPhrase pronYa Animate;
ThouNP = pron2NounPhrase pronTu Animate;
HeNP = pron2NounPhrase pronOn Animate;
SheNP = pron2NounPhrase pronOna Animate;
WeNP = pron2NounPhrase pronMu Animate;
YeNP = pron2NounPhrase pronVu Animate;
YouNP = pron2NounPhrase pronVu Animate;
TheyNP = pron2NounPhrase pronOni Animate;
EveryDet = kazhdujDet ** {n = Sg ; c= Nom} ;
AllDet = vseDetPl ** {n = Pl; c= Nom} ;
WhichDet = kotorujDet ** {n = Sg; c= Nom} ; -- a singular version only
MostDet = bolshinstvoDet ** {n = Pl; c= Gen} ;
HowIAdv = ss "как" ;
WhenIAdv = ss "когда" ;
WhereIAdv = ss "где" ;
WhyIAdv = ss "почему" ;
AndConj = ss "и" ** {n = Pl} ;
OrConj = ss "или" ** {n = Sg} ;
BothAnd = sd2 "как" [", так"] ** {n = Pl} ;
EitherOr = sd2 "либо" [", либо"] ** {n = Sg} ;
-- In case of "neither.. no" expression double negation is not
-- only possible, but also required in Russian.
-- There is no means of control for this however in the resource grammar.
NeitherNor = sd2 "ни" [", ни"] ** {n = Sg} ;
IfSubj = ss "если" ;
WhenSubj = ss "когда" ;
PhrYes = ss ["да ."] ;
PhrNo = ss ["нет ."] ;
} ;

View File

@@ -0,0 +1,30 @@
--# -path=.:../abstract:../../prelude
concrete RestaurantRus of Restaurant =
DatabaseRus ** open Prelude,Paradigms in {
flags coding=utf8 ;
lin
Restaurant = n2n restoran;
Bar = n2n bar ;
French = AdjP1 francuzskij ;
Italian = AdjP1 italyanskij ;
Indian = AdjP1 indijskij ;
Japanese = AdjP1 yaponskij ;
address = funGen adres ;
phone = funGen telefon ;
priceLevel = funGen (commNounPhrase2CommNoun(appFunComm urovenFun cenu)) ;
Cheap = deshevuj;
Expensive = dorogoj ;
WhoRecommend rest = mkSentSame (ss2 ["кто порекомендовал"] (rest.s ! Acc)) ;
WhoHellRecommend rest =
mkSentSame (ss2 ["кто, черт возьми, порекомендовал"] (rest.s ! Acc)) ;
LucasCarton = mkProperNameMasc ["Лукас Картун"] Inanimate;
oper
urovenFun : Function = funGen uroven ;
cenu : NounPhrase = mkNounPhrase Pl (n2n cena) ;
};

View File

@@ -0,0 +1,3 @@
--# -path=.:../abstract:../../prelude
resource Russian = reuse ResRus ;

View File

@@ -0,0 +1,898 @@
--1 A Small Russian Resource Syntax
--
-- Aarne Ranta, Janna Khegai 2003
--
-- This resource grammar contains definitions needed to construct
-- indicative, interrogative, and imperative sentences in Russian.
--
-- The following files are presupposed:
resource Syntax = Morpho ** open Prelude, (CO = Coordination) in {
flags coding=utf8 ;
--2 Common Nouns
--
--
--3 Common noun phrases
--
-- Complex common nouns ($Comm'NounPhrase$) have in principle
-- the same parameters as simple ones.
oper
CommNounPhrase: Type = {s : Number => Case => Str; g : Gender; anim : Animacy} ;
noun2CommNounPhrase : CommNoun -> CommNounPhrase = \sb ->
{s = \\n,c => sb.s ! SF n c ;
g = sb.g ;
anim = sb.anim
} ;
commNounPhrase2CommNoun : CommNounPhrase -> CommNoun = \sb ->
{s = \\sf => sb.s ! (numSF sf) ! (caseSF sf) ;
g = sb.g ;
anim = sb.anim
} ;
n2n = noun2CommNounPhrase;
n2n2 = commNounPhrase2CommNoun ;
--2 Noun Phrases
--
oper
NounPhrase : Type = { s : PronForm => Str ; n : Number ;
p : Person ; g: Gender ; anim : Animacy ; pron: Bool} ;
-- A function specific for Russian for setting the gender for
-- personal pronouns in first and second person, singular :
setNPGender : Gender -> NounPhrase -> NounPhrase = \gen, pronI ->
{ s = pronI.s ; g = gen ; anim = pronI.anim ;
n = pronI.n ; nComp = pronI.nComp ; p = pronI.p ; pron = pronI.pron } ;
mkNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,chelovek ->
{s = \\cas => chelovek.s ! n ! (extCase cas) ;
n = n ; g = chelovek.g ; p = P3 ; pron =False ;
anim = chelovek.anim
} ;
pron2NounPhrase : Pronoun -> Animacy -> NounPhrase = \ona, anim ->
{s = ona.s ; n = ona.n ; g = pgen2gen ona.g ;
pron = ona.pron; p = ona.p ; anim = anim } ;
nameNounPhrase : ProperName -> NounPhrase =
\masha -> {s = \\c => masha.s ! (extCase c) ;
p = P3; g = masha.g ; anim = masha.anim ;
n = Sg; nComp = Sg; pron = False} ;
--2 Determiners
--
-- Determiners (only determinative pronouns in Russian) are inflected
-- according to the gender of nouns they determine.
-- The determined noun has the case parameter specific for the determiner:
Determiner : Type = Adjective ** { n: Number; c : Case } ;
anyPlDet = kakojNibudDet ** {n = Pl; c= Nom} ;
detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \kazhduj, okhotnik ->
{s = \\c => case kazhduj.c of {
Nom =>
kazhduj.s ! AF (extCase c) okhotnik.anim (gNum okhotnik.g kazhduj.n) ++
okhotnik.s ! kazhduj.n ! (extCase c) ;
_ =>
kazhduj.s ! AF (extCase c) okhotnik.anim (gNum okhotnik.g kazhduj.n) ++
okhotnik.s ! kazhduj.n ! kazhduj.c };
n = kazhduj.n ;
p = P3 ;
pron = False;
g = okhotnik.g ;
anim = okhotnik.anim
} ;
indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,mashina ->
{s = \\c => mashina.s ! n ! (extCase c) ;
n = n ; p = P3 ; g = mashina.g ; anim = mashina.anim ;
pron = False
} ;
defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,mashina ->
{ s = \\c => mashina.s ! n ! (extCase c) ;
n = n ; p = P3 ; g = mashina.g ;anim = mashina.anim ; pron = False } ;
-- Genitives of noun phrases can be used like determiners,
-- to build noun phrases.
-- The number argument makes the difference between "мой дом" - "мои дома".
--
-- The variation like in "the car of John / John's car" in English is
-- not equally natural for proper names and pronouns and the rest of nouns.
-- Compare "дверца машины" and "машины дверца", while
-- "Ванина мама" and "мама Вани" or "моя мама" and "мама моя".
-- Here we have to make a choice of a universal form, which will be
-- "моя мама" - "Вани мама" - "машины дверца", which sounds
-- the best for pronouns, a little worse for proper names and
-- the worst for the rest of nouns. The reason is the fact that
-- possession/genetive is more a human category and pronouns are
-- used very often, so we try to suit this case in the first place.
npGenDet : Number -> NounPhrase -> CommNounPhrase -> NounPhrase =
\n,masha,mashina ->
{s = \\c => case masha.pron of
{ True => masha.s ! (mkPronForm Nom No (Poss (gNum mashina.g n))) ++
mashina.s ! n ! (extCase c) ;
False => masha.s ! (mkPronForm Gen No (Poss (gNum mashina.g n))) ++
mashina.s ! n ! (extCase c)
} ;
n = n ; p = P3 ; g = mashina.g ; anim = mashina.anim ; pron = False
} ;
--2 Adjectives
--3 Simple adjectives
--
-- A special type of adjectives just having positive forms
-- (for semantic reasons) is useful, e.g. "русский".
oper
extAdjective : AdjDegr -> Adjective = \adj ->
{ s = \\af => adj.s ! Pos ! af } ;
-- Coercions between the compound gen-num type and gender and number:
gNum : Gender -> Number -> GenNum = \g,n ->
case n of {Sg => case g of
{ Fem => ASg Fem ;
Masc => ASg Masc ;
Neut => ASg Neut
-- _ => variants {ASg Masc ; ASg Fem}
} ; Pl => APl} ;
--3 Adjective phrases
--
-- An adjective phrase may contain a complement, e.g. "моложе Риты".
-- Then it is used as postfix in modification, e.g. "человек, моложе Риты".
IsPostfixAdj = Bool ;
AdjPhrase : Type = Adjective ** {p : IsPostfixAdj} ;
-- Simple adjectives are not postfix:
adj2adjPhrase : Adjective -> AdjPhrase = \novuj -> novuj ** {p = False} ;
--3 Comparison adjectives
--
-- Each of the comparison forms has a characteristic use:
--
-- Positive forms are used alone, as adjectival phrases ("большой").
positAdjPhrase : AdjDegr -> AdjPhrase = \bolshoj ->
adj2adjPhrase (extAdjective bolshoj) ;
-- Comparative forms are used with an object of comparison, as
-- adjectival phrases ("больше тебя").
comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \bolshoj, tu ->
{s = \\af => bolshoj.s ! Comp ! af ++ tu.s ! (mkPronForm Gen Yes NonPoss) ;
p = True
} ;
-- Superlative forms are used with a modified noun, picking out the
-- maximal representative of a domain ("самый большой дом").
superlNounPhrase : AdjDegr -> CommNounPhrase -> NounPhrase = \bolshoj, dom ->
{s = \\pf => bolshoj.s ! Super ! AF (extCase pf) dom.anim (gNum dom.g Sg) ++
dom.s ! Sg ! (extCase pf) ;
n = Sg ;
p = P3 ;
pron = False;
anim = dom.anim ;
g = dom.g
} ;
--3 Two-place adjectives
--
-- A two-place adjective is an adjective with a preposition used before
-- the complement. (Rem. $Complement = {s2 : Preposition ; c : Case} $).
AdjCompl = Adjective ** Complement ;
complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \vlublen,tu ->
{s = \\af => vlublen.s ! af ++ vlublen.s2 ++
tu.s ! (mkPronForm vlublen.c No NonPoss) ;
p = True
} ;
--3 Complements
--
Complement = {s2 : Preposition ; c : Case} ;
complement : Str -> Complement = \cherez ->
{s2 = cherez ; c = Nom} ;
complementDir : Complement = complement [] ;
complementCas : Case -> Complement = \c ->
{s2 = [] ; c = c} ;
--2 Individual-valued functions
-- An individual-valued function is a common noun together with the
-- preposition prefixed to its argument ("ключ от дома").
-- The situation is analogous to two-place adjectives and transitive verbs.
--
-- We allow the genitive construction to be used as a variant of
-- all function applications. It would definitely be too restrictive only
-- to allow it when the required case is genitive. We don't know if there
-- are counterexamples to the liberal choice we've made.
Function = CommNounPhrase ** Complement ;
-- The application of a function gives, in the first place, a common noun:
-- "ключ от дома". From this, other rules of the resource grammar
-- give noun phrases, such as "ключи от дома", "ключи от дома
-- и от машины", and "ключ от дома и машины" (the
-- latter two corresponding to distributive and collective functions,
-- respectively). Semantics will eventually tell when each
-- of the readings is meaningful.
appFunComm : Function -> NounPhrase -> CommNounPhrase = \mama,ivan ->
{s = \\n, cas =>
mama.s ! n ! cas ++ mama.s2 ++
ivan.s ! (mkPronForm mama.c No (Poss (gNum mama.g n)));
g = mama.g ;
anim = mama.anim
} ;
-- It is possible to use a function word as a common noun; the semantics is
-- often existential or indexical.
funAsCommNounPhrase : Function -> CommNounPhrase = \x -> x ;
mkFun : CommNoun -> Preposition -> Case -> Function = \f,p,c ->
(n2n f) ** {s2 = p ; c = c} ;
-- The following is an aggregate corresponding to the original function application
-- producing "детство Ивана" and "Иваново детство". It does not appear in the
-- resource abstract syntax any longer.
-- Both versions return "детсво Ивана" although "Иваново детство"
-- must also be included
-- Such possesive form is only possible with proper names in Russian :
appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll,detstvo, ivan ->
let {n = ivan.n ; nf = if_then_else Number coll Sg n} in
variants {
defNounPhrase nf (appFunComm detstvo ivan) ; -- detstvoIvana
npGenDet nf ivan detstvo
} ;
-- The commonest cases are functions with Genitive.
funGen : CommNoun -> Function = \urovenCen ->
mkFun urovenCen [] Gen ;
--3 Modification of common nouns
--
-- The two main functions of adjective are in predication ("Иван - молод")
-- and in modification ("молодой человек"). Predication will be defined
-- later, in the chapter on verbs.
modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase =
\khoroshij,novayaMashina ->
{s = \\n, c =>
khoroshij.s ! AF c novayaMashina.anim (gNum novayaMashina.g n) ++
novayaMashina.s ! n ! c ;
g = novayaMashina.g ;
anim = novayaMashina.anim
} ;
--2 Verbs
--3 Transitive verbs
--
-- Transitive verbs are verbs with a preposition for the complement,
-- in analogy with two-place adjectives and functions.
-- One might prefer to use the term "2-place verb", since
-- "transitive" traditionally means that the inherent preposition is empty
-- and the case is accusative.
-- Such a verb is one with a *direct object*.
-- Note: Direct verb phrases where the Genitive case is also possible
-- ("купить хлеба", "не читать газет") are overlooked in mkDirectVerb
-- and can be expressed via more a general rule mkTransVerb.
TransVerb : Type = Verb ** {s2 : Preposition ; c: Case } ;
complementOfTransVerb : TransVerb -> Complement = \v -> {s2 = v.s2 ; c = v.c} ;
verbOfTransVerb : TransVerb -> Verb = \v ->
{s = v.s; t = v.t; a = v.a ; v = v.v } ;
mkTransVerb : Verb -> Preposition -> Case -> TransVerb = \v,p,cas ->
v ** {s2 = p ; c = cas } ;
mkDirectVerb : Verb -> TransVerb = \v ->
mkTransVerb v nullPrep Acc;
nullPrep : Preposition = [] ;
-- The rule for using transitive verbs is the complementization rule:
complTransVerb : Bool -> TransVerb -> NounPhrase -> VerbPhrase = \b,se,tu ->
{s = se.s ; a = se.a ; t = se.t ; v = se.v ; s2 = negation b ;
s3 = \\_,_ => se.s2 ++ tu.s ! (mkPronForm se.c No NonPoss) ;
negBefore = True } ;
--3 Verb phrases
--
-- Verb phrases are discontinuous: the parts of a verb phrase are
-- (s) an inflected verb, (s2) verb adverbials (such as negation), and
-- (s3) complement. This discontinuity is needed in sentence formation
-- to account for word order variations.
VerbPhrase : Type = Verb ** {s2 : Str ; s3 : Gender => Number => Str ;
negBefore: Bool} ;
-- A simple verb can be made into a verb phrase with an empty complement.
-- There are two versions, depending on if we want to negate the verb.
predVerb : Bool -> Verb -> VerbPhrase = \b,vidit ->
vidit ** {
s2 = negation b ;
s3 = \\_,_ => [] ;
negBefore = True
} ;
negation : Bool -> Str = \b -> if_then_else Str b [] "не" ;
-- Sometimes we want to extract the verb part of a verb phrase.
verbOfPhrase : VerbPhrase -> Verb = \v ->
{s = v.s; t = v.t ; a = v.a ; v =v.v} ;
-- Verb phrases can also be formed from adjectives ("- молод"),
-- common nouns ("- человек"), and noun phrases ("- самый молодой").
-- The third rule is overgenerating: "- каждый человек" has to be ruled out
-- on semantic grounds.
-- Note: in some case we can even omit a dash "-" :
-- "Я думаю, что это хорошая машина".
predAdjective : Bool -> Adjective -> VerbPhrase = \b,zloj ->
{ s= \\_ => "-" ;
t = Present ;
a = Imperfective ;
v = Act ;
s2 = negation b ;
s3 = \\g,n => case n of {
Sg => zloj.s ! AF Nom Animate (ASg g) ;
Pl => zloj.s ! AF Nom Animate APl
} ;
negBefore = False
} ;
predCommNoun : Bool -> CommNounPhrase -> VerbPhrase = \b,chelovek ->
{ s= \\_ => "-" ;
t = Present ;
a = Imperfective ;
v = Act ;
s2 = negation b ;
s3 = \\_,n => (indefNounPhrase n chelovek ).s ! (mkPronForm Nom No NonPoss) ;
negBefore = False
} ;
predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,masha ->
{ s= \\_ => "-" ;
t = Present ;
a = Imperfective ;
v = Act ;
s2 = negation b ;
s3 = \\_,_ => masha.s ! (mkPronForm Nom No NonPoss) ;
negBefore = False
} ;
-- A function specific for Russian :
predNeedShortAdjective: Bool -> NounPhrase -> CommNounPhrase -> Sentence =
\ b, Jag, Dig -> { s =
let {
mne = Jag.s ! (mkPronForm Dat No NonPoss) ;
nuzhen = need.s ! AF Nom Inanimate (gNum Dig.g Sg) ;
doctor = Dig.s ! Sg ! Nom ;
ne = negation b
} in
mne ++ ne ++ nuzhen ++ doctor
} ;
--2 Adverbials
--
adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \poet, khorosho ->
{s = \\vf => khorosho.s ++ poet.s ! vf ; s2 = poet.s2; s3 = poet.s3;
a = poet.a; v = poet.v; t = poet.t ; negBefore = poet.negBefore } ;
-- Adverbials are typically generated by prefixing prepositions.
-- The rule for creating locative noun phrases by the preposition "в"
-- is a little shaky: "в России" but "на острове".
locativeNounPhrase : NounPhrase -> Adverb = \ivan ->
{s = "в" ++ ivan.s ! (mkPronForm Prepos Yes NonPoss) } ;
-- This is a source of the "man with a telescope" ambiguity, and may produce
-- strange things, like "машины всегда".
-- Semantics will have to make finer distinctions among adverbials.
advCommNounPhrase : CommNounPhrase -> Adverb -> CommNounPhrase = \chelovek,uTelevizora ->
{s = \\n,c => chelovek.s ! n ! c ++ uTelevizora.s ;
g = chelovek.g ;
anim = chelovek.anim
} ;
--2 Sentences
--
-- We do not introduce the word order parameter for sentences in Russian
-- although there exist several word orders, but they are too specific
-- to capture on the level we work here.
oper
Sentence : Type = { s : Str } ;
-- This is the traditional $S -> NP VP$ rule.
predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence =
\Ya, tebyaNeVizhu -> { s =
let
{ ya = Ya.s ! (mkPronForm Nom No NonPoss);
ne = tebyaNeVizhu.s2;
vizhu = tebyaNeVizhu.s ! VFin (gNum Ya.g Ya.n) Ya.p;
tebya = tebyaNeVizhu.s3 ! Ya.g ! Ya.n
}
in
if_then_else Str tebyaNeVizhu.negBefore
(ya ++ ne ++ vizhu ++ tebya)
(ya ++ vizhu ++ ne ++ tebya)
} ;
-- A function specific for Russian:
U_predTransVerb : Bool -> TransVerb -> NounPhrase -> NounPhrase -> Sentence =
\b,Ser,Jag,Dig -> { s =
let {
menya = Jag.s ! (mkPronForm Gen Yes NonPoss) ;
bolit = Ser.s ! VFin (gNum Dig.g Dig.n) Dig.p ;
golova = Dig.s ! (mkPronForm Nom No NonPoss) ;
ne = negation b
} in
"у" ++ menya ++ ne ++ bolit ++ golova
} ;
-- This is a macro for simultaneous predication and complementation.
predTransVerb : Bool -> TransVerb -> NounPhrase -> NounPhrase -> Sentence =
\b,vizhu,ya,tu -> predVerbPhrase ya (complTransVerb b vizhu tu) ;
--3 Sentence-complement verbs
--
-- Sentence-complement verbs take sentences as complements.
SentenceVerb : Type = Verb ;
-- To generate "сказал, что Иван гуляет" / "не сказал, что Иван гуляет":
complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase =
\b,vidit,tuUlubaeshsya ->
{s = vidit.s ; s2 = negation b ; s3 = \\_,_ => [", что"] ++
tuUlubaeshsya.s ;
t = vidit.t ; v = vidit.v ; a = vidit.a ; negBefore = True } ;
--2 Sentences missing noun phrases
--
-- This is one instance of Gazdar's *slash categories*, corresponding to his
-- $S/NP$.
-- We cannot have - nor would we want to have - a productive slash-category former.
-- Perhaps a handful more will be needed.
--
-- 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 ;
slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase =
\b,ivan,lubit ->
predVerbPhrase ivan (predVerb b (verbOfTransVerb lubit)) **
complementOfTransVerb lubit ;
--2 Coordination
--
-- Coordination is to some extent orthogonal to the rest of syntax, and
-- has been treated in a generic way in the module $CO$ in the file
-- $coordination.gf$. The overall structure is independent of category,
-- but there can be differences in parameter dependencies.
--
--3 Conjunctions
--
-- Coordinated phrases are built by using conjunctions, which are either
-- simple ("и", "или") or distributed ("как - так", "либо - либо").
--
-- 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.
Conjunction = CO.Conjunction ** {n : Number} ;
ConjunctionDistr = CO.ConjunctionDistr ** {n : Number} ;
--2 Relative pronouns and relative clauses
--
oper
identRelPron : RelPron = { s = \\gn, c, anim =>
kotorujDet.s ! (AF c anim gn )} ;
funRelPron : Function -> RelPron -> RelPron = \mama, kotoruj ->
{s = \\gn,c, anim => let {nu = numGNum gn} in
mama.s ! nu ! c ++
mama.s2 ++ kotoruj.s ! gn ! mama.c ! anim
} ;
-- Relative clauses can be formed from both verb phrases ("видит Машу") and
-- slash expressions ("я вижу").
RelClause : Type = RelPron ;
relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \kotoruj, gulyaet ->
{ s = \\gn, c, anim => let { nu = numGNum gn } in
kotoruj.s ! gn ! c ! anim ++ gulyaet.s2 ++ gulyaet.s ! VFin gn P3 ++
gulyaet.s3 ! genGNum gn ! nu
} ;
relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause =
\kotoruj, yaVizhu ->
{s = \\gn, _ , anim => yaVizhu.s2 ++ kotoruj.s ! gn ! yaVizhu.c ! anim
++ yaVizhu.s
} ;
-- A 'degenerate' relative clause is the one often used in mathematics, e.g.
-- "число x, такое что x - четное".
relSuch : Sentence -> RelClause = \A ->
{s = \\gn,c, anim => takoj.s ! AF c anim gn ++ "что" ++ A.s } ;
-- 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.
modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase =
\chelovek,kotorujSmeetsya ->
{ s = \\n,c => chelovek.s ! n ! c ++ "," ++
kotorujSmeetsya.s ! gNum chelovek.g n ! Nom ! chelovek.anim;
g = chelovek.g ;
anim = chelovek.anim
} ;
--2 Interrogative pronouns
--
-- If relative pronouns are adjective-like, interrogative pronouns are
-- noun-phrase-like. Actually we can use the very same type!
IntPron : Type = NounPhrase ;
-- In analogy with relative pronouns, we have a rule for applying a function
-- to a relative pronoun to create a new one. We can reuse the rule applying
-- functions to noun phrases!
funIntPron : Function -> IntPron -> IntPron =
appFun False ;
-- There is a variety of simple interrogative pronouns:
-- "какая машина", "кто", "что".
nounIntPron : Number -> CommNounPhrase -> IntPron = \n, x ->
detNounPhrase (kakojDet ** {n = n; c= Nom}) x ;
intPronKto : Number -> IntPron = \num ->
{ s = table {
PF Nom _ _ => "кто" ;
PF Gen _ _ => "кого" ;
PF Dat _ _ => "кому" ;
PF Acc _ _ => "кого" ;
PF Inst _ _ => "кем" ;
PF Prepos _ _ => ["о ком"]
} ;
g = Masc ;
anim = Animate ;
n = num ;
p = P3 ;
pron = False
} ;
intPronChto : Number -> IntPron = \num ->
{ s = table {
PF Nom _ _ => "что" ;
PF Gen _ _ => "чего" ;
PF Dat _ _ => "чему" ;
PF Acc _ _ => "что" ;
PF Inst _ _ => "чем" ;
PF Prepos _ _=> ["о чем"]
} ;
g = Neut ;
anim = Inanimate ;
n = num ;
p = P3 ;
pron = False
} ;
--2 Utterances
-- By utterances we mean whole phrases, such as
-- 'can be used as moves in a language game': indicatives, questions, imperative,
-- and one-word utterances. The rules are far from complete.
--
-- N.B. we have not included rules for texts, which we find we cannot say much
-- about on this level. In semantically rich GF grammars, texts, dialogues, etc,
-- will of course play an important role as categories not reducible to utterances.
-- An example is proof texts, whose semantics show a dependence between premises
-- and conclusions. Another example is intersentential anaphora.
Utterance = SS ;
indicUtt : Sentence -> Utterance = \x -> postfixSS "." (defaultSentence x) ;
interrogUtt : Question -> Utterance = \x -> postfixSS "?" (defaultQuestion x) ;
--2 Questions
--
-- Questions are either direct ("Ты счастлив?")
-- or indirect ("Потом он спросил счастлив ли ты").
param
QuestForm = DirQ | IndirQ ;
oper
Question = SS1 QuestForm ;
--3 Yes-no questions
--
-- Yes-no questions are used both independently ("Ты взял мяч?")
-- and after interrogative adverbials ("Почему ты взял мяч?").
-- Note: The particle "ли" can also be used in direct questions:
-- Видел ли ты что-нибудь подобное?
-- but we are not considering this case.
questVerbPhrase : NounPhrase -> VerbPhrase -> Question =
\tu,spish ->
let { vu = tu.s ! (mkPronForm Nom No NonPoss);
spish = spish.s ! VFin (gNum tu.g tu.n) tu.p
++ spish.s2 ++ spish.s3 ! tu.g ! tu.n } in
{ s = table {
DirQ => vu ++ spish ;
IndirQ => spish ++ "ли" ++ vu
}
} ;
--3 Wh-questions
--
-- Wh-questions are of two kinds: ones that are like $NP - VP$ sentences,
-- others that are like $S/NP - NP$ sentences.
intVerbPhrase : IntPron -> VerbPhrase -> Question = \kto,spit ->
{s = table { _ => (predVerbPhrase kto spit).s }
} ;
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 }
} ;
--3 Interrogative adverbials
--
-- These adverbials will be defined in the lexicon: they include
-- "когда", "где", "как", "почему", etc, which are all invariant one-word
-- expressions. In addition, they can be formed by adding prepositions
-- to interrogative pronouns, in the same way as adverbials are formed
-- from noun phrases. N.B. we rely on record subtyping when ignoring the
-- position component.
IntAdverb = SS ;
-- A question adverbial can be applied to anything, and whether this makes
-- sense is a semantic question.
questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question =
\kak, tu, pozhivaesh ->
{s = \\q => kak.s ++ tu.s ! (mkPronForm Nom No NonPoss) ++
pozhivaesh.s2 ++ pozhivaesh.s ! VFin (gNum tu.g tu.n) tu.p ++
pozhivaesh.s3 ! tu.g ! tu.n } ;
--2 Imperatives
--
-- We only consider second-person imperatives.
Imperative: Type = { s: Gender => Number => Str } ;
imperVerbPhrase : VerbPhrase -> Imperative = \budGotov ->
{s = \\g, n => budGotov.s ! VImper n P2 ++ budGotov.s2 ++ budGotov.s3 ! g ! n} ;
imperUtterance : Gender -> Number -> Imperative -> Utterance = \g,n,I ->
ss (I.s ! g ! n ++ "!") ;
--3 Coordinating sentences
--
-- We need a category of lists of sentences. It is a discontinuous
-- category, the parts corresponding to 'init' and 'last' segments
-- (rather than 'head' and 'tail', because we have to keep track of the slot between
-- the last two elements of the list). A list has at least two elements.
ListSentence : Type = SD2 ;
twoSentence : (_,_ : Sentence) -> ListSentence = CO.twoSS ;
consSentence : ListSentence -> Sentence -> ListSentence =
CO.consSS CO.comma ;
-- 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. "ты куришь, вы пьете и я ем".
conjunctSentence : Conjunction -> ListSentence -> Sentence = \c,xs ->
ss (CO.conjunctX c xs) ;
-- To coordinate a list of sentences by a distributed conjunction, we place
-- the first part (e.g. "как") in front of the first element, the second
-- part ("так и") between the last two elements, and commas in the other slots.
-- For sentences this is really not used.
conjunctDistrSentence : ConjunctionDistr -> ListSentence -> Sentence =
\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
-- if and only if all elements are prefix.
ListAdjPhrase : Type =
{s1,s2 : AdjForm => Str ; p : Bool} ;
twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y ->
CO.twoTable AdjForm x y ** {p = andB x.p y.p} ;
consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x ->
CO.consTable AdjForm CO.comma xs x ** {p = andB xs.p x.p} ;
conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs ->
CO.conjunctTable AdjForm c xs ** {p = xs.p} ;
conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase = \c,xs ->
CO.conjunctDistrTable AdjForm c xs ** {p = xs.p} ;
--3 Coordinating noun phrases
--
-- The structure is the same as for sentences. The result is either always plural
-- or plural if any of the components is, depending on the conjunction.
ListNounPhrase : Type = { s1,s2 : PronForm => Str ; g: Gender ;
anim : Animacy ; n : Number ; p : Person ; pron : Bool } ;
twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y ->
CO.twoTable PronForm x y ** {n = conjNumber x.n y.n ;
g = conjGender x.g y.g ; p = conjPerson x.p y.p ;
pron = conjPron x.pron y.pron ; anim = conjAnim x.anim y.anim } ;
consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x ->
CO.consTable PronForm CO.comma xs x **
{n = conjNumber xs.n x.n ; g = conjGender x.g xs.g ;
anim = conjAnim x.anim xs.anim ;
p = conjPerson xs.p x.p; pron = conjPron xs.pron x.pron} ;
conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \c,xs ->
CO.conjunctTable PronForm c xs ** {n = conjNumber c.n xs.n ;
anim = xs.anim ;
p = xs.p; g = xs.g ; pron = xs.pron} ;
conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase =
\c,xs ->
CO.conjunctDistrTable PronForm c xs ** {n = conjNumber c.n xs.n ;
p = xs.p ; pron = xs.pron ; anim = xs.anim ;
g = xs.g } ;
-- We have to define a calculus of numbers of persons. For numbers,
-- it is like the conjunction with $Pl$ corresponding to $False$.
conjNumber : Number -> Number -> Number = \m,n -> case <m,n> of {
<Sg,Sg> => Sg ;
_ => Pl
} ;
-- For persons, we let the latter argument win ("либо ты, либо я пойду"
-- but "либо я, либо ты пойдешь"). This is not quite clear.
conjPerson : Person -> Person -> Person = \_,p ->
p ;
-- For pron, we let the latter argument win - "Маша или моя мама" (Nominative case)
-- but - "моей или Машина мама" (Genetive case) both corresponds to
-- "Masha's or my mother"), which is actually not exactly correct, since
-- different cases should be used - "Машина или моя мама".
conjPron : Bool -> Bool -> Bool = \_,p ->
p ;
-- For gender in a similar manner as for person:
-- Needed for adjective predicates like:
-- "Маша или Оля - красивая", "Антон или Олег - красивый",
-- "Маша или Олег - красивый".
-- The later is not totally correct, but there is no correct way to say that.
conjGender : Gender -> Gender -> Gender = \_,m -> m ;
conjAnim : Animacy -> Animacy -> Animacy = \_,m -> m ;
--2 Subjunction
--
-- Subjunctions ("когда", "если", etc)
-- are a different way to combine sentences than conjunctions.
-- The main clause can be a sentence, an imperative, or a question,
-- but the subjoined clause must be a sentence.
--
-- There are uniformly two variant word orders, e.g.
-- "если ты закуришь, я рассержусь"
-- and "я рассержусь, если ты закуришь".
Subjunction = SS ;
subjunctSentence : Subjunction -> Sentence -> Sentence -> Sentence =
\if, A, B ->
ss (subjunctVariants if A.s B.s) ;
subjunctImperative : Subjunction -> Sentence -> Imperative -> Imperative =
\if, A, B ->
{s = \\g,n => subjunctVariants if A.s (B.s ! g ! n)} ;
subjunctQuestion : Subjunction -> Sentence -> Question -> Question =
\if, A, B ->
{s = \\q => subjunctVariants if A.s (B.s ! q)} ;
subjunctVariants : Subjunction -> Str -> Str -> Str = \if,A,B ->
variants {if.s ++ A ++ "," ++ B ; B ++ "," ++ if.s ++ A} ;
--2 One-word utterances
--
-- An utterance can consist of one phrase of almost any category,
-- the limiting case being one-word utterances. These
-- utterances are often (but not always) in what can be called the
-- default form of a category, e.g. the nominative.
-- This list is far from exhaustive.
useNounPhrase : NounPhrase -> Utterance = \masha ->
postfixSS "." (defaultNounPhrase masha) ;
useCommonNounPhrase : Number -> CommNounPhrase -> Utterance = \n,mashina ->
useNounPhrase (indefNounPhrase n mashina) ;
useRegularName : Gender -> SS -> NounPhrase = \g, masha ->
nameNounPhrase (case g of { Masc => mkProperNameMasc masha.s Animate;
_ => mkProperNameFem masha.s Animate }) ;
-- Here are some default forms.
defaultNounPhrase : NounPhrase -> SS = \masha ->
ss (masha.s ! PF Nom No NonPoss) ;
defaultQuestion : Question -> SS = \ktoTu ->
ss (ktoTu.s ! DirQ) ;
defaultSentence : Sentence -> Utterance = \x ->
x ;
};

View File

@@ -0,0 +1,40 @@
-- use this path to read the grammar from the same directory
--# -path=.:../abstract:../../prelude
concrete TestRus of TestAbs = ResRus ** open Syntax in {
flags
coding=utf8 ;
startcat=Phr ; lexer=text ; parser=chart ; unlexer=text ;
-- a random sample from the lexicon
lin
Big = bolshoj ;
Small = malenkij ;
Old = staruj ;
Young = molodoj ;
Man = muzhchina ;
Woman = zhenchina ;
Car = mashina ;
House = dom ;
Light = svet ;
Walk = extVerb verbGulyat Act Present ;
Run = extVerb verbBegat Act Present ;
Love = mkDirectVerb (extVerb verbLubit Act Present ) ;
Send = mkDirectVerb (extVerb verbOtpravlyat Act Present ) ;
Wait = mkDirectVerb (extVerb verbZhdat Act Present );
Say = extVerb verbGovorit Act Present ; --- works in present tense...
Prove = extVerb verbDokazuvat Act Present ;
SwitchOn = mkDirectVerb (extVerb verbVkluchat Act Present ) ;
SwitchOff = mkDirectVerb (extVerb verbVukluchat Act Present ) ;
Mother = funGen mama ;
Uncle = funGen dyadya ;
Always = vsegda ;
Well = chorosho ;
John = mkProperNameMasc "Иван" Animate ;
Mary = mkProperNameFem "Маш" Animate ;
};

View File

@@ -0,0 +1,288 @@
--1 Russian Word Classes and Morphological Parameters
--
-- Aarne Ranta, Janna Khegai 2003
--
-- This is a resource module for Russian morphology, defining the
-- morphological parameters and word classes of Russian. It is aimed
-- to be complete w.r.t. the description of word forms.
-- However, it does not include those parameters that are not needed for
-- analysing individual words: such parameters are defined in syntax modules.
--
resource Types = open Prelude in {
flags coding=utf8 ;
--2 Enumerated parameter types
--
-- These types are the ones found in school grammars.
-- Their parameter values are atomic.
param
Gender = Masc | Fem | Neut ;
Number = Sg | Pl ;
Case = Nom | Gen | Dat | Acc | Inst | Prepos ;
Voice = Act | Pass ;
Aspect = Imperfective | Perfective ;
Tense = Present | Past ;
Degree = Pos | Comp | Super ;
Person = P1 | P2 | P3 ;
AfterPrep = Yes | No ;
Possessive = NonPoss | Poss GenNum ;
Animacy = Animate | Inanimate ;
-- A number of Russian nouns have common gender. They can
-- denote both males and females: "умница" (a clever person), "инженер" (an engineer).
-- We overlook this phenomenon for now.
-- The AfterPrep parameter is introduced in order to describe
-- the variations of the third person personal pronoun forms
-- depending on whether they come after a preposition or not.
-- The Possessive parameter is introduced in order to describe
-- the possessives of personal pronouns, which are used in the
-- Genetive constructions like "мама моя" (my mother) instead of
-- "мама меня" (the mother of mine).
--2 Word classes and hierarchical parameter types
--
-- Real parameter types (i.e. ones on which words and phrases depend)
-- are mostly hierarchical. The alternative would be cross-products of
-- simple parameters, but this would usually overgenerate.
-- However, we use the cross-products in complex cases
-- (for example, aspect and tense parameter in the verb description)
-- where the relationship between the parameters are non-trivial
-- even though we aware that some combinations do not exist
-- (for example, present perfective does not exist, but removing
-- this combination would lead to having different descriptions
-- for perfective and imperfective verbs, which we do not want for the
-- sake of uniformity).
--3 Nouns
--
-- Common nouns decline according to number and case.
-- For the sake of shorter description these parameters are
-- combined in the type SubstForm.
param SubstForm = SF Number Case ;
-- Substantives moreover have an inherent gender.
oper
CommNoun : Type = {s : SubstForm => Str ; g : Gender ; anim : Animacy } ;
numSF: SubstForm -> Number = \sf -> case sf of
{
SF Sg _ => Sg ;
_ => Pl
} ;
caseSF: SubstForm -> Case = \sf -> case sf of
{
SF _ Nom => Nom ;
SF _ Gen => Gen ;
SF _ Dat => Dat ;
SF _ Inst => Inst ;
SF _ Acc => Acc ;
SF _ Prepos => Prepos
} ;
--
--3 Pronouns
--
oper
Pronoun : Type = { s : PronForm => Str ; n : Number ;
p : Person ; g: PronGen ; pron: Bool} ;
param PronForm = PF Case AfterPrep Possessive;
-- Gender is not morphologically determined for first
-- and second person pronouns.
PronGen = PGen Gender | PNoGen ;
-- The following coercion is useful:
oper
pgen2gen : PronGen -> Gender = \p -> case p of {
PGen g => g ;
PNoGen => variants {Masc ; Fem} --- the best we can do for ya, tu
} ;
oper
extCase: PronForm -> Case = \pf -> case pf of
{ PF Nom _ _ => Nom ;
PF Gen _ _ => Gen ;
PF Dat _ _ => Dat ;
PF Inst _ _ => Inst ;
PF Acc _ _ => Acc ;
PF Prepos _ _ => Prepos
} ;
mkPronForm: Case -> AfterPrep -> Possessive -> PronForm =
\c,n,p -> PF c n p ;
--3 Adjectives
--
-- Adjectives is a very complex class.
-- The major division is between the comparison degrees.
param
AdjForm = AF Case Animacy GenNum ;
-- Declination forms depend on Case, Animacy , Gender:
-- "большие дома" - "больших домов" (big houses - big houses'),
-- Animacy plays role only in the Accusative case:
-- "я люблю большие дома"-"я люблю больших мужчин"
-- (I love big houses - I love big men);
-- and on Number: "большой дом" - "большие дома"
-- (a big house - big houses).
-- The plural never makes a gender distinction.
GenNum = ASg Gender | APl ;
oper numGNum : GenNum -> Number = \gn ->
case gn of { APl => Pl ; _ => Sg } ;
oper genGNum : GenNum -> Gender = \gn ->
case gn of { ASg Fem => Fem; _ => Masc } ;
oper numAF: AdjForm -> Number = \af ->
case af of { AF _ _ gn => (numGNum gn) } ;
oper caseAF: AdjForm -> Case = \af ->
case af of { AF c _ _ => c } ;
-- The Degree parameter should also be more complex, since most Russian
-- adjectives have two comparative forms:
-- attributive (syntactic (compound), declinable) -
-- "более высокий" (corresponds to "more high")
-- and predicative (indeclinable)- "выше" (higher) and more than one
-- superlative forms: "самый высокий" (corresponds to "the most high") -
-- "наивысший" (the highest).
-- Even one more parameter independent of the degree can be added,
-- since Russian adjectives in the positive degree also have two forms:
-- long (attributive and predicative) - "высокий" (high) and short (predicative) - "высок"
-- although this parameter will not be exactly orthogonal to the
-- degree parameter.
-- Short form has no case declension, so in principle
-- it can be considered as an additional case.
-- Note: although the predicative usage of the long
-- form is perfectly grammatical, it can have a slightly different meaning
-- compared to the short form.
-- For example: "он - больной" (long, predicative) vs.
-- "он - болен" (short, predicative).
oper
AdjDegr : Type = {s : Degree => AdjForm => Str} ;
-- Adjective type includes both non-degree adjective classes:
-- possesive ("мамин"[mother's], "лисий" [fox'es])
-- and relative ("русский" [Russian]) adjectives.
Adjective : Type = {s : AdjForm => Str} ;
--3 Verbs
-- Mood is the main verb classification parameter.
-- The verb mood can be infinitive, subjunctive, imperative, and indicative.
-- Note: subjunctive mood is analytical, i.e. formed from the past form of the
-- indicative mood plus the particle "бы". That is why they have the same GenNum
-- parameter. We choose to keep the "redundant" form in order to indicate
-- the presence of the subjunctive mood in Russian verbs.
-- Aspect and Voice parameters are present in every mood, so Voice is put
-- before the mood parameter in verb form description the hierachy.
-- Moreover Aspect is regarded as an inherent parameter of a verb entry.
-- The primary reason for that is that one imperfective form can have several
-- perfective forms: "ломать" - "с-ломать" - "по-ломать" (to break).
-- Besides, the perfective form could be formed from imperfective
-- by prefixation, but also by taking a completely different stem:
-- "говорить"-"сказать" (to say). In the later case it is even natural to
-- regard them as different verb entries.
-- Another reason is that looking at the Aspect as an inherent verb parameter
-- seem to be customary in other similar projects:
-- http://starling.rinet.ru/morph.htm
-- Note: Of course, the whole inflection table has many redundancies
-- in a sense that many verbs do not have all grammatically possible
-- forms. For example, passive does not exist for the verb
-- "любить" (to love), but exists for the verb "ломать" (to break).
-- Depending on the tense verbs conjugate according to combinations
-- of gender, person and number of the verb objects.
-- Participles (Present and Past) and Gerund forms are not included in the
-- current description. This is the verb type used in the lexicon:
oper Verbum : Type = { s: VerbForm => Str ; asp : Aspect };
param
VerbForm = VFORM Voice VerbConj ;
VerbConj = VIND VTense | VIMP Number Person | VINF | VSUB GenNum ;
VTense = VPresent Number Person | VPast GenNum | VFuture Number Person ;
-- For writing an application grammar one usually doesn't need
-- the whole inflection table, since each verb is used in
-- a particular context that determines some of the parameters
-- (Tense and Voice while Aspect is fixed from the beginning) for certain usage.
-- So we define the "Verb" type, that have these parameters fixed.
-- The conjugation parameters left (Gender, Number, Person)
-- are combined in the "VF" type:
param VF =
VFin GenNum Person | VImper Number Person | VInf | VSubj GenNum;
oper
Verb : Type = {s : VF => Str ; t: Tense ; a : Aspect ; v: Voice} ;
extVerb : Verbum -> Voice -> Tense -> Verb = \aller, vox, t ->
{ s = table {
VFin gn p => case t of {
Present => aller.s ! VFORM vox (VIND (VPresent (numGNum gn) p)) ;
Past => aller.s ! VFORM vox (VIND (VPast gn))
} ;
VImper n p => aller.s ! VFORM vox (VIMP n p) ;
VInf => aller.s ! VFORM vox VINF ;
VSubj gn => aller.s ! VFORM vox (VSUB gn)
}; t = t ; a = aller.asp ; v = vox } ;
--3 Other open classes
--
-- Proper names and adverbs are the remaining open classes.
oper
PNm : Type = {s : Case => Str ; g : Gender} ;
-- Adverbials are not inflected (we ignore comparison, and treat
-- compared adverbials as separate expressions; this could be done another way).
Adverb : Type = SS ;
--3 Closed classes
--
-- The rest of the Russian word classes are closed, i.e. not extensible by new
-- lexical entries. Thus we don't have to know how to build them, but only
-- how to use them, i.e. which parameters they have.
--
--3 Relative pronouns
--
-- Relative pronouns are inflected in
-- gender, number, and case just like adjectives.
RelPron : Type = {s : GenNum => Case => Animacy => Str} ;
--3 Prepositions are just strings.
Preposition = Str ;
};