diff --git a/src/Lang.labels b/src/Lang.labels index 7b574b343..fb55ff6d9 100644 --- a/src/Lang.labels +++ b/src/Lang.labels @@ -1,157 +1,157 @@ -PredVP nsubj head -PredVPS nsubj head -DirectComplVQ empty nsubj head ccomp -- Temp argument can only be empty in English -DirectComplVS empty nsubj head ccomp -- Temp argument can only be empty in English -SlashVP nsubj head -SlashVS nsubj head ccomp -FocusObjS nsubj head -- again might be wrong; more correct to call it dobj -QuestIAdv advmod head -- "where does John sleep" cf. AdvVP -QuestIComp head nsubj -- "where is John": John is clearly nsubj, but is where the head? -QuestQVP nsubj head -QuestSlash obj head -QuestVP nsubj head +PredVP nsubj head +PredVPS nsubj head +DirectComplVQ empty nsubj head ccomp -- Temp argument can only be empty in English +DirectComplVS empty nsubj head ccomp -- Temp argument can only be empty in English +SlashVP nsubj head +SlashVS nsubj head ccomp +FocusObjS nsubj head -- again might be wrong; more correct to call it obj +QuestIAdv advmod head -- "where does John sleep" cf. AdvVP +QuestIComp head nsubj -- "where is John": John is clearly nsubj, but is where the head? +QuestQVP nsubj head +QuestSlash obj head +QuestVP nsubj head IdetCN det head -PredSCVP csubj head +PredSCVP csubj head -ComplSlash head obj -ComplSlashIP head obj -Slash3V3 head obj -SlashV2VNP head obj xcomp -PastPartAgentAP head obj -AdvQVP head obj +ComplSlash head obj +ComplSlashIP head obj +Slash3V3 head obj +SlashV2VNP head obj xcomp +PastPartAgentAP head obj +AdvQVP head obj -Slash2V3 head iobj +Slash2V3 head iobj -ComplVS head ccomp -ComplVQ head ccomp -SlashV2S head ccomp -SlashV2Q head ccomp -CleftAdv head advcl -- not sure +ComplVS head ccomp +ComplVQ head ccomp +SlashV2S head ccomp +SlashV2Q head ccomp +CleftAdv head advcl -- not sure -ComplVA head xcomp -ComplVV head xcomp -SlashVV head acl -SlashV2A head xcomp -SlashV2V head xcomp +ComplVA head xcomp +ComplVV head xcomp +SlashVV head acl +SlashV2A head xcomp +SlashV2V head xcomp -AdvNP head nmod -- not sure -ExtAdvNP head nmod -- not sure -PassAgentVPSlash head nmod -- not sure -CleftNP head acl -- this cannot be nmod, not with type RS +AdvNP head nmod -- not sure +ExtAdvNP head nmod -- not sure +PassAgentVPSlash head nmod -- not sure +CleftNP head acl -- this cannot be nmod, not with type RS -SSubjS head mark advcl -RelS head advcl +SSubjS head mark advcl +RelS head advcl -AdNum advmod head -AdAP advmod head -AdvAP head advmod -ComparAdvAdj advmod amod head -ComparAdvAdjS advmod amod head -AdvIAdv advmod head -AdVVP advmod head -AdvVP head advmod -ExtAdvVP head advmod -AddAdvQVP head advmod -AdVVPSlash advmod head -AdvVPSlash head advmod -AdvSlash head advmod -ExistIPAdv head advmod -AdvS advmod head -ExtAdvS advmod head +AdNum advmod head +AdAP advmod head +AdvAP head advmod +ComparAdvAdj advmod amod head +ComparAdvAdjS advmod amod head +AdvIAdv advmod head +AdVVP advmod head +AdvVP head advmod +ExtAdvVP head advmod +AddAdvQVP head advmod +AdVVPSlash advmod head +AdvVPSlash head advmod +AdvSlash head advmod +ExistIPAdv head advmod +AdvS advmod head +ExtAdvS advmod head -SubjS mark head -RelVP mark head -RelSlash mark head +SubjS mark head +RelVP mark head +RelSlash mark head -ComplN2 head nmod -ComplN3 nmod head -AdvCN head nmod -PossNP head nmod -PartNP head nmod -ExistNPAdv head nmod +ComplN2 head nmod +ComplN3 nmod head +AdvCN head nmod +PossNP head nmod +PartNP head nmod +ExistNPAdv head nmod -OrdNumeralSuperl nummod head -- quite wrong; cannot find relevant details in the documentation; but most probably head lies outside the score of this function -DetQuant head nummod -- quite wrong; I think the head lies outside the scope of the function -CNNumNP head nummod +OrdNumeralSuperl nummod head -- quite wrong; cannot find relevant details in the documentation; but most probably head lies outside the score of this function +DetQuant head nummod -- quite wrong; I think the head lies outside the scope of the function +CNNumNP head nummod -ApposCN head appos -ApposNP head appos +ApposCN head appos +ApposNP head appos -RelNP head acl -RelCN head acl -SentCN head acl -SentAP head acl +RelNP head acl +RelCN head acl +SentCN head acl +SentAP head acl -DetQuantOrd head nummod amod -- quite wrong; again for same reason as DetQuant function -DetCN det head -IdetCN det head +DetQuantOrd head nummod amod -- quite wrong; again for same reason as DetQuant function +DetCN det head +IdetCN det head IdetQuant head nummod -CountNP det head -PredetNP det head +CountNP det head +PredetNP det head PPartNP head amod -- only in core RGL -AdjCN amod head -AdjDAP head amod -CAdvAP case amod head -ComparA amod head -ComplA2 amod head -CompoundAP head amod -AdAdV amod head -AdAdv amod head +AdjCN amod head +AdjDAP head amod +CAdvAP case amod head +ComparA amod head +ComplA2 amod head +CompoundAP head amod +AdAdV amod head +AdAdv amod head -CompoundN compound head +CompoundN compound head -IIDig head goeswith +IIDig head goeswith -PrepNP case head -PrepIP case head -SlashPrep head case -VPSlashPrep head case +PrepNP case head +PrepIP case head +SlashPrep head case +VPSlashPrep head case -UttImpPl empty head -UttImpPol empty head -UttImpSg empty head +UttImpPl empty head +UttImpPol empty head +UttImpSg empty head -MkVPS empty empty head +MkVPS empty empty head -UseCl empty empty head -UseQCl empty empty head -UseRCl empty empty head -UseSlash empty empty head -UseVC empty empty head +UseCl empty empty head +UseQCl empty empty head +UseRCl empty empty head +UseSlash empty empty head +UseVC empty empty head -BaseAP head conj -BaseAdV head conj -BaseAdv head conj -BaseCN head conj -BaseDAP head conj -BaseIAdv head conj -BaseNP head conj -BaseRS head conj -BaseS head conj -ConsAP head conj -ConsAdV head conj -ConsAdv head conj -ConsCN head conj -ConsDAP head conj -ConsIAdv head conj -ConsNP head conj -ConsRS head conj -ConsS head conj -ConjAP cc head -ConjAdV cc head -ConjAdv cc head -ConjCN cc head -ConjDet cc head -ConjIAdv cc head -ConjNP cc head -ConjRS cc head -ConjS cc head -PhrUtt cc head discourse +BaseAP head conj +BaseAdV head conj +BaseAdv head conj +BaseCN head conj +BaseDAP head conj +BaseIAdv head conj +BaseNP head conj +BaseRS head conj +BaseS head conj +ConsAP head conj +ConsAdV head conj +ConsAdv head conj +ConsCN head conj +ConsDAP head conj +ConsIAdv head conj +ConsNP head conj +ConsRS head conj +ConsS head conj +ConjAP cc head +ConjAdV cc head +ConjAdv cc head +ConjCN cc head +ConjDet cc head +ConjIAdv cc head +ConjNP cc head +ConjRS cc head +ConjS cc head +PhrUtt cc head discourse -PlusChunk head dep -TTAnt empty empty head +PlusChunk head dep +TTAnt empty empty head TExclMark head dep -- punctuation in the middle in these three TFullStop head dep @@ -159,13 +159,13 @@ TQuestMark head dep ComplV2 head obj -- shortcuts in App ComplV2V head obj xcomp -ComplV3 head iobj obj ---- could be dobj dobj +ComplV3 head iobj obj ---- could be obj obj PassAgentV2 head ncomp -- not sure RelV2 mark nsubj head QuestV2 obj nsubj head ModCN amod head -- in ResourceDemo -RSubjS mark advcl head +RSubjS mark advcl head SlashV2 nsubj head RAdvCN head case nmod SubjCl head mark advcl @@ -181,7 +181,7 @@ AdV ADV Adv ADV CAdv ADV Card NUM -Conj CONJ +Conj CCONJ Det DET Digits NUM IAdv ADV @@ -194,7 +194,7 @@ N2 NOUN N3 NOUN Numeral NUM Ord NUM -PConj CONJ +PConj CCONJ PN PROPN Predet DET Prep ADP @@ -214,7 +214,3 @@ VA VERB VQ VERB VS VERB VV VERB - - - - diff --git a/src/chinese/AdjectiveChi.gf b/src/chinese/AdjectiveChi.gf index 61c2fa60f..ab17134ac 100644 --- a/src/chinese/AdjectiveChi.gf +++ b/src/chinese/AdjectiveChi.gf @@ -4,26 +4,58 @@ concrete AdjectiveChi of Adjective = CatChi ** open ResChi, Prelude in { PositA a = a ** {hasAdA = False} ; - --ComparA a np = complexAP (a.s ++ than_s ++ np.s) ; - ComparA a np = complexAP (than_s ++ np.s ++ a.s) ; + ComparA a np = a ** { + s = table {_=> than_s ++ np.s ++ a.s!Attr}; + hasAdA = False - UseComparA a = complexAP (geng_s ++ a.s) ; + }; - AdjOrd ord = complexAP ord.s ; + UseComparA a = a ** { + s = table { _=> geng_s ++ a.s!Attr}; + hasAdA = False + }; - -- CAdvAP ad ap np = complexAP (ap.s ++ ad.s ++ ad.p ++ np.s) ; - CAdvAP ad ap np = complexAP (ad.s++ np.s++ad.p++ap.s ) ; --modified by ChenPeng 11.24 + AdjOrd ord = ord ** { + s = table { + adjPlace => ord.s + -- Attr => ord.s; --"first is he" ; + -- Pred => ord.s --"he is first" + } ; + hasAdA = False; + monoSyl = True -- to do and figure out in relation to Ord = {s : Str} + }; - ComplA2 a np = complexAP (appPrep a.c2 np.s ++ a.s) ; + CAdvAP ad ap np = ap ** { + s = table {adjPlace => ad.s ++ np.s ++ ad.p ++ ap.s!adjPlace} + }; - ReflA2 a = complexAP (a.s ++ appPrep a.c2 reflPron) ; + ComplA2 a np = a ** { + s= table { adjPlace => appPrep a.c2 np.s ++ a.s!adjPlace}; + hasAdA = False + }; - SentAP ap sc = complexAP (ap.s ++ sc.s) ; - AdAP ada ap = {s = ada.s ++ ap.s ; monoSyl = False ; hasAdA = True} ; + ReflA2 a = a ** { + s = table {adjPlace => a.s!adjPlace ++ appPrep a.c2 reflPron}; + hasAdA = False + }; + + + SentAP ap sc = ap ** { + s = table { adjPlace => ap.s ! adjPlace ++ sc.s } + } ; + + -- AdAP ada ap = {s = ada.s ++ ap.s ; monoSyl = False ; hasAdA = True} ; + AdAP ada ap = ap ** { + s = table { adjPlace => ada.s ++ ap.s ! adjPlace }; + monoSyl = False; + hasAdA = True + }; UseA2 a = a ** {hasAdA = False} ; - - AdvAP ap adv = complexAP (adv.s ++ ap.s) ; ---- + + AdvAP ap adv = ap ** { + s = table { adjPlace => adv.s ++ ap.s ! adjPlace } + }; } diff --git a/src/chinese/AdverbChi.gf b/src/chinese/AdverbChi.gf index 8a50ddd90..206b14d57 100644 --- a/src/chinese/AdverbChi.gf +++ b/src/chinese/AdverbChi.gf @@ -1,21 +1,21 @@ -concrete AdverbChi of Adverb = CatChi ** +concrete AdverbChi of Adverb = CatChi ** open ResChi, Prelude in { lin - PositAdvAdj a = {s = a.s ++ "地" ; advType = ATManner ; hasDe = False} ; ---- for all adjs? + PositAdvAdj a = {s = a.s!Attr ++ "地" ; advType = ATManner ; hasDe = False} ; ---- for all adjs? - PrepNP prep np = ss (appPrep prep np.s) ** {advType = prep.advType ; hasDe = prep.hasDe} ; --- should depend on np too ? + PrepNP prep np = ss (appPrep prep np.s) ** {advType = prep.advType ; hasDe = prep.hasDe} ; --- should depend on np too ? - ComparAdvAdj cadv a np = ss (a.s ++ cadv.s ++ cadv.p ++ np.s) ** {advType = ATManner ; hasDe = False} ; + ComparAdvAdj cadv a np = ss (a.s!Attr ++ cadv.s ++ cadv.p ++ np.s) ** {advType = ATManner ; hasDe = False} ; - ComparAdvAdjS cadv a s = ss (a.s ++ cadv.s ++ cadv.p ++ s.s) ** {advType = ATManner ; hasDe = False} ; + ComparAdvAdjS cadv a s = ss (a.s!Attr ++ cadv.s ++ cadv.p ++ linS s) ** {advType = ATManner ; hasDe = False} ; AdAdv ad adv = adv ** {s = ad.s ++ adv.s} ; - SubjS subj s = ss (subj.prePart ++ s.s ++ subj.sufPart) ** {advType = ATTime ; hasDe = False} ; + SubjS subj s = ss (subj.prePart ++ linS s ++ subj.sufPart) ** {advType = ATTime ; hasDe = False} ; AdnCAdv cadv = ss (cadv.s ++ conjThat) ** {advType = ATManner ; hasDe = False} ; ----- - PositAdAAdj a = {s = a.s} ; ---- + PositAdAAdj a = {s = a.s!Attr} ; ---- } diff --git a/src/chinese/CatChi.gf b/src/chinese/CatChi.gf index 679846ced..a046e7550 100644 --- a/src/chinese/CatChi.gf +++ b/src/chinese/CatChi.gf @@ -4,14 +4,14 @@ concrete CatChi of Cat = CommonX - [Tense, Temp, Ant, Adv] ** open ResChi, Prelu -- Tensed/Untensed - S = {s : Str} ; + S = Sentence ; QS = {s : Bool => Str} ; -- True = direct question (with ma for sentential questions) RS = {s : Str} ; - SSlash = {s : Str ; c2 : Preposition} ; + SSlash = {s : Str ; c2 : Preposition} ; -- Sentence - Cl = Clause ; -- {s : Polarity => Aspect => Str ; np: Str ; vp: Polarity => Aspect => Str} ; + Cl = Clause ; -- {s : Polarity => Aspect => Str ; np: Str ; vp: Polarity => Aspect => Str} ; ClSlash = Clause ** {c2 : Preposition} ; @@ -21,7 +21,7 @@ concrete CatChi of Cat = CommonX - [Tense, Temp, Ant, Adv] ** open ResChi, Prelu QCl = {s : Bool => Polarity => Aspect => Str} ; -- True = direct question IP = {s : Str} ; - IComp = {s : Str} ; + IComp = {s : Str} ; IDet = {s : Str ; detType : DetType} ; IQuant = {s : Str} ; @@ -32,7 +32,7 @@ concrete CatChi of Cat = CommonX - [Tense, Temp, Ant, Adv] ** open ResChi, Prelu -- Verb - VP = ResChi.VP ; + VP = ResChi.VP ; Comp = ResChi.VP ; VPSlash = ResChi.VP ** {c2 : Preposition ; isPre : Bool} ; -- whether the missing arg is before verb @@ -59,13 +59,16 @@ concrete CatChi of Cat = CommonX - [Tense, Temp, Ant, Adv] ** open ResChi, Prelu -- Structural - Conj = {s : ConjForm => {s1,s2 : Str}} ; + Conj = { + s : ConjForm => {s1,s2 : Str} ; -- different form whether it's used for S, A, N, ... + conjType : ConjType -- different placement whether it's and,or,... or if-then + } ; Subj = {prePart : Str ; sufPart : Str} ; Prep = Preposition ; -- Open lexical classes, e.g. Lexicon - V, VS, VQ, VA = Verb ; + V, VS, VQ, VA = Verb ; V2, V2Q, V2S = Verb ** {c2 : Preposition ; hasPrep : Bool ; part : Str} ; V3, V2A, V2V = Verb ** {c2, c3 : Preposition ; hasPrep : Bool ; part : Str} ; VV = Verb ; @@ -84,4 +87,6 @@ concrete CatChi of Cat = CommonX - [Tense, Temp, Ant, Adv] ** open ResChi, Prelu Tense = {s : Str ; t : Aspect} ; Ant = {s : Str ; t : Aspect} ; +linref + S = linS ; } diff --git a/src/chinese/ConjunctionChi.gf b/src/chinese/ConjunctionChi.gf index e507667ae..2dc17731e 100644 --- a/src/chinese/ConjunctionChi.gf +++ b/src/chinese/ConjunctionChi.gf @@ -2,33 +2,47 @@ concrete ConjunctionChi of Conjunction = CatChi ** open ResChi, Prelude, Coordin lin - ConjS c = conjunctDistrSS (c.s ! CSent) ; + ConjS c ss = + let conj = c.s ! CSent + in case c.conjType of { + Jiu => {preJiu = conj.s1 ++ ss.s1 ++ comma ++ ss.preJiu ; + postJiu = conj.s2 ++ ss.postJiu} ; + NotJiu => {preJiu = conj.s1 ++ ss.s1 ++ conj.s2 ++ ss.preJiu ; + postJiu = ss.postJiu} + } ; ConjAdv c as = conjunctDistrSS (c.s ! CSent) as ** {advType = as.advType ; hasDe = as.hasDe} ; ---- ?? ConjNP c = conjunctDistrSS (c.s ! CPhr CNPhrase) ; - ConjAP c as = conjunctDistrSS (c.s ! CPhr CAPhrase) as ** {monoSyl = notB as.monoSyl ; hasAdA = True} ; ---- add de iff as doesn't + ConjAP c as = conjunctDistrTable AdjPlace (c.s ! CPhr CAPhrase) as ** {monoSyl = notB as.monoSyl ; hasAdA = True} ; ---- add de iff as doesn't ConjRS c = conjunctDistrSS (c.s ! CSent) ; - ConjCN c ns = conjunctDistrSS (c.s ! CPhr CNPhrase) ns ** {c = ns.c} ; + ConjCN c ns = conjunctDistrSS (c.s ! CPhr CNPhrase) ns ** {c = ns.c} ; -- These fun's are generated from the list cat's. - BaseS = twoSS ; - ConsS = consrSS duncomma ; + BaseS s t = t ** { + s1 = linS s + } ; + + ConsS s ss = -- here we do the same thing actually, the crucial split has happened in BaseS + ss ** {s1 = linS s ++ comma ++ ss.s1}; + + BaseAdv x y = twoSS x y ** {advType = x.advType ; hasDe = y.hasDe} ; ---- ?? ConsAdv x xs = consrSS duncomma x xs ** {advType = x.advType ; hasDe = xs.hasDe} ; ---- ?? BaseNP = twoSS ; ConsNP = consrSS duncomma ; - BaseAP x y = twoSS x y ** {monoSyl = y.monoSyl} ; - ConsAP x xs = consrSS duncomma x xs ** {monoSyl = xs.monoSyl} ; + BaseAP x y = twoTable AdjPlace x y ** {monoSyl = y.monoSyl} ; + ConsAP x xs = consrTable AdjPlace duncomma x xs ** {monoSyl = xs.monoSyl} ; BaseRS = twoSS ; ConsRS = consrSS duncomma ; BaseCN x y = twoSS x y ** {c = x.c} ; --- classified comes from first part ; should it rather be ge? ConsCN x xs = consrSS duncomma x xs ** {c = x.c} ; lincat - [S] = {s1,s2 : Str} ; + --[S] = ConjType => {s1,s2 : Str} ; + [S] = {s1,preJiu,postJiu : Str} ; [Adv] = {s1,s2 : Str ; advType : AdvType ; hasDe : Bool} ; [NP] = {s1,s2 : Str} ; - [AP] = {s1,s2 : Str ; monoSyl : Bool} ; + [AP] = {s1,s2 : AdjPlace => Str ; monoSyl : Bool} ; [RS] = {s1,s2 : Str} ; [CN] = {s1,s2 : Str ; c : Str} ; diff --git a/src/chinese/DocumentationChi.gf b/src/chinese/DocumentationChi.gf index ef76c9ee5..9ac20f480 100644 --- a/src/chinese/DocumentationChi.gf +++ b/src/chinese/DocumentationChi.gf @@ -1,6 +1,6 @@ concrete DocumentationChi of Documentation = CatChi ** open ResChi, - HTML + HTML in { lincat @@ -19,9 +19,9 @@ lin InflectionA, InflectionA2 = \adj -> { t = "a" ; s1 = heading1 "Adjective" ; - s2 = adj.s + s2 = adj.s!Attr } ; - + InflectionAdv, InflectionAdV, InflectionAdA, InflectionAdN = \adv -> { t = "adv" ; s1 = heading1 "Adverb" ; diff --git a/src/chinese/ExtraChi.gf b/src/chinese/ExtraChi.gf index cba1a0924..689432d3d 100644 --- a/src/chinese/ExtraChi.gf +++ b/src/chinese/ExtraChi.gf @@ -1,9 +1,9 @@ -concrete ExtraChi of ExtraChiAbs = CatChi ** +concrete ExtraChi of ExtraChiAbs = CatChi ** open ResChi, Coordination, (S = StructuralChi), Prelude in { flags coding = utf8 ; - lincat + lincat VPS = {s : Str} ; [VPS] = {s1,s2 : Str} ; VPI = {s : Str} ; --- ??? @@ -18,7 +18,7 @@ concrete ExtraChi of ExtraChiAbs = CatChi ** BaseVPS = twoSS ; ConsVPS = consrSS duncomma ; - PredVPS np vps = {s = np.s ++ vps.s} ; + PredVPS np vps = {preJiu = np.s ; postJiu = vps.s} ; MkVPI vp = {s = (mkClause [] vp).s ! Pos ! APlain} ; --- ?? almost just a copy of VPS ConjVPI c = conjunctDistrSS (c.s ! CSent) ; @@ -37,19 +37,20 @@ concrete ExtraChi of ExtraChiAbs = CatChi ** Aspect = {s : Str ; a : ResChi.Aspect} ; lin CompBareAP ap = case ap.hasAdA of { - True => insertObj (mkNP ap.s) (predV nocopula []) ; - False => insertObj (mkNP ap.s) (predV hen_copula []) - } ; + True => insertObj (mkNP (ap.s!Pred)) (predV nocopula []) ; + False => insertObj (mkNP (ap.s!Pred)) (predV hen_copula []) + } ; QuestRepV cl = { s = \\_,p,a => ---- also for indirect questions? let - v = cl.vp.verb ; + v = cl.vp.verb ; verb = case a of { - APlain => v.s ++ v.neg ++ v.sn ; + APlain => v.s ++ v.neg ++ v.sn ; APerf => v.s ++ "不" ++ v.sn ++ v.pp ; ADurStat => v.s ++ "不" ++ v.sn ; ADurProg => v.s ++ v.neg ++ v.dp ++ v.sn ; -- mei or bu - AExper => v.s ++ v.neg ++ v.sn ++ v.ep + AExper => v.s ++ v.neg ++ v.sn ++ v.ep ; + AFut => jiu_s ++ v.s ++ v.neg ++ v.sn ++ v.ep -- TODO check placement of jiang } in cl.np ++ cl.vp.prePart ++ verb ++ cl.vp.compl @@ -57,4 +58,4 @@ concrete ExtraChi of ExtraChiAbs = CatChi ** TopicAdvVP vp adv = insertTopic adv vp ; -} +} diff --git a/src/chinese/IdiomChi.gf b/src/chinese/IdiomChi.gf index 9a9d4d107..6b803ac79 100644 --- a/src/chinese/IdiomChi.gf +++ b/src/chinese/IdiomChi.gf @@ -12,7 +12,7 @@ concrete IdiomChi of Idiom = CatChi ** open Prelude, ResChi in { ---- it is John who did it CleftNP np rs = mkClause rs.s copula np.s ; -- did it + de + is I - CleftAdv ad s = mkClause (s.s ++ possessive_s) copula ad.s ; -- she sleeps + de + is here + CleftAdv ad s = mkClause (linS s ++ possessive_s) copula ad.s ; -- she sleeps + de + is here ExistNP np = mkClause [] (regVerb you_s) np.s ; ---- infl of you diff --git a/src/chinese/LexiconChi.gf b/src/chinese/LexiconChi.gf index 1296b2af7..3468e7e90 100644 --- a/src/chinese/LexiconChi.gf +++ b/src/chinese/LexiconChi.gf @@ -1,7 +1,7 @@ -concrete LexiconChi of Lexicon = CatChi ** +concrete LexiconChi of Lexicon = CatChi ** open ParadigmsChi, ResChi, Prelude in { -flags +flags coding = utf8 ; lin @@ -14,13 +14,13 @@ lin tree_N = mkN "树" "棵"; -- "shu" "ke" big_A = mkA "大" ; -- "da" small_A = mkA "小" ; -- "xiao" - green_A = mkA "绿" ; -- "lv" + green_A = colourA "绿" ; -- "lv" walk_V = mkV "走" ; -- "zou" sleep_V = mkV "睡觉" ; -- "shui" love_V2 = mkV2 "爱" ; -- "ai" watch_V2 = mkV2 "看" ; -- "kan" know_VS = mkV "知道" ; -- "zhidao" - wonder_VQ = mkV "好奇" ; -- "haoqi" + wonder_VQ = mkV "好奇" ; -- "haoqi" john_PN = mkPN "约翰" ; -- "yuehan" @@ -63,7 +63,7 @@ horn_N = mkN "角" "根"; tail_N = mkN "尾巴" "条"; -- [mark] "尾" -> "尾巴" , "尾" is often treated as morpheme, or if stands alone, it is a classifier itself feather_N = mkN "羽毛" "根"; hair_N = mkN "头发" "根"; -- [mark] several classifiers , "根"(single hair), "把"(several hairs) -head_N = mkN "头" "颗"; +head_N = mkN "头" "颗"; ear_N = mkN "耳朵" "只"; eye_N = mkN "眼睛" "只"; nose_N = mkN "鼻子" ; @@ -79,7 +79,7 @@ wing_N = mkN "翅膀" "只"; -- [mark] "翼" -> "翅膀", "翅膀" is the common belly_N = mkN "肚子" ; guts_N = mkN "肠子" "根"; neck_N = mkN "脖子" ; -back_N = mkN "背" ; +back_N = mkN "背" ; breast_N = mkN "胸" ; heart_N = mkN "心脏" "颗"; liver_N = mkN "肝" ; @@ -101,7 +101,7 @@ live_V = mkV "活" ; die_V = mkV "死" ; kill_V2 = mkV2 "杀" ; fight_V2 = mkV2 "打架" ; -- [mark] "吵架" -> "打架", "吵架" = quarrel, argue -hunt_V2 = mkV2 "打猎" ; -- [mark] "打猎" is iv, can't think of proper translation in v2 form for hunt +hunt_V2 = mkV2 "打猎" ; -- [mark] "打猎" is iv, can't think of proper translation in v2 form for hunt hit_V2 = mkV2 "打" ; cut_V2 = mkV2 "割" ; split_V2 = mkV2 "劈开" ; @@ -159,10 +159,10 @@ ashes_N = mkN "灰" []; burn_V = mkV "烧" ; road_N = mkN "路" "条"; mountain_N = mkN "山" "座"; -red_A = mkA "红" ; -yellow_A = mkA "黄" ; -white_A = mkA "白" ; -black_A = mkA "黑" ; +red_A = colourA "红" ; +yellow_A = colourA "黄" ; +white_A = colourA "白" ; +black_A = colourA "黑" ; night_N = mkN "夜晚" ; -- [mark] "夜晚" 's classifier is "个" day_N = mkN "白天" []; -- [mark] "白天" -> "天", "天" itself is classifier year_N = mkN "年" [] ; -- [mark] "年" itself is classifier @@ -343,7 +343,7 @@ shirt_N = mkN "衬衫" "件" ; silver_N = mkN "银子" "块"; -- [mark] "银" --> "银子" sister_N = mkN "妹妹" ; sock_N = mkN "袜子" "只"; -steel_N = mkN "钢" "块"; +steel_N = mkN "钢" "块"; stove_N = mkN "炉子" ; village_N = mkN "村庄" "座"; war_N = mkN "战争" "场" ; -- [mark] rewritten @@ -353,29 +353,27 @@ wood_N = mkN "木头" "块" ; -- [mark] "木" --> "木头" -- from scratch, by Jolene lin - alas_Interj = ssword "唉" ; + alas_Interj = ssword "唉" ; beg_V2V = mkV2V (mkV "乞求") ; -- beg him to do something - break_V2 = mkV2 "打破" ; - broad_A = mkA "宽" ; - brown_A = mkA "棕" ; - clever_A = mkA "聪明" ; - close_V2 = mkV2 "关闭" ; - easy_A2V = mkA2 "简单" ; - empty_A = mkA "空" ; - fun_AV = mkA "有趣" ; - hate_V2 = mkV2 "讨厌" ; - married_A2 = mkA2 "结婚" ; - paris_PN = mkPN "巴黎" ; - probable_AS = mkA "可能" ; + break_V2 = mkV2 "打破" ; + broad_A = mkA "宽" ; + brown_A = colourA "棕" ; + clever_A = mkA "聪明" ; + close_V2 = mkV2 "关闭" ; + easy_A2V = mkA2 "简单" ; + empty_A = mkA "空" ; + fun_AV = mkA "有趣" ; + hate_V2 = mkV2 "讨厌" ; + married_A2 = mkA2 "结婚" ; + paris_PN = mkPN "巴黎" ; + probable_AS = mkA "可能" ; ready_A = mkA "准备好" ; -- [mark] "准备好": 准备(v) + 好(adj,complement) - seek_V2 = mkV2 "寻求" ; - stop_V = mkV "停止" ; - stupid_A = mkA "笨" ; - switch8off_V2 = mkV2 "关" ; - switch8on_V2 = mkV2 "开" ; - ugly_A = mkA "丑" ; + seek_V2 = mkV2 "寻求" ; + stop_V = mkV "停止" ; + stupid_A = mkA "笨" ; + switch8off_V2 = mkV2 "关" ; + switch8on_V2 = mkV2 "开" ; + ugly_A = mkA "丑" ; uncertain_A = mkA "不确定" ; -- [mark] "不确定": 不("un-") + 确定("certain") - - -} +} \ No newline at end of file diff --git a/src/chinese/NounChi.gf b/src/chinese/NounChi.gf index 4a4a330b4..a9a180761 100644 --- a/src/chinese/NounChi.gf +++ b/src/chinese/NounChi.gf @@ -12,6 +12,7 @@ concrete NounChi of Noun = CatChi ** open ResChi, Prelude in { DetNP det = {s = case det.detType of { DTFull Pl => det.s ++ xie_s ; + DTPoss => det.s ; _ => det.s ++ ge_s } ; } ; ---- @@ -28,7 +29,7 @@ concrete NounChi of Noun = CatChi ** open ResChi, Prelude in { NTFull => quant.pl ++ num.s ; -- to avoid yi in indef NTVoid Pl => quant.pl ++ num.s ; _ => quant.s ++ num.s - } ; + } ; detType = case num.numType of { NTFull => DTNum ; -- five NTVoid n => case quant.detType of { @@ -63,8 +64,8 @@ concrete NounChi of Noun = CatChi ** open ResChi, Prelude in { AdNum adn num = {s = adn.s ++ num.s ; hasC = True} ; - OrdSuperl a = {s = superlative_s ++ a.s} ; - OrdNumeralSuperl n a = {s = ordinal_s ++ n.s ++ superlative_s ++ a.s} ; ---- to check AR 24/8/2014 + OrdSuperl a = {s = superlative_s ++ a.s ! Attr} ; + OrdNumeralSuperl n a = {s = ordinal_s ++ n.s ++ superlative_s ++ a.s ! Attr} ; ---- to check AR 24/8/2014 DefArt = mkQuant [] [] DTPoss ; -- use that_Quant if you want the_s IndefArt = mkQuant yi_s [] DTNum ; -- (DTFull Sg) ; -- empty in the plural @@ -80,8 +81,8 @@ concrete NounChi of Noun = CatChi ** open ResChi, Prelude in { ComplN3 f x = {s = appPrep f.c2 x.s ++ f.s ; c = f.c ; c2 = f.c3} ; AdjCN ap cn = case ap.monoSyl of { - True => {s = ap.s ++ cn.s ; c = cn.c} ; - False => {s = ap.s ++ possessive_s ++ cn.s ; c = cn.c} + True => {s = ap.s ! Attr ++ cn.s ; c = cn.c} ; + False => {s = ap.s ! Attr ++ possessive_s ++ cn.s ; c = cn.c} } ; RelCN cn rs = {s = rs.s ++ cn.s ; c = cn.c} ; diff --git a/src/chinese/ParadigmsChi.gf b/src/chinese/ParadigmsChi.gf index 6ec08c2f4..eec89b92e 100644 --- a/src/chinese/ParadigmsChi.gf +++ b/src/chinese/ParadigmsChi.gf @@ -5,11 +5,11 @@ flags coding = utf8 ; flags coding=utf8; oper mkN = overload { - mkN : (man : Str) -> N - = \n -> lin N (regNoun n ge_s) ; - mkN : (man : Str) -> Str -> N + mkN : (man : Str) -> N + = \n -> lin N (regNoun n ge_s) ; + mkN : (man : Str) -> Str -> N = \n,c -> lin N (regNoun n c) - } ; + } ; mkN2 = overload { mkN2 : Str -> N2 @@ -21,7 +21,7 @@ oper mkN3 : N -> Prep -> Prep -> N3 = \n,p,q -> lin N3 (n ** {c2 = p ; c3 = q}) ; - + mkPN : (john : Str) -> PN = \s -> lin PN {s = word s} ; -- normal name, in Chinese characters @@ -29,11 +29,14 @@ oper = \s -> lin PN {s = s} ; -- foreign name, in Latin or other non-Chinese characters mkA = overload { - mkA : (small : Str) -> A + mkA : (small : Str) -> A = \a -> lin A (simpleAdj a) ; - mkA : (small : Str) -> Bool -> A + mkA : (small : Str) -> Bool -> A = \a,b -> lin A (mkAdj a b) ; - } ; + } ; + + colourA : Str -> A ; -- colour Adjectives have a "色" when used as predicative + colourA colour = lin A (colourAdj colour); mkA2 = overload { mkA2 : Str -> A2 @@ -43,32 +46,32 @@ oper mkA2 : A -> Prep -> A2 = \a,p -> lin A2 (a ** {c2 = p}) ; } ; - - mkV = overload { - mkV : (walk : Str) -> V + + mkV = overload { + mkV : (walk : Str) -> V = \walk -> case walk of { v + "+" + p => lin V (regVerb (v + p)) ; _ => lin V (regVerb walk) } ; - mkV : (walk,out : Str) -> V + mkV : (walk,out : Str) -> V = \v,p -> lin V (regVerb (v + p)) ; ---- mkV : (arrive : Str) -> Str -> Str -> Str -> Str -> V = \arrive,pp,ds,dp,ep -> lin V (mkVerb arrive pp ds dp ep neg_s) ; mkV : (arrive : Str) -> Str -> Str -> Str -> Str -> Str -> V = \arrive,pp,ds,dp,ep,neg -> lin V (mkVerb arrive pp ds dp ep neg) ; - } ; + } ; mkV2 = overload { - mkV2 : Str -> V2 + mkV2 : Str -> V2 = \s -> case s of { v + "+" + p => lin V2 (regVerb v ** {c2 = emptyPrep ; hasPrep = False ; part = word p}) ; - v + "*" + p => lin V2 (regVerb v ** + v + "*" + p => lin V2 (regVerb v ** {c2 = ResChi.mkPreposition p [] (getAdvType p) ; hasPrep = True ; part = []}) ; _ => lin V2 (regVerb s ** {c2 = emptyPrep ; hasPrep = False ; part = []}) } ; - mkV2 : V -> V2 + mkV2 : V -> V2 = \v -> lin V2 (v ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; - mkV2 : V -> Prep -> V2 + mkV2 : V -> Prep -> V2 = \v,p -> lin V2 (v ** {c2 = p ; hasPrep = True ; part = []}) ; } ; @@ -110,47 +113,47 @@ oper mkV2Q = overload { mkV2Q : V -> V2Q = - \v -> lin V2Q (v ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; + \v -> lin V2Q (v ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; mkV2Q : Str -> V2Q = - \v -> lin V2Q (regVerb v ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; + \v -> lin V2Q (regVerb v ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; } ; mkV2V= overload { - mkV2V : Str -> V2V = - \s -> lin V2V (regVerb s ** {c2 = emptyPrep ; c3 = emptyPrep ; hasPrep = False ; part = []}) ; + mkV2V : Str -> V2V = + \s -> lin V2V (regVerb s ** {c2 = emptyPrep ; c3 = emptyPrep ; hasPrep = False ; part = []}) ; mkV2V : V -> V2V = - \v -> lin V2V (v ** {c2 = emptyPrep ; c3 = emptyPrep ; hasPrep = False ; part = []}) ; + \v -> lin V2V (v ** {c2 = emptyPrep ; c3 = emptyPrep ; hasPrep = False ; part = []}) ; ---- mkV2V : V -> Str -> Str -> V2V = ----- \v,p,q -> lin V2V (v ** {c2 = mkPrep p ; c3 = mkPrep q}) ; +---- \v,p,q -> lin V2V (v ** {c2 = mkPrep p ; c3 = mkPrep q}) ; } ; mkV2S = overload { mkV2S : Str -> V2S = - \s -> lin V2S (regVerb s ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; + \s -> lin V2S (regVerb s ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; mkV2S : V -> V2S = - \v -> lin V2S (v ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; + \v -> lin V2S (v ** {c2 = emptyPrep ; hasPrep = False ; part = []}) ; ---- mkV2S : V -> Str -> V2S = ----- \v,p -> lin V2S (v ** {c2 = mkPrep p}) ; +---- \v,p -> lin V2S (v ** {c2 = mkPrep p}) ; } ; mkV2A = overload { mkV2A : Str -> V2A - = \s -> lin V2A (regVerb s ** {c2 = emptyPrep ; c3 = emptyPrep ; hasPrep = False ; part = []}) ; + = \s -> lin V2A (regVerb s ** {c2 = emptyPrep ; c3 = emptyPrep ; hasPrep = False ; part = []}) ; mkV2A : V -> V2A - = \v -> lin V2A (v ** {c2 = emptyPrep ; c3 = emptyPrep ; hasPrep = False ; part = []}) ; + = \v -> lin V2A (v ** {c2 = emptyPrep ; c3 = emptyPrep ; hasPrep = False ; part = []}) ; } ; ---- mkV2A : V -> Str -> Str -> V2A ----- = \v,p,q -> lin V2A (v ** {c2 = mkPrep p ; c3 = mkPrep q}) ; +---- = \v,p,q -> lin V2A (v ** {c2 = mkPrep p ; c3 = mkPrep q}) ; mkAdv = overload { - mkAdv : Str -> Adv + mkAdv : Str -> Adv = \s -> let at = getAdvType s in lin Adv {s = word s ; advType = at ; hasDe = advTypeHasDe at} ; - mkAdv : Str -> Str -> Adv + mkAdv : Str -> Str -> Adv = \s,t -> let at = getAdvType s in lin Adv {s = word (s + t) ; advType = at ; hasDe = advTypeHasDe at} ; ---- - mkAdv : Str -> AdvType -> Adv + mkAdv : Str -> AdvType -> Adv = \s,at -> lin Adv {s = word s ; advType = at ; hasDe = advTypeHasDe at} ; - mkAdv : Adv -> AdvType -> Adv -- To fix the AdvType in an Adv produced by SyntaxChi.mkAdv + mkAdv : Adv -> AdvType -> Adv -- To fix the AdvType in an Adv produced by SyntaxChi.mkAdv = \adv,at -> adv ** {advType = at ; hasDe = advTypeHasDe at} ; } ; @@ -165,50 +168,50 @@ oper = ATTime ; mannerAdvType : AdvType = ATManner ; - + mkPrep = overload { -- first pre part, then optional post part - mkPrep : Str -> Prep + mkPrep : Str -> Prep = \s -> lin Prep (ResChi.mkPreposition s [] (getAdvType s)) ; - mkPrep : Str -> Str -> Prep + mkPrep : Str -> Str -> Prep = \s,t -> lin Prep (ResChi.mkPreposition s t (getAdvType s)) ; - mkPrep : Str -> Str -> AdvType -> Prep + mkPrep : Str -> Str -> AdvType -> Prep = \s,t,a -> lin Prep (ResChi.mkPreposition s t a) ; } ; - mkInterj : Str -> Interj + mkInterj : Str -> Interj = \s -> lin Interj {s = word s} ; emptyPrep : Preposition = mkPrep [] ; - mkpNP : Str -> CatChi.NP + mkpNP : Str -> CatChi.NP = \s -> lin NP {s = word s} ; - mkAdV : Str -> AdV + mkAdV : Str -> AdV = \s -> lin AdV {s = word s} ; - mkAdN : Str -> AdN + mkAdN : Str -> AdN = \s -> lin AdN {s = word s} ; - mkSubj : Str -> Subj + mkSubj : Str -> Subj = \s -> lin Subj (ResChi.mkSubj s []) ; mkConj = overload { - mkConj : Str -> Conj - = \s -> lin Conj {s = \\_ => mkConjForm s} ; - mkConj : (both,and : Str) -> Conj - = \s,t -> lin Conj {s = \\_ => mkConjForm2 s t} ; + mkConj : Str -> Conj + = \s -> lin Conj {s = \\_ => mkConjForm s ; conjType = NotJiu} ; + mkConj : (both,and : Str) -> Conj + = \s,t -> lin Conj {s = \\_ => mkConjForm2 s t ; conjType = NotJiu} ; } ; - mkpDet : Str -> Det + mkpDet : Str -> Det = \s -> lin Det {s = word s ; detType = DTFull Sg} ; - mkQuant : Str -> Quant + mkQuant : Str -> Quant = \s -> lin Quant {s,pl = word s ; detType = DTFull Sg} ; - mkAdA : Str -> AdA + mkAdA : Str -> AdA = \s -> lin AdA {s = word s} ; - mkNum : Str -> Num + mkNum : Str -> Num = \s -> lin Num {s = word s ; numType = NTFull} ; - mkPredet : Str -> Predet + mkPredet : Str -> Predet = \s -> lin Predet {s = word s} ; - mkIDet : Str -> IDet + mkIDet : Str -> IDet = \s -> lin IDet {s = word s ; detType = DTNum} ; ---- - mkPConj : Str -> PConj + mkPConj : Str -> PConj = \s -> lin PConj {s = word s} ; - mkRP : Str -> RP + mkRP : Str -> RP = \s -> lin RP {s = table {True => [] ; False => word s}} ; diff --git a/src/chinese/PhraseChi.gf b/src/chinese/PhraseChi.gf index 51b3787d1..4f1813421 100644 --- a/src/chinese/PhraseChi.gf +++ b/src/chinese/PhraseChi.gf @@ -3,7 +3,7 @@ concrete PhraseChi of Phrase = CatChi ** open Prelude, ResChi in { lin PhrUtt pconj utt voc = {s = pconj.s ++ voc.s ++ utt.s} ; - UttS s = s ; + UttS s = ss (linS s) ; UttQS qs = ss (qs.s ! True) ; UttImpSg pol imp = {s = pol.s ++ imp.s ! pol.p} ; UttImpPl pol imp = {s = pol.s ++ imp.s ! pol.p} ; @@ -13,7 +13,7 @@ concrete PhraseChi of Phrase = CatChi ** open Prelude, ResChi in { UttIAdv iadv = iadv ; UttNP np = np ; UttCN cn = cn ; - UttAP ap = ap ; + UttAP ap = {s = ap.s!Attr} ; UttCard x = x ; UttVP vp = ss (infVP vp) ; UttAdv adv = adv ; diff --git a/src/chinese/QuestionChi.gf b/src/chinese/QuestionChi.gf index 7dac73416..d190869d9 100644 --- a/src/chinese/QuestionChi.gf +++ b/src/chinese/QuestionChi.gf @@ -1,4 +1,4 @@ -concrete QuestionChi of Question = CatChi ** +concrete QuestionChi of Question = CatChi ** open ResChi, Prelude in { flags optimize=all_subs ; @@ -7,29 +7,15 @@ concrete QuestionChi of Question = CatChi ** lin QuestCl cl = { - s = table { - True => \\p,a => cl.s ! p ! a ++ question_s ; -- redup question as variant in ExtraChi - False => \\p,a => --- code copied from ExtraChi - let - v = cl.vp.verb ; - verb = case a of { - APlain => v.s ++ v.neg ++ v.sn ; - APerf => v.s ++ neg_s ++ v.sn ++ v.pp ; - ADurStat => v.s ++ neg_s ++ v.sn ; - ADurProg => v.s ++ v.neg ++ v.dp ++ v.sn ; -- mei or bu - AExper => v.s ++ v.neg ++ v.sn ++ v.ep - } - in - cl.np ++ cl.vp.prePart ++ verb ++ cl.vp.compl - } + s = \\b,p,a => cl.s ! p ! a ++ question_s ; -- redup question as variant in ExtraChi } ; QuestVP ip vp = { s = \\_,p,a => ip.s ++ vp.prePart ++ useVerb vp.verb ! p ! a ++ vp.compl } ; - - QuestSlash ip cls = {s = \\_ => (mkClauseCompl cls.np (insertObj (ss (appPrep cls.c2 ip.s)) cls.vp) []).s} ; - + + QuestSlash ip cls = {s = \\_ => (mkClauseCompl cls.np (insertObj (ss (appPrep cls.c2 ip.s)) cls.vp) []).s} ; + QuestIAdv iadv cl = {s = \\_ => (mkClauseCompl cl.np (insertAdv iadv cl.vp) []).s} ; QuestIComp icomp np = {s = \\_,p,a => np.s ++ icomp.s} ; ---- order @@ -49,13 +35,13 @@ concrete QuestionChi of Question = CatChi ** IdetIP idet = idet ; IdetQuant iquant num = { - s = iquant.s ++ num.s ; + s = iquant.s ++ num.s ; detType = case num.numType of { NTFull => DTNum ; -- which five NTVoid n => DTFull n ---- TODO: whose } } ; - + AdvIAdv i a = ss (a.s ++ i.s) ; diff --git a/src/chinese/ResChi.gf b/src/chinese/ResChi.gf index e30a87941..9ed6c7a50 100644 --- a/src/chinese/ResChi.gf +++ b/src/chinese/ResChi.gf @@ -42,6 +42,8 @@ resource ResChi = ParamX ** open Prelude in { geng_s = "更" ; -- more, in comparison hen_s = "很" ; -- very, or predicating a monosyllabic adjective taN_s = "它" ; + jiu_s = "就" ; + hui_s = "会" ; zai_V = mkVerb "在" [] [] [] [] "不" ; fullstop_s = "。" ; @@ -67,9 +69,9 @@ resource ResChi = ParamX ** open Prelude in { bword : Str -> Str -> Str = \x,y -> x ++ y ; -- change to x + y to treat words as single tokens word : Str -> Str = \s -> case s of { - x@? + y@? + z@? + u@? + v@? + w@? + a@? + b@? + c@? + d@? + e@? => + x@? + y@? + z@? + u@? + v@? + w@? + a@? + b@? + c@? + d@? + e@? => bword x (bword y (bword z (bword u (bword v (bword w (bword a (bword b (bword c (bword d e))))))))) ; - x@? + y@? + z@? + u@? + v@? + w@? + a@? + b@? + c@? + d@? => + x@? + y@? + z@? + u@? + v@? + w@? + a@? + b@? + c@? + d@? => bword x (bword y (bword z (bword u (bword v (bword w (bword a (bword b (bword c d)))))))) ; x@? + y@? + z@? + u@? + v@? + w@? + a@? + b@? + c@? => bword x (bword y (bword z (bword u (bword v (bword w (bword a (bword b c))))))) ; x@? + y@? + z@? + u@? + v@? + w@? + a@? + b@? => bword x (bword y (bword z (bword u (bword v (bword w (bword a b)))))) ; @@ -89,144 +91,173 @@ resource ResChi = ParamX ** open Prelude in { -- parameters param - Aspect = APlain | APerf | ADurStat | ADurProg | AExper ; ---- APlain added by AR + Aspect = APlain | APerf | ADurStat | ADurProg | AExper | AFut ; ---- APlain added by AR ConjForm = CPhr CPosType | CSent; + ConjType = Jiu | NotJiu ; -- to put conjunction in the right place in ConjS: "I sleep *and* she walks" vs. "if I sleep, she *then* walks" CPosType = CAPhrase | CNPhrase | CVPhrase ; DeForm = DeNoun | NdNoun ; -- parameter created for noun with/out partical "de" AdvType = ATPlace Bool | ATTime | ATManner | ATPoss ; -- ATPlace True = has zai_s already --- parts of speech + AdjPlace = Attr | Pred ; -- a green cat / the cat is green colour +-- parts of speech oper VP = { topic : Str ; -- topicalized item, before subject prePart : Str ; -- between subject and verb - verb : Verb ; + verb : Verb ; compl : Str ; -- after verb - isAdj : Bool ; -- whether it is an adjectival predication and behaves differently in relative + isAdj : Bool ; -- whether it is an adjectival predication and behaves differently in relative } ; - NP = {s : Str} ; + NP = {s : Str} ; -- for morphology Noun : Type = {s : Str ; c : Str} ; - Adj : Type = {s : Str ; monoSyl: Bool} ; + Adj : Type = {s : AdjPlace => Str ; monoSyl: Bool} ; Verb : Type = {s,sn : Str ; pp,ds,dp,ep : Str ; neg : Str} ; --- sn=[] needed for "hen" as copula regNoun : Str -> Str -> Noun = \s,c -> {s = word s ; c = word c}; - mkAdj : Str -> Bool -> Adj = \s,b -> {s = word s ; monoSyl = b}; + mkAdj : Str -> Bool -> Adj = \s,b -> {s = + table { + _ => word s + }; + monoSyl = b}; - complexAP : Str -> Adj ** {hasAdA : Bool} = - \s -> {s = s ; monoSyl = False ; hasAdA = False} ; --- not used for adding AdA + complexAP : Str -> Adj ** {hasAdA : Bool} = + \s -> mkAdj s False ** {hasAdA = False} ; --- not used for adding AdA simpleAdj : Str -> Adj = \s -> case s of { ? => mkAdj s True ; -- monosyllabic _ => mkAdj s False } ; - copula : Verb = mkVerb "是" [] [] [] [] "不" ; - hen_copula : Verb = - {s = hen_s ; sn = [] ; pp = [] ; ds = [] ; dp = [] ; ep = [] ; neg = "不"} ; --- - nocopula : Verb = - {s = [] ; sn = [] ; pp = [] ; ds = [] ; dp = [] ; ep = [] ; neg = "不"} ; --- - adjcopula : Verb = - {s = "是" ; sn = [] ; pp = [] ; ds = [] ; dp = [] ; ep = [] ; neg = "不"} ; --- + colourAdj : Str -> Adj = \s -> { + s = table { + Attr => word s ; + Pred => word s ++ "色" + }; + monoSyl = case s of { + ? => True ; + _ => False } + }; - regVerb : (walk : Str) -> Verb = \v -> + copula : Verb = mkVerb "是" [] [] [] [] "不" ; + hen_copula : Verb = + {s = hen_s ; sn = [] ; pp = [] ; ds = [] ; dp = [] ; ep = [] ; neg = "不"} ; --- + nocopula : Verb = + {s = [] ; sn = [] ; pp = [] ; ds = [] ; dp = [] ; ep = [] ; neg = "不"} ; --- + adjcopula : Verb = + {s = "是" ; sn = [] ; pp = [] ; ds = [] ; dp = [] ; ep = [] ; neg = "不"} ; --- + + regVerb : (walk : Str) -> Verb = \v -> mkVerb v "了" "着" "在" "过" "不" ; -- 没" ; noVerb : Verb = regVerb [] ; ---?? -- used as copula for verbal adverbs - mkVerb : (v : Str) -> (pp,ds,dp,ep,neg : Str) -> Verb = \v,pp,ds,dp,ep,neg -> + mkVerb : (v : Str) -> (pp,ds,dp,ep,neg : Str) -> Verb = \v,pp,ds,dp,ep,neg -> {s,sn = word v ; pp = pp ; ds = ds ; dp = dp ; ep = ep ; neg = neg} ; - useVerb : Verb -> Polarity => Aspect => Str = \v -> + useVerb : Verb -> Polarity => Aspect => Str = \v -> table { Pos => table { APlain => v.s ; APerf => v.s ++ v.pp ; ADurStat => v.s ++ v.ds ; ADurProg => v.dp ++ v.s ; - AExper => v.s ++ v.ep + AExper => v.s ++ v.ep ; + AFut => hui_s ++ v.s } ; Neg => table { APlain => v.neg ++ v.sn ; --- neg? APerf => "不" ++ v.sn ++ v.pp ; ADurStat => "不" ++ v.sn ; ADurProg => v.neg ++ v.dp ++ v.sn ; -- mei or bu - AExper => v.neg ++ v.sn ++ v.ep + AExper => v.neg ++ v.sn ++ v.ep ; + AFut => "不" ++ hui_s ++ v.s } } ; - infVP : VP -> Str = \vp -> vp.topic ++ vp.prePart ++ vp.verb.s ++ vp.compl ; + infVP : VP -> Str = \vp -> vp.topic ++ vp.prePart ++ vp.verb.s ++ vp.compl ; predV : Verb -> Str -> VP = \v,part -> { - verb = v ; + verb = v ; compl = part ; prePart, topic = [] ; isAdj = False ; - } ; + } ; insertObj : NP -> VP -> VP = \np,vp -> vp ** { compl = np.s ++ vp.compl ; - } ; + } ; insertObjPost : NP -> VP -> VP = \np,vp -> vp ** { compl = vp.compl ++ np.s ; - } ; + } ; insertAdv : SS -> VP -> VP = \adv,vp -> vp ** { prePart = adv.s ++ vp.prePart ; - } ; + } ; insertTopic : SS -> VP -> VP = \adv,vp -> vp ** { topic = adv.s ++ vp.topic - } ; + } ; insertAdvPost : SS -> VP -> VP = \adv,vp -> vp ** { prePart = vp.prePart ++ adv.s ; - } ; + } ; insertPP : SS -> VP -> VP = \pp,vp -> vp ** { prePart = vp.prePart ++ pp.s ; - } ; + } ; insertExtra : SS -> VP -> VP = \ext,vp -> insertObjPost ext vp ; -- clauses: keep np and vp separate to enable insertion of IAdv - Clause : Type = { - s : Polarity => Aspect => Str ; - np : Str; - vp : VP - } ; + Clause : Type = { + s : Polarity => Aspect => Str ; + np : Str ; + vp : VP ; + postJiu : Polarity => Aspect => Str ; + } ; + + Sentence : Type = { + preJiu, -- everything until the subject + postJiu -- everything after the subject + : Str + } ; + + linS : Sentence -> Str = \s -> s.preJiu ++ s.postJiu ; + simpleS : Str -> Sentence = \s -> {preJiu=s ; postJiu=[]} ; mkClause = overload { - mkClause : Str -> Verb -> Clause = \np,v -> + mkClause : Str -> Verb -> Clause = \np,v -> mkClauseCompl np (predV v []) [] ; mkClause : Str -> Verb -> Str -> Clause = \subj,verb,obj -> mkClauseCompl subj (predV verb []) obj ; - mkClause : Str -> VP -> Clause = \np,vp -> + mkClause : Str -> VP -> Clause = \np,vp -> mkClauseCompl np vp [] ; - mkClause : Str -> VP -> Str -> Clause = + mkClause : Str -> VP -> Str -> Clause = mkClauseCompl ; } ; - + mkClauseCompl : Str -> VP -> Str -> Clause = \np,vp,compl -> { s = \\p,a => vp.topic ++ np ++ vp.prePart ++ useVerb vp.verb ! p ! a ++ vp.compl ++ compl ; np = vp.topic ++ np ; vp = insertObj (ss compl) vp ; + postJiu = \\p,a => vp.prePart ++ useVerb vp.verb ! p ! a ++ vp.compl ++ compl ; } ; - + -- for structural words -param +param DetType = DTFull Number | DTNum | DTPoss ; -- this, these, five, our NumType = NTFull | NTVoid Number ; -- five, sg, pl @@ -250,8 +281,8 @@ oper s = word s } ; - Preposition = {prepPre : Str ; prepPost : Str ; advType : AdvType ; hasDe : Bool} ; - + Preposition = {prepPre : Str ; prepPost : Str ; advType : AdvType ; hasDe : Bool} ; + mkPreposition : Str -> Str -> AdvType -> Preposition = \s1,s2,at -> { prepPre = word s1 ; prepPost = word s2 ; @@ -262,8 +293,8 @@ oper advTypeHasDe : AdvType -> Bool = \at -> case at of { ATPoss => True ; _ => False - } ; - + } ; + getAdvType : Str -> AdvType = \s -> case s of { "的" => ATPoss ; "在" + _ => ATPlace True ; -- certain that True @@ -271,7 +302,7 @@ oper } ; possessiveIf : Bool -> Str = \hasDe -> case hasDe of { - True => [] ; --- to avoid double "de" + True => [] ; --- to avoid double "de" _ => possessive_s } ; @@ -285,7 +316,7 @@ oper mkNP : Str -> NP = ss ; -- not to be used in lexicon building - appPrep : Preposition -> Str -> Str = \prep,s -> + appPrep : Preposition -> Str -> Str = \prep,s -> prep.prepPre ++ s ++ prep.prepPost ; } diff --git a/src/chinese/SentenceChi.gf b/src/chinese/SentenceChi.gf index 65d8ae4d3..9e9e1f38b 100644 --- a/src/chinese/SentenceChi.gf +++ b/src/chinese/SentenceChi.gf @@ -1,4 +1,4 @@ -concrete SentenceChi of Sentence = CatChi ** +concrete SentenceChi of Sentence = CatChi ** open Prelude, ResChi in { flags optimize=all_subs ; @@ -12,39 +12,55 @@ concrete SentenceChi of Sentence = CatChi ** ImpVP vp = { s = table { Pos => infVP vp ; - Neg => neg_s ++ infVP vp + Neg => neg_s ++ infVP vp } } ; - SlashVP np vp = + SlashVP np vp = mkClauseCompl np.s vp [] ** {c2 = vp.c2} ; SlashVS np vs sslash = ** {c2 = sslash.c2} ; - + -- yet another reason for discontinuity of clauses AdvSlash slash adv = slash ** {vp = insertAdv adv slash.vp} ; ---- parser loops with unknown tokens if this version is used AR 20/4/2014 ---- mkClauseCompl slash.np [] ---- ** {c2 = slash.c2} ; - + SlashPrep cl prep = cl ** {c2 = prep} ; - - EmbedS s = ss (conjThat ++ s.s) ; + + EmbedS s = ss (conjThat ++ linS s) ; EmbedQS qs = ss (qs.s ! False) ; EmbedVP vp = ss (infVP vp) ; - UseCl t p cl = {s = t.s ++ p.s ++ cl.s ! p.p ! t.t} ; - UseQCl t p cl = {s = \\isDir => t.s ++ p.s ++ cl.s ! isDir ! p.p ! t.t} ; - UseRCl t p cl = {s = t.s ++ p.s ++ cl.s ! p.p ! t.t} ; + UseCl t p cl = { + preJiu = cl.np ; + postJiu = t.s ++ p.s ++ cl.postJiu ! p.p ! t.t} ; + + UseQCl t p cl = {s = \\isDir => t.s ++ p.s ++ cl.s ! isDir ! p.p ! t.t} ; + UseRCl t p cl = {s = t.s ++ p.s ++ cl.s ! p.p ! t.t} ; UseSlash t p cl = {s = t.s ++ p.s ++ cl.s ! p.p ! t.t ; c2 = cl.c2} ; - AdvS a s = ss (a.s ++ s.s) ; - ExtAdvS a s = ss (a.s ++ chcomma ++ s.s) ; + AdvS a s = s ** { + preJiu = a.s ++ s.preJiu -- tomorrow she + } ; - RelS s r = ss (s.s ++ r.s) ; + ExtAdvS a s = s ** { + preJiu = a.s ++ chcomma ++ s.preJiu -- tomorrow, she + } ; - SSubjS a subj b = ss (a.s ++ subj.prePart ++ b.s ++ subj.sufPart) ; + RelS s r = s ** { + postJiu = s.postJiu ++ r.s ; + } ; + + -- a="she walks", b="I die" + -- result: preJiu="if she walks, I", postJiu="die" + SSubjS a subj b = { + preJiu = linS a ++ subj.prePart -- if she walks, + ++ b.preJiu ; -- I + postJiu = b.postJiu ++ subj.sufPart -- die + } ; } diff --git a/src/chinese/StructuralChi.gf b/src/chinese/StructuralChi.gf index 2fc84c74b..40cf45cf1 100644 --- a/src/chinese/StructuralChi.gf +++ b/src/chinese/StructuralChi.gf @@ -5,7 +5,7 @@ concrete StructuralChi of Structural = CatChi ** lin every_Det = mkDet "每" Sg ; - + this_Quant = mkQuant "这" ; that_Quant = mkQuant "那" ; @@ -25,18 +25,20 @@ lin possess_Prep = mkPrep [] "的" ATPoss ; with_Prep = mkPrep "和" "一起" (ATPlace True) ; -- "with you" ---- with_Prep = mkPrep "和" [] ; -- "with bread" - + and_Conj = {s = table { CPhr CNPhrase => mkConjForm "和" ; CPhr CAPhrase => mkConjForm "而" ; CPhr CVPhrase => mkConjForm "又" ; - CSent => mkConjForm "并且" --modified by chenpneg 11.19 - } + CSent => mkConjForm "而" --modified by chenpneg 11.19 + } ; + conjType = NotJiu ; } ; or_Conj = {s = table { CPhr _ => mkConjForm "或" ; CSent => mkConjForm "还是" - } + } ; + conjType = NotJiu ; } ; although_Subj = mkSubj "虽然" "但"; @@ -52,8 +54,8 @@ when_IAdv = mkIAdvL "什么时候" ; how_IAdv = mkIAdvL "如何" ; all_Predet = ssword "所有" ; many_Det = mkDet (word "很多") DTPoss ; -someSg_Det = mkDet (word "一些") Sg ; -somePl_Det = mkDet (word "一些") Sg ; +someSg_Det = mkDet (word "一些") DTPoss ; +somePl_Det = mkDet (word "一些") DTPoss ; few_Det = mkDet "少" Pl ; other_A = mkA "其他" ; @@ -116,13 +118,14 @@ as_CAdv = {s = word "和" ; p = word "一样" } ; -- modified by chenpeng 11.24 at_least_AdN = ssword "最少" ; -- at least five at_most_AdN = ssword "最多" ; behind_Prep = mkPrep "在" "后面" ; - + both7and_DConj = {s = table { -- modified by chenpeng 11.19 CPhr CNPhrase => mkConjForm2 "包括" "和" ; CPhr CAPhrase => mkConjForm2 "即" "又" ; CPhr CVPhrase => mkConjForm2 "不但" "而且" ; CSent => mkConjForm2 "不但" "而且" - } + } ; + conjType = NotJiu ; } ; by8agent_Prep = mkPrep "被" [] mannerAdvType; -- by for agent in passive @@ -135,7 +138,8 @@ either7or_DConj = {s = table { -- modified by chenpeng 11.19 CPhr CAPhrase => mkConjForm2 "要么" "要么" ; CPhr CVPhrase => mkConjForm2 "要么" "要么" ; CSent => mkConjForm2 "要么" "要么" - } + } ; + conjType = NotJiu ; } ; everybody_NP = ssword "每个人" ; -- [mark] "每个人": 每(every)+个(classifier)+人(person) @@ -152,11 +156,10 @@ less_CAdv = {s = than_s ; p = word "没更"} ; -- modified by chenpeng 11.24 more_CAdv = {s = than_s ; p = word "更"} ; -- modified by chenpeng 11.24 most_Predet = ssword "大多数" ; if_then_Conj = {s = table { -- added by chenpeng 11.19 - CPhr CNPhrase => mkConjForm [] ; - CPhr CAPhrase => mkConjForm [] ; - CPhr CVPhrase => mkConjForm [] ; - CSent => mkConjForm2 "如果" "那么" - } + CSent => mkConjForm2 "如果" "就" ; -- if she walks, I then sleep + CPhr _ => mkConjForm2 "如果" "那么" -- if fish , then rice + } ; + conjType = Jiu ; } ; nobody_NP = ssword "没人" ; nothing_NP = ssword "没有什么" ; @@ -171,7 +174,7 @@ there7from_Adv = mkAdv "从那里" ; -- from there there7to_Adv = mkAdv "到那里" ; therefore_PConj = ssword "因此" ; through_Prep = mkPrep "通过" ; -which_IQuant = mkIQuant "哪" ; -- +which_IQuant = mkIQuant "哪" ; -- --which_IQuant = ssword [] ; -- [mark] in sent, it depends on the context without_Prep = mkPrep "没有" [] mannerAdvType ; youPol_Pron = ssword "您" ; -- polite you diff --git a/src/chinese/SymbolChi.gf b/src/chinese/SymbolChi.gf index 69457d54c..264e5bee5 100644 --- a/src/chinese/SymbolChi.gf +++ b/src/chinese/SymbolChi.gf @@ -13,17 +13,17 @@ concrete SymbolChi of Symbol = CatChi ** open Prelude, ResChi in { s = cn.s ++ i.s ; c = cn.c } ; - CNSymbNP det cn xs = ss (det.s ++ cn.s ++ xs.s) ; ---- + CNSymbNP det cn xs = ss (det.s ++ cn.s ++ xs.s) ; ---- CNNumNP cn i = { s = cn.s ++ i.s ; c = cn.c } ; - SymbS sy = sy ; + SymbS sy = simpleS sy.s ; SymbNum sy = sy ; SymbOrd sy = sy ; -lincat +lincat Symb, [Symb] = SS ; diff --git a/src/chinese/TenseChi.gf b/src/chinese/TenseChi.gf index f2c196c05..b03702068 100644 --- a/src/chinese/TenseChi.gf +++ b/src/chinese/TenseChi.gf @@ -1,4 +1,4 @@ -concrete TenseChi of Tense = +concrete TenseChi of Tense = CatChi [Tense,Temp,Ant], TenseX [Pol,PNeg,PPos] ** open ResChi in { lin @@ -6,11 +6,11 @@ concrete TenseChi of Tense = ---- ?? TPres = {s = [] ; t = APlain} ; - TPast = {s = [] ; t = APerf} ; - TFut = {s = [] ; t = ADurProg} ; + TPast = {s = [] ; t = APerf} ; + TFut = {s = [] ; t = AFut} ; TCond = {s = [] ; t = ADurStat} ; ASimul = {s = [] ; t = APlain} ; - AAnter = {s = [] ; t = APerf} ; + AAnter = {s = [] ; t = APerf} ; } diff --git a/src/chinese/VerbChi.gf b/src/chinese/VerbChi.gf index 013ee1994..9c0503d4b 100644 --- a/src/chinese/VerbChi.gf +++ b/src/chinese/VerbChi.gf @@ -7,14 +7,14 @@ concrete VerbChi of Verb = CatChi ** open ResChi, Prelude in { SlashV2a v = predV v v.part ** {c2 = v.c2 ; isPre = v.hasPrep} ; - Slash2V3 v np = insertAdv (mkNP (ba_s ++ np.s)) (predV v v.part) ** {c2 = v.c3 ; isPre = v.hasPrep} ; -- slot for third argument + Slash2V3 v np = insertAdv (mkNP (ba_s ++ np.s)) (predV v v.part) ** {c2 = v.c3 ; isPre = v.hasPrep} ; -- slot for third argument Slash3V3 v np = insertObj (mkNP (appPrep v.c3 np.s)) (predV v v.part) ** {c2 = v.c2 ; isPre = True} ; -- slot for ba object - SlashV2A v ap = insertObj ap (predV v v.part) ** {c2 = v.c2 ; isPre = v.hasPrep} ; + SlashV2A v ap = insertObj {s = ap.s ! Pred} (predV v v.part) ** {c2 = v.c2 ; isPre = v.hasPrep} ; SlashV2V v vp = insertObj (mkNP (infVP vp)) (predV v v.part) ** {c2 = v.c2 ; isPre = v.hasPrep} ; - SlashV2S v s = insertObj (ss (say_s ++ s.s)) (predV v v.part) ** {c2 = v.c2 ; isPre = v.hasPrep} ; - SlashV2Q v q = insertObj (ss (say_s ++ q.s ! False)) (predV v v.part) ** {c2 = v.c2 ; isPre = v.hasPrep} ; + SlashV2S v s = insertObj (ss (say_s ++ linS s)) (predV v v.part) ** {c2 = v.c2 ; isPre = v.hasPrep} ; + SlashV2Q v q = insertObj (ss (say_s ++ q.s ! False)) (predV v v.part) ** {c2 = v.c2 ; isPre = v.hasPrep} ; ComplVV v vp = { verb = v ; @@ -23,9 +23,9 @@ concrete VerbChi of Verb = CatChi ** open ResChi, Prelude in { isAdj = False ; } ; - ComplVS v s = insertObj s (predV v []) ; - ComplVQ v q = insertObj (ss (q.s ! False)) (predV v []) ; - ComplVA v ap = insertObj ap (predV v []) ; + ComplVS v s = insertObj (ss (linS s)) (predV v []) ; + ComplVQ v q = insertObj (ss (q.s ! False)) (predV v []) ; + ComplVA v ap = insertObj {s = ap.s ! Pred} (predV v []) ; ComplSlash vp np = case vp.isPre of { --- True => insertAdv (mkNP (ba_s ++ np.s)) vp ; --- ba or vp.c2 ? @@ -39,7 +39,7 @@ concrete VerbChi of Verb = CatChi ** open ResChi, Prelude in { SlashVV v vp = ---- too simple? insertObj (mkNP (infVP vp)) (predV v []) ** {c2 = vp.c2 ; isPre = vp.isPre} ; - SlashV2VNP v np vp = + SlashV2VNP v np vp = insertObj np (insertObj (mkNP (infVP vp)) (predV v v.part)) ** {c2 = vp.c2 ; isPre = vp.isPre} ; @@ -56,19 +56,19 @@ concrete VerbChi of Verb = CatChi ** open ResChi, Prelude in { ATTime | ATPoss => insertTopic adv vp -- *today* he here sleeps } ; - AdVVP adv vp = insertAdv adv vp ; - + AdVVP adv vp = insertAdv adv vp ; + ReflVP vp = insertObj (mkNP reflPron) vp ; PassV2 v = insertAdv (mkNP passive_s) (predV v v.part) ; ---- - CompAP ap = insertObj (mkNP (ap.s ++ de_s)) (predV copula []) ** {isAdj = True} ; + CompAP ap = insertObj (mkNP (ap.s ! Pred ++ de_s)) (predV copula []) ** {isAdj = True} ; {- CompAP ap = case ap.hasAdA of { - True => insertObj (mkNP ap.s) (predV nocopula []) ; + True => insertObj (mkNP ap.s) (predV nocopula []) ; False => insertObj (mkNP (ap.s ++ de_s)) (predV copula []) - } ; + } ; -} CompNP np = insertObj np (predV copula []) ; ---- diff --git a/src/chinese/unittest/adjectives.gftest b/src/chinese/unittest/adjectives.gftest new file mode 100644 index 000000000..4fbfc9a89 --- /dev/null +++ b/src/chinese/unittest/adjectives.gftest @@ -0,0 +1,3 @@ +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant that_Quant NumSg) (AdjCN (PositA green_A) (UseN cat_N))) (UseComp (CompAP (PositA green_A)))) +LangChi: 那 只 绿 猫 是 绿 色 的 +LangEng: that green cat is green \ No newline at end of file diff --git a/src/chinese/unittest/adverbial.gftest b/src/chinese/unittest/adverbial.gftest new file mode 100644 index 000000000..842d9c90c --- /dev/null +++ b/src/chinese/unittest/adverbial.gftest @@ -0,0 +1,12 @@ +-- These are not ideal output. TODO: Add new constructor for semantic contexts to achieve the correct output for "地" vs "得" + +Lang: PredVP (AdvNP (UsePron it_Pron) (PositAdvAdj beautiful_A)) (UseV walk_V) +LangChi: 漂 亮 地 的 它 走 +LangEng: it beautifully walks +-- Correct LangChi: 它 漂 亮 地 走 + + +Lang: PredVP (UsePron it_Pron) (AdvVP (UseV walk_V) (PositAdvAdj beautiful_A)) +LangChi: 它 走 得 漂 亮 地 +LangEng: it walks beautifully +-- Correct LangChi: 它 走 得 漂 亮 diff --git a/src/chinese/unittest/complements.gftest b/src/chinese/unittest/complements.gftest new file mode 100644 index 000000000..3068c2dcb --- /dev/null +++ b/src/chinese/unittest/complements.gftest @@ -0,0 +1,3 @@ +-- One way of saying "he/she gives me a cat" +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron he_Pron) (ComplSlash (Slash2V3 give_V3 (DetCN (DetQuant DefArt NumSg) (UseN cat_N))) (UsePron i_Pron))) +LangChi: 他 把 猫 给 我 \ No newline at end of file diff --git a/src/chinese/unittest/conjunctions.gftest b/src/chinese/unittest/conjunctions.gftest new file mode 100644 index 000000000..024012a0d --- /dev/null +++ b/src/chinese/unittest/conjunctions.gftest @@ -0,0 +1,47 @@ +-- Basic conjunctions, no jiu +Lang: ConjS and_Conj (BaseS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV sleep_V))) (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron she_Pron) (UseV walk_V)))) +LangChi: 我 睡 觉 而 她 走 +LangEng: I sleep and she walks + +Lang: ConjS or_Conj (BaseS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV go_V))) (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron she_Pron) (UseV go_V)))) +LangChi: 我 去 还 是 她 去 +LangEng: I go or she goes + +Lang: ConjS either7or_DConj (BaseS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV go_V))) (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron she_Pron) (UseV go_V)))) +LangChi: 要 么 我 去 要 么 她 去 +LangEng: either I go or she goes + +-- If-then in different tenses +Lang: ConjS if_then_Conj (BaseS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV sleep_V))) (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron she_Pron) (UseV die_V)))) +LangChi: 如 果 我 睡 觉 , 她 就 死 +LangEng: if I sleep then she dies + +Lang: ConjS if_then_Conj (BaseS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV sleep_V))) (UseCl (TTAnt TFut ASimul) PPos (PredVP (UsePron she_Pron) (UseV die_V)))) +LangChi: 如 果 我 睡 觉 , 她 就 会 死 +LangEng: if I sleep then she will die + +-- contrast: if_Subj, not if_then_Conj +Lang: ExtAdvS (SubjS if_Subj (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV sleep_V)))) (UseCl (TTAnt TFut ASimul) PPos (PredVP (UsePron she_Pron) (UseV die_V))) +LangChi: 如 果 我 睡 觉 , 她 会 死 +LangEng: if I sleep , she will die + +-- back to if_then_Conj, now with negations +Lang: ConjS if_then_Conj (BaseS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV sleep_V))) (UseCl (TTAnt TPres ASimul) PNeg (PredVP (UsePron she_Pron) (UseV die_V)))) +LangChi: 如 果 我 睡 觉 , 她 就 不 死 +LangEng: if I sleep then she doesn't die + +Lang: ConjS if_then_Conj (BaseS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV sleep_V))) (UseCl (TTAnt TFut ASimul) PNeg (PredVP (UsePron she_Pron) (UseV die_V)))) +LangChi: 如 果 我 睡 觉 , 她 就 不 会 死 +LangEng: if I sleep then she won't die + + + +-- NP conjunctions +Lang: ConjNP or_Conj (BaseNP (MassNP (UseN fish_N)) (MassNP (UseN beer_N))) +LangChi: 鱼 或 啤 酒 +LangEng: fish or beer + +--NB: unnatural non-empty strings just for testing purpose +Lang: ConjNP if_then_Conj (BaseNP (MassNP (UseN fish_N)) (MassNP (UseN beer_N))) +LangChi: 如 果 鱼 那 么 啤 酒 +LangEng: if fish then beer \ No newline at end of file diff --git a/src/chinese/unittest/future.gftest b/src/chinese/unittest/future.gftest new file mode 100644 index 000000000..6a7110fad --- /dev/null +++ b/src/chinese/unittest/future.gftest @@ -0,0 +1,32 @@ +Lang: UseCl (TTAnt TFut ASimul) PPos (PredVP (UsePron i_Pron) (UseV die_V)) +LangChi: 我 会 死 +LangEng: I will die + +Lang: ExtAdvS (SubjS if_Subj (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV sleep_V)))) (UseCl (TTAnt TFut ASimul) PPos (PredVP (UsePron she_Pron) (UseV walk_V))) +LangChi: 如 果 我 睡 觉 , 她 会 走 +LangEng: if I sleep , she will walk + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ProgrVP (UseV die_V))) +LangChi: 我 在 死 +LangEng: I am dying + +Lang: UseCl (TTAnt TFut ASimul) PNeg (PredVP (UsePron i_Pron) (UseV die_V)) +LangChi: 我 不 会 死 +LangEng: I won't die + +Lang: UseQCl (TTAnt TFut ASimul) PPos (QuestCl (PredVP (UsePron i_Pron) (UseV die_V))) +-- LangChi: 我 会 不 会 死 +LangChi: 我 会 死 吗 +LangEng: will I die + +Lang: UseQCl (TTAnt TFut ASimul) PNeg (QuestCl (PredVP (UsePron i_Pron) (UseV die_V))) +LangChi: 我 不 会 死 吗 +LangEng: won't I die + +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (UsePron i_Pron) (ComplVQ know_VQ (UseQCl (TTAnt TFut ASimul) PPos (QuestCl (PredVP (UsePron i_Pron) (UseV die_V)))))) +LangChi: 我 不 知 道 我 会 死 吗 +LangEng: I don't know if I will die + +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (UsePron i_Pron) (ComplVQ know_VQ (UseQCl (TTAnt TFut ASimul) PNeg (QuestCl (PredVP (UsePron i_Pron) (UseV die_V)))))) +LangChi: 我 不 知 道 我 不 会 死 吗 +LangEng: I don't know if I won't die \ No newline at end of file diff --git a/src/chinese/unittest/negation.gftest b/src/chinese/unittest/negation.gftest new file mode 100644 index 000000000..f78c4144d --- /dev/null +++ b/src/chinese/unittest/negation.gftest @@ -0,0 +1,30 @@ +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (MassNP (UseN cat_N)) (UseComp (CompCN (UseN dog_N)))) +LangEng: cat isn't a dog +LangChi: 猫 不 是 狗 + +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant this_Quant NumPl) (UseN cat_N)) (UseComp (CompAP (PositA green_A)))) +LangEng: these cats aren't green +LangChi: 这 些 猫 不 是 绿 色 的 + +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant that_Quant NumPl) (UseN cat_N)) (UseComp (CompAdv (PrepNP in_Prep (DetCN (DetQuant DefArt NumSg) (UseN house_N)))))) +LangEng: those cats aren't in the house +LangChi: 那 些 猫 不 在 房 子 中 + +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant this_Quant NumPl) (UseN cat_N)) (ComplVV can8know_VV (UseV walk_V))) +LangChi: 这 些 猫 不 会 走 +LangEng: these cats can't walk + +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant this_Quant NumPl) (UseN cat_N)) (ComplVV can_VV (UseV walk_V))) +LangChi: 这 些 猫 不 能 走 +LangEng: these cats can't walk + +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant this_Quant NumPl) (UseN cat_N)) (ComplVV want_VV (UseV walk_V))) +LangChi: 这 些 猫 不 想 走 +LangEng: these cats don't want to walk + +-- this tree does not make semantic sense in chinese but is compositionally correct due to the direct word for word translation for "must" +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant that_Quant NumPl) (UseN cat_N)) (ComplVV must_VV (UseV walk_V))) +LangChi: 那 些 猫 不 必 须 走 +LangEng: those cats mustn't walk + +-- 没有 and must not , bu ke yi \ No newline at end of file diff --git a/src/chinese/unittest/numerals.gftest b/src/chinese/unittest/numerals.gftest new file mode 100644 index 000000000..ff2077a23 --- /dev/null +++ b/src/chinese/unittest/numerals.gftest @@ -0,0 +1,11 @@ +Lang: DetCN (DetQuant IndefArt (NumCard (NumNumeral (num (pot2as3 (pot1as2 (pot0as1 pot01))))))) (UseN cat_N) +LangEng: one cat +LangChi: 一 只 猫 + +Lang: DetCN (DetQuant this_Quant (NumCard (NumNumeral (num (pot2as3 (pot1as2 (pot0as1 (pot0 n5)))))))) (UseN cat_N) +LangEng: these five cats +LangChi: 这 五 只 猫 + +Lang: DetCN (DetQuant (PossPron i_Pron) (NumCard (NumNumeral (num (pot2as3 (pot2 (pot0 n7))))))) (UseN cat_N) +LangEng: my seven hundred cats +LangChi: 我 的 七 百 只 猫 \ No newline at end of file diff --git a/src/chinese/unittest/passive.gftest b/src/chinese/unittest/passive.gftest new file mode 100644 index 000000000..3a2e5c887 --- /dev/null +++ b/src/chinese/unittest/passive.gftest @@ -0,0 +1,11 @@ +Lang: PredVP (DetCN (DetQuant that_Quant NumSg) (UseN boy_N)) (PassV2 kill_V2) +LangEng: that boy is killed +LangChi: 那 个 男 孩 被 杀 + +Lang: PredVP (DetCN (DetQuant DefArt NumSg) (UseN chair_N)) (PassV2 split_V2) +LangEng: the chair is split +LangChi: 椅 子 被 劈 开 + +Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant that_Quant NumSg) (UseN boy_N)) (ComplVV want_VV (PassV2 kill_V2))) +LangEng: that boy doesn't want to be killed +LangChi: 那 个 男 孩 不 想 被 杀 diff --git a/src/chinese/unittest/pronouns.gftest b/src/chinese/unittest/pronouns.gftest new file mode 100644 index 000000000..37f6c4bd8 --- /dev/null +++ b/src/chinese/unittest/pronouns.gftest @@ -0,0 +1,117 @@ +---------- +-- Objects + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (ComplSlash (VPSlashPrep (ComplSlash (VPSlashPrep (UseV go_V) with_Prep) (UsePron i_Pron)) to_Prep) (DetCN (DetQuant DefArt NumSg) (UseN moon_N)))) +LangEng: the cat goes with me to the moon +LangChi: 猫 和 我 一 起 往 月 亮 去 + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant (PossPron i_Pron) NumPl) (UseN cat_N)) (UseComp (CompAdv (PrepNP with_Prep (DetCN (DetQuant that_Quant NumSg) (UseN person_N)))))) +LangEng: my cats are with that person +LangChi: 我 的 猫 和 那 个 人 一 起 + +Lang: UseCl (TTAnt TPast ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a hit_V2) (UsePron he_Pron))) +LangEng: I hit him +LangChi: 我 打 了 他 + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a hit_V2) (UsePron he_Pron))) +LangEng: I hit him +LangChi: 我 打 他 + +------------- +-- Possession +Lang: DetCN (DetQuant (PossPron i_Pron) NumSg) (UseN cat_N) +LangEng: my cat +LangChi: 我 的 猫 + +-- that is my cat +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetNP (DetQuant that_Quant NumSg)) (UseComp (CompNP (DetCN (DetQuant (PossPron i_Pron) NumSg) (UseN cat_N))))) +LangEng: that is my cat +LangChi: 那 个 是 我 的 猫 + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant that_Quant NumSg) (UseN cat_N)) (UseComp (CompNP (DetNP (DetQuant (PossPron i_Pron) NumSg))))) +LangEng: that cat is mine +LangChi: 那 只 猫 是 我 的 + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant (PossPron she_Pron) NumSg) (UseN cat_N)) (UseComp (CompAP (PositA green_A)))) +LangEng: her cat is green +LangChi: 她 的 猫 是 绿 色 的 + +-- two variants, different trees +-- read a book +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron he_Pron) (ComplSlash (SlashV2a read_V2) (DetCN (DetQuant IndefArt NumSg) (PossNP (UseN book_N) (UsePron she_Pron))))) +LangEng: he reads a book of hers +LangChi: 他 读 一 本 她 的 书 + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron he_Pron) (ComplSlash (SlashV2a read_V2) (DetCN (DetQuant (PossPron she_Pron) NumSg) (UseN book_N)))) +LangEng: he reads her book +LangChi: 他 读 她 的 书 + +-- I read his/her father's book +Lang: UseCl (TTAnt TPast ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a read_V2) (DetCN (DetQuant DefArt NumSg) (PossNP (UseN book_N) (DetCN (DetQuant DefArt NumSg) (PossNP (UseN2 father_N2) (UsePron she_Pron))))))) +LangEng: I read the book of the father of hers +LangChi: 我 读 了 她 的 父 亲 的 书 + +-- Only the noun phrase +Lang: MassNP (PossNP (UseN book_N) (UsePron he_Pron)) +LangEng: book of his +LangChi: 他 的 书 + +Lang: DetCN (DetQuant (PossPron he_Pron) NumSg) (UseN book_N) +LangEng: his book +LangChi: 他 的 书 + +-- For non-pronoun NPs, multiple trees +Lang: AdvNP (MassNP (UseN book_N)) (PrepNP part_Prep (DetCN (DetQuant DefArt NumSg) (UseN cat_N))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: AdvNP (MassNP (UseN book_N)) (PrepNP possess_Prep (DetCN (DetQuant DefArt NumSg) (UseN cat_N))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: MassNP (AdvCN (UseN book_N) (PrepNP part_Prep (DetCN (DetQuant DefArt NumSg) (UseN cat_N)))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: MassNP (AdvCN (UseN book_N) (PrepNP possess_Prep (DetCN (DetQuant DefArt NumSg) (UseN cat_N)))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: MassNP (ApposCN (AdvCN (UseN book_N) (PrepNP part_Prep (DetNP (DetQuant DefArt NumPl)))) (MassNP (UseN cat_N))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: MassNP (ApposCN (AdvCN (UseN book_N) (PrepNP possess_Prep (DetNP (DetQuant DefArt NumPl)))) (MassNP (UseN cat_N))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: MassNP (ApposCN (PartNP (UseN book_N) (DetNP (DetQuant DefArt NumPl))) (MassNP (UseN cat_N))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: MassNP (ApposCN (PossNP (UseN book_N) (DetNP (DetQuant DefArt NumPl))) (MassNP (UseN cat_N))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: MassNP (PartNP (UseN book_N) (DetCN (DetQuant DefArt NumSg) (UseN cat_N))) +LangEng: book of the cat +LangChi: 猫 的 书 + +Lang: MassNP (PossNP (UseN book_N) (DetCN (DetQuant DefArt NumSg) (UseN cat_N))) +LangEng: book of the cat +LangChi: 猫 的 书 + +-- You can also produce nonsensical variants, in all languages. +-- The point of RGL is to be a collection of syntactic structures, +-- and application grammarians can choose to use them in any combinations. +-- So the following English linearizations aren't *wrong*, they just don't make sense. + +-- If theese Chinese linearizations are merely weird, like the English ones, then they are correct. +-- If they feel wrong in the same way as "his cat of my" would in English, then they are wrong. +Lang: DetCN (DetQuant (PossPron he_Pron) NumSg) (PossNP (UseN cat_N) (UsePron i_Pron)) +LangEng: his cat of mine +LangChi: 他 的 我 的 猫 + +Lang: DetCN (DetQuant (PossPron i_Pron) NumSg) (PossNP (UseN cat_N) (UsePron she_Pron)) +LangEng: my cat of hers +LangChi: 我 的 她 的 猫 \ No newline at end of file diff --git a/src/chinese/unittest/quantifier.gftest b/src/chinese/unittest/quantifier.gftest new file mode 100644 index 000000000..2a15d0cbf --- /dev/null +++ b/src/chinese/unittest/quantifier.gftest @@ -0,0 +1,63 @@ +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a have_V2) (DetCN somePl_Det (UseN cat_N)))) +--LangChi: 我 有 一 些 只 猫 +LangChi: 我 有 一 些 猫 +LangEng: I have some cats + +Lang: DetCN someSg_Det (UseN water_N) +--LangChi: 一 些 滴 水 +LangChi: 一 些 水 +LangEng: some water + +Lang: DetCN someSg_Det (UseN beer_N) +--LangChi: 一 些 杯 啤 酒 +LangChi: 一 些 啤 酒 +LangEng: some beer + +--LangChi: 我 有 几 只 猫 +--LangEng: I have a few cats + + +Lang: DetCN (DetQuant IndefArt (NumCard (NumNumeral (num (pot2as3 (pot1as2 pot111)))))) (UseN cat_N) +LangChi: 十 一 只 猫 +LangEng: eleven cats + +Lang: DetCN many_Det (UseN cat_N) +LangChi: 很 多 猫 +LangEng: many cats + +Lang: PredVP (UsePron i_Pron) (ComplVV want_VV (ComplSlash (SlashV2a have_V2) (DetCN many_Det (UseN child_N)))) +LangChi: 我 想 有 很 多 孩 子 +LangEng: I want to have many children + + +Lang: DetCN (DetQuant this_Quant NumPl) (UseN cat_N) +LangChi: 这 些 猫 +LangEng: these cats + +Lang: DetCN (DetQuant this_Quant NumSg) (UseN cat_N) +LangChi: 这 只 猫 +LangEng: this cat + +Lang: PredVP (UsePron i_Pron) (ComplSlash (SlashV2a like_V2) (DetCN (DetQuant that_Quant NumPl) (UseN cat_N))) +LangChi: 我 喜 欢 那 些 猫 +LangEng: I like those cats + +Lang: PredVP (UsePron i_Pron) (ComplSlash (SlashV2a like_V2) (DetCN (DetQuant that_Quant NumSg) (UseN cat_N))) +LangChi: 我 喜 欢 那 只 猫 +LangEng: I like that cat + +Lang: DetCN every_Det (UseN rule_N) +LangChi: 每 项 规 则 +LangEng: every rule + +Lang: DetCN few_Det (UseN child_N) +LangChi: 少 些 孩 子 +LangEng: few children + +Lang: PredVP (UsePron i_Pron) (ComplVV want_VV (ComplSlash (SlashV2a have_V2) (DetCN few_Det (UseN child_N)))) +LangChi: 我 想 有 少 些 孩 子 +LangEng: I want to have few children + +Lang: DetCN much_Det (UseN beer_N) +LangChi: 多 杯 啤 酒 +LangEng: much beer diff --git a/src/chinese/unittest/relative.gftest b/src/chinese/unittest/relative.gftest new file mode 100644 index 000000000..1d697bba4 --- /dev/null +++ b/src/chinese/unittest/relative.gftest @@ -0,0 +1,57 @@ +-------------------------------------------------------------- +-- Basics + +Lang: DetCN (DetQuant IndefArt NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (UseV walk_V)))) +LangEng: a cat that walks +LangChi: 一 只 走 的 猫 + +Lang: DetCN (DetQuant IndefArt NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (ComplSlash (SlashV2a drink_V2) (MassNP (UseN milk_N)))))) +LangEng: a cat that drinks milk +LangChi: 一 只 喝 牛 奶 的 猫 + +Lang: MassNP (RelCN (UseN milk_N) (UseRCl (TTAnt TPres ASimul) PPos (RelSlash IdRP (SlashVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (SlashV2a drink_V2))))) +LangEng: milk that the cat drinks +LangChi: 猫 喝 的 牛 奶 + + +Lang: DetCN (DetQuant DefArt NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (ComplSlash (VPSlashPrep (UseV walk_V) with_Prep) (DetCN (DetQuant DefArt NumSg) (UseN dog_N)))))) +LangChi: 和 狗 一 起 走 的 猫 +LangEng: the cat that walks with the dog + +-------------------------------------------------------------- +-- Determiner placement + +Lang: DetCN (DetQuant this_Quant NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (UseV walk_V)))) +LangEng: this cat that walks +LangChi: 这 只 走 的 猫 + +Lang: DetCN (DetQuant (PossPron i_Pron) NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (ComplSlash (SlashV2a drink_V2) (MassNP (UseN milk_N)))))) +LangEng: my cat that drinks milk +LangChi: 我 的 喝 牛 奶 的 猫 + + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetNP (DetQuant this_Quant NumSg)) (UseComp (CompNP (DetCN (DetQuant DefArt NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (UseV walk_V)))))))) +LangEng: this is the cat that walks +LangChi: 这 个 是 走 的 猫 + + +-------------------------------------------------------------- +-- Complex example: "the book that his/her father gave him/her" + +-- 1. His father gave him a book +Lang: UseCl (TTAnt TPast ASimul) PPos (PredVP (MassNP (ComplN2 father_N2 (UsePron he_Pron))) (ComplSlash (Slash2V3 give_V3 (MassNP (UseN book_N))) (UsePron he_Pron))) +LangChi: 他 父 亲 把 书 给 了 他 + +-- 2. the book that the father of her gave her +Lang: DetCN (DetQuant DefArt NumSg) (RelCN (UseN book_N) (UseRCl (TTAnt TPast ASimul) PPos (RelSlash IdRP (SlashVP (DetCN (DetQuant DefArt NumSg) (ComplN2 father_N2 (UsePron she_Pron))) (Slash3V3 give_V3 (UsePron she_Pron)))))) +LangChi: 她 父 亲 给 了 她 的 书 +LangEng: the book that the father of her gave her + +-- I want to read the book that my father gave me +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplVV want_VV (ComplSlash (SlashV2a read_V2) (DetCN (DetQuant DefArt NumSg) (RelCN (UseN book_N) (UseRCl (TTAnt TPast ASimul) PPos (RelSlash IdRP (SlashVP (DetCN (DetQuant (PossPron i_Pron) NumSg) (UseN2 father_N2)) (Slash3V3 give_V3 (UsePron i_Pron)))))))))) +LangChi: 我 想 读 我 的 父 亲 给 了 我 的 书 + + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplVV want_VV (ComplSlash (SlashV2a read_V2) (DetCN (DetQuant DefArt NumSg) (RelCN (UseN book_N) (UseRCl (TTAnt TPast ASimul) PPos (RelSlash IdRP (SlashVP (DetCN (DetQuant (PossPron i_Pron) NumSg) (UseN2 father_N2)) (SlashV2a read_V2))))))))) +LangChi: 我 想 读 我 的 父 亲 读 了 的 书 +LangEng: I want to read the book that my father read \ No newline at end of file diff --git a/src/chinese/unittest/tenses.gftest b/src/chinese/unittest/tenses.gftest new file mode 100644 index 000000000..e85c43fa9 --- /dev/null +++ b/src/chinese/unittest/tenses.gftest @@ -0,0 +1,44 @@ +------------- +-- Basics + +Lang: UseCl (TTAnt TPres AAnter) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (UseV walk_V)) +LangEng: the cat has walked +LangChi: 猫 走 了 + +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant this_Quant NumSg) (UseN cat_N)) (UseV walk_V)) +LangEng: this cat walks +LangChi: 这 只 猫 走 + +Lang: UseCl (TTAnt TFut ASimul) PPos (PredVP (DetCN (DetQuant this_Quant NumSg) (UseN cat_N)) (UseV walk_V)) +LangEng: this cat will walk +LangChi: 这 只 猫 会 走 + +Lang: PredVP (DetCN (DetQuant this_Quant NumSg) (UseN cat_N)) (ComplVV can8know_VV (UseV walk_V)) +LangChi: 这 只 猫 会 走 +LangEng: this cat can walk + +Lang: PredVP (DetCN (DetQuant this_Quant NumSg) (UseN cat_N)) (ComplVV can_VV (UseV walk_V)) +LangChi: 这 只 猫 能 走 +LangEng: this cat can walk + +-- As a verbal complement +Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant (PossPron i_Pron) NumSg) (UseN cat_N)) (ComplVV want_VV (UseV walk_V))) +LangChi: 我 的 猫 想 走 +LangEng: my cat wants to walk + +-- Transitive verbs + +Lang: UseCl (TTAnt TPres AAnter) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a eat_V2) (DetCN (DetQuant IndefArt NumSg) (UseN fish_N)))) +LangChi: 我 吃 了 一 条 鱼 +LangEng: I have eaten a fish + +------------- +-- Conditions + +Lang: AdvS (SubjS if_Subj (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV walk_V)))) (UseCl (TTAnt TFut ASimul) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (UseV walk_V))) +LangEng: if I walk the cat will walk +LangChi: 如 果 我 走 猫 会 走 + +Lang: ExtAdvS (SubjS when_Subj (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseV walk_V)))) (UseCl (TTAnt TFut ASimul) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (UseV walk_V))) +LangEng: when I walk , the cat will walk +LangChi: 我 走 的 时 候 , 猫 会 走 diff --git a/src/english/LangEng.labels b/src/english/LangEng.labels index e011bab47..625bd231f 100644 --- a/src/english/LangEng.labels +++ b/src/english/LangEng.labels @@ -3,13 +3,13 @@ UseV,ComplVV,ComplVS,ComplVQ,ComplVA,SlashV2a,SlashV2V,SlashV2A,SlashV2S,Slash2V UseV,UseComp {"to"} PART mark head UseComp,CompAdv,CompAP,CompNP,CompCN,ProgrVP,QuestIComp {"is","are","am","was","were","been","be"} VERB cop head CompCN {"a","an"} DET det head -PassV2 {"is","are","am","was","were""been","be"} VERB auxpass head +PassV2 {"is","are","am","was","were""been","be"} VERB aux:pass head ComplVV {"to"} PART mark xcomp ComplVS {"that"} PART mark ccomp EmbedVP {"to"} PART mark head EmbedS {"that"} PART mark head SentCN {"that","to"} PART mark acl -ExtAdvS,SubjS {","} PUNCT punct head +ConsNP,ExtAdvS,SSubjS,VocNP {","} PUNCT punct head ExistNPAdv,ExistNP {"not","don't","doesn't","didn't","haven't","hasn't","hadn't","wouldn't","won't","isn't","aren't","wasn't","weren't"} PART neg head ExistNPAdv,ExistNP {"has","had","have","will","would","do","does","did"} AUX aux head ExistNPAdv,ExistNP {"is","are","am","was","were""been","be"} VERB cop head @@ -34,9 +34,3 @@ PossNP,PartNP {"of"} ADP case nmod @"am" PresSg1 @"is" PresSg3 @"are" PresPl - - - - - - diff --git a/src/german/ExtendGer.gf b/src/german/ExtendGer.gf index 030c4ceb6..bf6757c7c 100644 --- a/src/german/ExtendGer.gf +++ b/src/german/ExtendGer.gf @@ -81,7 +81,8 @@ lin infObjs = (vp.inf.inpl.p1)!agr ; -- adapted to new VP.inf, HL 3/2022 infPred = vp.inf.inpl.p2 ; infCompl : Str = case of { - => [] ; _ => infObjs ++ infPred } ; + => [] ; --# notpresent + _ => infObjs ++ infPred } ; pred : {inf, infComplfin : Str} = case of { => --# notpresent {inf = infObjs ++ haben ++ infPred ++ verb.inf ; --# notpresent Duden 318 diff --git a/src/german/ExtraGer.gf b/src/german/ExtraGer.gf index ea099fcef..df1906d0b 100644 --- a/src/german/ExtraGer.gf +++ b/src/german/ExtraGer.gf @@ -142,7 +142,8 @@ concrete ExtraGer of ExtraGerAbs = CatGer ** infObjs = (vp.inf.inpl.p1)!agr ; -- adapted to new VP.inf, HL 3/2022 infPred = vp.inf.inpl.p2 ; infCompl : Str = case of { - => [] ; _ => infObjs ++ infPred } ; + => [] ; --# notpresent + _ => infObjs ++ infPred } ; pred : {inf, infComplfin : Str} = case of { => --# notpresent {inf = infObjs ++ haben ++ infPred ++ verb.inf ; --# notpresent Duden 318 @@ -182,7 +183,7 @@ concrete ExtraGer of ExtraGerAbs = CatGer ** ReflPoss num cn = {s = \\a,c => num.s ! cn.g ! c ++ possPron a num.n cn.g c ++ cn.s ! adjfCase Strong c ! num.n ! c} ; - ReflPron = { s = reflPron } ; -- reflexively used personal pronoun, with special forms in P3 Sg + ReflPron = { s = ResGer.reflPron } ; -- reflexively used personal pronoun, with special forms in P3 Sg -- In P1,P2 we might use "selbst" to define a (stronger) reflexive pronoun instead: -- HL 3/2022 -- du kennst mich vs. ich kenne mich selbst @@ -190,7 +191,7 @@ concrete ExtraGer of ExtraGerAbs = CatGer ** -- sie kennen sich (selbst) =/= sie kennen einander -- Likewise, instead of ReflPoss we might define a reflexive possessive pronoun: -- du kennst meine Fehler vs. ich kenne meine eigenen Fehler - -- er|sie|es kennt seine Fehler vs. er|sie|es kennt seine|ihre|seine eigenen Fehler + -- er|sie|es kennt seine|ihre Fehler vs. er|sie|es kennt seine|ihre|seine eigenen Fehler oper reflPronSelf : Agr => Case => Str = \\a => \\c => reflPron ! a ! c ++ "selbst" ; @@ -299,4 +300,6 @@ concrete ExtraGer of ExtraGerAbs = CatGer ** -- this function is not entirely satisfactory as largely -- though not entirely duplicating mkClause in ResGer + + } diff --git a/src/german/ExtraGerAbs.gf b/src/german/ExtraGerAbs.gf index ef02bf633..eff464de3 100644 --- a/src/german/ExtraGerAbs.gf +++ b/src/german/ExtraGerAbs.gf @@ -4,13 +4,12 @@ abstract ExtraGerAbs = Extra [ VPSlash, PassVPSlash, PassAgentVPSlash, CompIQuant, PastPartAP, PastPartAgentAP, Temp,Tense,Pol,S,NP,VV,VP,Conj,IAdv,IQuant,IComp,ICompAP,IAdvAdv,Adv,AP, Foc,FocObj,FocAdv,FocAP,UseFoc, - RNP,ReflRNP,ReflPoss + RNP,ReflRNP,ReflPoss,ReflPron ] ** { flags coding=utf8; cat FClause ; -- formal clause - fun PPzuAdv : CN -> Adv ; -- zum Lied, zur Flasche TImpfSubj : Tense ; -- ich möchte... --# notpresent @@ -27,4 +26,5 @@ abstract ExtraGerAbs = Extra [ FtoCl : FClause -> Cl ; -- embedding FClause within the RGL, to allow generation of S, Utt, etc. Pass3V3 : V3 -> VPSlash ; -- wir bekommen den Beweis erklärt + } diff --git a/src/german/ResGer.gf b/src/german/ResGer.gf index d23216991..cd4da865e 100644 --- a/src/german/ResGer.gf +++ b/src/german/ResGer.gf @@ -254,7 +254,7 @@ resource ResGer = ParamX ** open Prelude in { -- adv : Str ; -- die Frage [a von Max] -- HL: cannot be extracted a : Agr ; -- isLight : Bool ; -- light NPs come before negation in simple clauses (expensive) - -- isPron : Bool } ; -- needed to put accPron before datPron + -- isPron : Bool ; -- needed to put accPron before datPron w : Weight } ; mkN : (x1,_,_,_,_,x6,x7 : Str) -> Gender -> Noun = @@ -606,7 +606,7 @@ resource ResGer = ParamX ** open Prelude in { Fut => vf True (wird m a) vpart haben ; --# notpresent Cond => vf True (wuerde a) vpart haben ; --# notpresent Pres => vf True (hat m t a) vpart [] - } ; --# notpresent + } ; VPImperat False => vf False (verb.s ! VImper (numberAgr a)) [] [] ; VPImperat True => vf False (verb.s ! VFin False (VPresSubj Pl P3)) [] [] ; VPInfinit Anter => vf True [] (vpart ++ haben) [] ; --# notpresent @@ -828,7 +828,8 @@ resource ResGer = ParamX ** open Prelude in { -- leave inf-complement of +auxV(2)V in place, -- extract infzu-complement of -auxV(2)V: (ComplVV, SlashV2V) infCompl : Str = case of { - => [] ; _ => infObjs ++ infPred } ; + => [] ; --# notpresent + _ => infObjs ++ infPred } ; pred : {inf, infComplfin : Str} = case of { => --# notpresent {inf = infObjs ++ haben ++ infPred ++ verb.inf ; --# notpresent Duden 318 @@ -838,15 +839,10 @@ resource ResGer = ParamX ** open Prelude in { {inf = verb.inf ++ haben ; --# notpresent infComplfin = -- es ++ wird/hat/hatte ++ tun ++ wollen --# notpresent infObjs ++ verb.fin ++ infPred ++ verb.inf ++ haben} ; --# notpresent - => + _ => {inf = verb.inf ++ haben ; - infComplfin = -- es zu tun ++ [] ++ [] ++ versucht + infComplfin = -- es zu tun ++ versucht/[] +[]+ hat/versuchte infCompl ++ verb.inf ++ haben ++ verb.fin} - ; --# notpresent - _ => --# notpresent - {inf = verb.inf ++ haben ; --# notpresent - infComplfin = -- es zu tun ++ versucht ++ [] ++ hat --# notpresent - infCompl ++ verb.inf ++ haben ++ verb.fin} --# notpresent } ; extra = vp.inf.extr!agr ++ vp.ext ; in @@ -1005,4 +1001,3 @@ resource ResGer = ParamX ** open Prelude in { in ; } - diff --git a/src/malay/unittest/negation.gftest b/src/malay/unittest/negation.gftest index 95c152333..f44c7a3db 100644 --- a/src/malay/unittest/negation.gftest +++ b/src/malay/unittest/negation.gftest @@ -8,7 +8,7 @@ LangMay: kucing tidak berjalan Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant this_Quant NumPl) (UseN cat_N)) (UseComp (CompAP (PositA green_A)))) LangEng: these cats aren't green -LangMay: kucing-kucing ini hijau +LangMay: kucing-kucing ini tidak hijau Lang: UseCl (TTAnt TPres ASimul) PNeg (PredVP (DetCN (DetQuant that_Quant NumPl) (UseN cat_N)) (UseComp (CompAdv (PrepNP in_Prep (DetCN (DetQuant DefArt NumSg) (UseN house_N)))))) LangEng: those cats aren't in the house diff --git a/tests/german/TestLang.gf b/tests/german/TestLang.gf index 663258f02..107765a8b 100644 --- a/tests/german/TestLang.gf +++ b/tests/german/TestLang.gf @@ -1,5 +1,5 @@ abstract TestLang = - Grammar, + Grammar - [SlashVP, RelSlash], TestLexiconGerAbs , Construction ** { @@ -32,4 +32,12 @@ abstract TestLang = Pass2V3 : V3 -> NP -> VP ; -- uns erklärt werden ; Eng give_V3[indir,dir]: we are given the book Pass2V4 : V4 -> NP -> VPSlash ; -- bei dir (für Gold) gekauft werden + + cat + ClauseSlash ; + + fun + RelSlash : RP -> ClauseSlash -> RCl ; + SlashVP : NP -> VPSlash -> ClauseSlash ; + } ; diff --git a/tests/german/TestLangGer.gf b/tests/german/TestLangGer.gf index e94536e5e..4fe2bf143 100644 --- a/tests/german/TestLangGer.gf +++ b/tests/german/TestLangGer.gf @@ -2,7 +2,7 @@ -- use the modified files in gf-rgl/src/german concrete TestLangGer of TestLang = - GrammarGer + GrammarGer - [SlashVP, RelSlash] , TestLexiconGer , ConstructionGer ** open ResGer,Prelude,(P=ParadigmsGer) in { @@ -100,12 +100,10 @@ concrete TestLangGer of TestLang = insertExtrapos vp.ext ( insertInf inf vps) ** {c2 = v.c2 ; objCtrl = v.objCtrl} ; -} - -- SlashV2VNP : V2V -> NP -> VPSlash -> VPSlash ; -- beg me to buy -- -- (the book) that (she (begged:V2V me:NP (to buy ()):VPSlash):VPSlash):ClSlash --- 3/22 expensive: +-- 3/22 expensive: |NP|=54, |Prep|=|18|, |V2|=180, |V2V|=720, |VP|=360, |VPSlash|=12.290 (!) -- i -v -src TestLangGer.gf -- + ComplSlash 699840 (355680,532) -- + SlashV2V 259200 (1440,20) @@ -152,3 +150,99 @@ gr -tr (PredVP (UsePron ?) (ComplSlash (SlashV2V lassen_V2V (ReflVP (SlashV2a wa -} +-- Reimplementation of SlashVP: replace mkClause by mkClSlash to let reflexives agree +-- with object in relative clauses, if objCtrl = true. To save memory, use +-- ClauseSlash.s : ... => RelGenNum => Str instead of : ... => Agr => Str. +-- + SlashVP 699840 gf: out of memory (requested 2097152 bytes) with Agr => Str +-- + SlashVP 699840 (2880,160) with RelGenNum => Str; |Agr| = 18, |RelGenNum| = 5. +-- Todo: replace other uses of ClSlash by ClauseSlash + + lincat + ClauseSlash = { + s : Mood => ResGer.Tense => Anteriority => Polarity => Order => RelGenNum => Str ; + c2 : Preposition + } ; + + lin + SlashVP np vp = + let subj = mkSubj np vp.c1 + in mkClSlash subj.p1 subj.p2 vp ** { c2 = vp.c2 } ; + + RelSlash rp cls = lin RCl { + s = \\m,t,a,p,gn => + appPrep cls.c2 (\\k => usePrepC k (\c -> rp.s ! gn ! c)) ++ + cls.s ! m ! t ! a ! p ! Sub ! gn ; + c = (prepC cls.c2.c).c + } ; +{- + QuestSlash ip slash = { + s = \\m,t,a,p => + let + cls = slash.s ! m ! t ! a ! p ; + who = appPrep slash.c2 (\\k => usePrepC k (\c -> ip.s ! c)) ; + in table { + QDir => who ++ cls ! Inv ; + QIndir => who ++ cls ! Sub + } + } ; +-} + + + oper + gnToAgr : RelGenNum -> Agr = \gn -> + case gn of {RGenNum (GSg g) => Ag g Sg P3 ; + RGenNum GPl => Ag Neutr Pl P3 ; + RSentence => Ag Neutr Sg P3} ; + + + mkClSlash : Str -> Agr -> ResGer.VPSlash -> ClauseSlash = \subj,agr,vp -> + let vps = useVP vp in lin ClauseSlash { + c2 = vp.c2 ; + s = \\m,t,a,b,o,gn => + let + ord = case o of { + Sub => True ; -- glue prefix to verb + _ => False + } ; + verb = vps.s ! ord ! agr ! VPFinite m t a ; + haben = verb.inf2 ; + neg = negation ! b ; + ag : Agr = case vp.objCtrl of {True => gnToAgr gn ; _ => agr} ; + obj1 = (vp.nn ! ag).p1 ++ (vp.nn ! ag).p2 ; -- refl ++ pronouns ++ light nps + obj2 = (vp.nn ! ag).p3 ; -- pp-objects and heavy nps + obj3 = (vp.nn ! ag).p4 ++ vp.adj ++ vp.a2 ; -- pred.AP|CN|Adv, via useComp HL 6/2019 + compl : Str = obj1 ++ obj2 ++ neg ++ obj3 ; + infObjs = (vp.inf.inpl.p1) ! ag ; + infPred = vp.inf.inpl.p2 ; + infCompl : Str = case of { + => [] ; _ => infObjs ++ infPred } ; + pred : {inf, infComplfin : Str} = case of { + => --# notpresent + {inf = infObjs ++ haben ++ infPred ++ verb.inf ; --# notpresent Duden 318 + infComplfin = -- es ++ wird ++ haben ++ tun ++ wollen --# notpresent + infObjs ++ verb.fin ++ haben ++ infPred ++ verb.inf} ; --# notpresent + <_,Anter,True> => --# notpresent + {inf = verb.inf ++ haben ; --# notpresent + infComplfin = -- es ++ wird/hat/hatte ++ tun ++ wollen --# notpresent + infObjs ++ verb.fin ++ infPred ++ verb.inf ++ haben} ; --# notpresent + => + {inf = verb.inf ++ haben ; + infComplfin = -- es zu tun ++ [] ++ [] ++ versucht + infCompl ++ verb.inf ++ haben ++ verb.fin} + ; --# notpresent + _ => --# notpresent + {inf = verb.inf ++ haben ; --# notpresent + infComplfin = -- es zu tun ++ versucht ++ [] ++ hat --# notpresent + infCompl ++ verb.inf ++ haben ++ verb.fin} --# notpresent + } ; + extra : Str = (vp.inf.extr) ! ag ++ vp.ext ; + in + case o of { + Main => subj ++ verb.fin ++ compl ++ infCompl ++ pred.inf ++ extra ; + Inv => verb.fin ++ subj ++ compl ++ infCompl ++ pred.inf ++ extra ; + Subj => subj ++ compl ++ pred.infComplfin ++ extra + } + } ; + +} +