forked from GitHub/gf-rgl
make complememt position flexible
This commit is contained in:
+37
-25
@@ -27,6 +27,7 @@ param
|
||||
param
|
||||
Order = SVO | VSO | VOS | OSV | OVS | SOV ;
|
||||
AdvPos = PreS | PreV | PreO | PreNeg | InV | InS ; -- | InO
|
||||
ComplPos = CPreV | CPostV ;
|
||||
SAdvPos = SPreS | SPreV | SPreO | SPreNeg ;
|
||||
param
|
||||
Agr = Ag Gender Number Case ; -- Agreement for NP et al.
|
||||
@@ -1226,19 +1227,22 @@ oper
|
||||
-- clauses
|
||||
Sentence =
|
||||
{
|
||||
s,o,v,neg : AdvPos => Str ; -- Subject, verbphrase, object and negation particle plus potential adverb
|
||||
s,o,neg : AdvPos => Str ; -- Subject, verbphrase, object and negation particle plus potential adverb
|
||||
v : AdvPos => ComplPos => Str ;
|
||||
t : C.Tense ; -- tense marker
|
||||
p : C.Pol ; -- polarity marker
|
||||
sadv : Str -- sentence adverb¡
|
||||
} ;
|
||||
|
||||
Clause = {s,o : AdvPos => Str ; v : Tense => Anteriority => VQForm => AdvPos => Str ; neg : Polarity => AdvPos => Str ; adv : Str } ;
|
||||
Clause = {s,o : AdvPos => Str ; v : Tense => Anteriority => VQForm => AdvPos => ComplPos => Str ; neg : Polarity => AdvPos => Str ; adv : Str } ;
|
||||
QClause = {s : C.Tense => Anteriority => C.Pol => QForm => Str} ;
|
||||
|
||||
mkClause : NounPhrase -> VerbPhrase -> Clause = \np,vp ->
|
||||
let
|
||||
-- combines adverbs from noun phrase and verb phrase
|
||||
adv = np.adv ++ vp.adv ;
|
||||
-- extracts the complement from the verb phrase
|
||||
compl = vp.compl ! Ag np.g np.n Nom ;
|
||||
-- helper functions to either place the adverb in the designated position
|
||||
-- or an empty string instead
|
||||
pres : AdvPos -> Str = \ap -> case ap of { PreS => adv ; _ => [] } ;
|
||||
@@ -1246,33 +1250,38 @@ oper
|
||||
preo : AdvPos -> Str = \ap -> case ap of { PreO => adv ; _ => [] } ;
|
||||
preneg : AdvPos -> Str = \ap -> case ap of { PreNeg => adv ; _ => [] } ;
|
||||
ins : AdvPos -> Str = \ap -> case ap of { InS => adv ; _ => [] } ;
|
||||
inv : AdvPos -> Str = \ap -> case ap of { InV => adv ; _ => [] }
|
||||
inv : AdvPos -> Str = \ap -> case ap of { InV => adv ; _ => [] } ;
|
||||
cprev : ComplPos -> Str = \cp -> case cp of { CPreV => compl ; _ => [] } ;
|
||||
cpostv : ComplPos -> Str = \cp -> case cp of { CPostV => compl ; _ => [] }
|
||||
in
|
||||
{
|
||||
-- subject part of the clause:
|
||||
-- ap is the adverb position in the clause
|
||||
s = \\ap =>
|
||||
pres ap ++ -- adverbs can be placed in the beginning of the clause
|
||||
-- advpos is the adverb position in the clause
|
||||
s = \\advpos =>
|
||||
pres advpos ++ -- adverbs can be placed in the beginning of the clause
|
||||
np.det.s ! np.g ! Nom ++ -- the determiner, if any
|
||||
np.preap.s ! (Ag np.g np.n Nom) ++ -- adjectives which come before the subject noun, agreeing with it
|
||||
ins ap ++ -- adverbs can be placed within the subject noun phrase
|
||||
ins advpos ++ -- adverbs can be placed within the subject noun phrase
|
||||
np.s ! Nom ++ -- the noun of the subject noun phrase in nominative
|
||||
np.postap .s ! (Ag np.g np.n Nom) ++ -- adjectives which come after the subject noun, agreeing with it
|
||||
np.det.sp ! np.g ! Nom ; -- second part of split determiners
|
||||
-- verb part of the clause:
|
||||
-- tense and anter(ority) for the verb tense
|
||||
-- vqf is the VQForm parameter which defines if the ordinary verbform or the quistion form with suffix "-ne" will be used
|
||||
-- ap is the adverb position in the clause
|
||||
v = \\tense,anter,vqf,ap =>
|
||||
prev ap ++ -- adverbs can be placed in the before the verb phrase
|
||||
vp.compl ! Ag np.g np.n Nom ++ -- verb phrase complement, e.g. predicative expression, agreeing with the subject
|
||||
inv ap ++ -- adverbs can be placed within the verb phrase
|
||||
-- advposis the adverb position in the clause
|
||||
-- comppos is the position of the verb complement
|
||||
v = \\tense,anter,vqf,advpos,complpos =>
|
||||
prev advpos ++ -- adverbs can be placed in the before the verb phrase
|
||||
cprev complpos ++ -- verb phrase complement, e.g. predicative expression, agreeing with the subject, can go before the verb
|
||||
inv advpos ++ -- adverbs can be placed within the verb phrase
|
||||
-- verb form with conversion between different forms of tense and aspect
|
||||
vp.s ! VAct ( anteriorityToVAnter anter ) ( tenseToVTense tense ) np.n np.p ! vqf ;
|
||||
vp.s ! VAct ( anteriorityToVAnter anter ) ( tenseToVTense tense ) np.n np.p ! vqf ++
|
||||
cpostv complpos ; -- complement can also go after the verb
|
||||
|
||||
-- object part of the clause
|
||||
o = \\ap => preo ap ++ vp.obj ;
|
||||
o = \\advpos => preo advpos ++ vp.obj ;
|
||||
-- optional negation particle, adverbs can be placed before the negation
|
||||
neg = \\pol,ap => preneg ap ++ negation pol ;
|
||||
neg = \\pol,advpos => preneg advpos ++ negation pol ;
|
||||
adv = ""
|
||||
} ;
|
||||
|
||||
@@ -1286,20 +1295,23 @@ oper
|
||||
p = pol
|
||||
} ;
|
||||
|
||||
combineSentence : Sentence -> ( SAdvPos => AdvPos => Order => Str ) = \s ->
|
||||
combineSentence : Sentence -> ( SAdvPos => AdvPos => ComplPos => Order => Str ) = \s ->
|
||||
let
|
||||
pres : SAdvPos -> Str = \ap -> case ap of { SPreS => s.sadv ; _ => [] } ;
|
||||
prev : SAdvPos -> Str = \ap -> case ap of { SPreV => s.sadv ; _ => [] } ;
|
||||
preo : SAdvPos -> Str = \ap -> case ap of { SPreO => s.sadv ; _ => [] } ;
|
||||
preneg : SAdvPos -> Str = \ap -> case ap of { SPreNeg => s.sadv ; _ => [] }
|
||||
in
|
||||
\\sap,ap,order => case order of {
|
||||
SVO => s.t.s ++ s.p.s ++ pres sap ++ s.s ! ap ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ++ preo sap ++ s.o ! ap;
|
||||
VSO => s.t.s ++ s.p.s ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ++ pres sap ++ s.s ! ap ++ preo sap ++ s.o ! ap;
|
||||
VOS => s.t.s ++ s.p.s ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ++ preo sap ++ s.o ! ap ++ pres sap ++ s.s ! ap ;
|
||||
OSV => s.t.s ++ s.p.s ++ preo sap ++ s.o ! ap ++ pres sap ++ s.s ! ap ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap;
|
||||
OVS => s.t.s ++ s.p.s ++ preo sap ++ s.o ! ap ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ++ pres sap ++ s.s ! ap ;
|
||||
SOV => s.t.s ++ s.p.s ++ pres sap ++ s.s ! ap ++ preo sap ++ s.o ! ap ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap
|
||||
-- sap is the position of the sentence adverbial
|
||||
-- ap is the position of the adverb
|
||||
-- cp is the position of the verb complement
|
||||
\\sap,ap,cp,order => case order of {
|
||||
SVO => s.t.s ++ s.p.s ++ pres sap ++ s.s ! ap ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ! cp ++ preo sap ++ s.o ! ap;
|
||||
VSO => s.t.s ++ s.p.s ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ! cp ++ pres sap ++ s.s ! ap ++ preo sap ++ s.o ! ap;
|
||||
VOS => s.t.s ++ s.p.s ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ! cp ++ preo sap ++ s.o ! ap ++ pres sap ++ s.s ! ap ;
|
||||
OSV => s.t.s ++ s.p.s ++ preo sap ++ s.o ! ap ++ pres sap ++ s.s ! ap ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ! cp;
|
||||
OVS => s.t.s ++ s.p.s ++ preo sap ++ s.o ! ap ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ! cp ++ pres sap ++ s.s ! ap ;
|
||||
SOV => s.t.s ++ s.p.s ++ pres sap ++ s.s ! ap ++ preo sap ++ s.o ! ap ++ preneg sap ++ s.neg ! ap ++ prev sap ++ s.v ! ap ! cp
|
||||
} ;
|
||||
|
||||
|
||||
@@ -1307,8 +1319,8 @@ oper
|
||||
-- questions
|
||||
mkQuestion : SS -> Clause -> QClause = \ss,cl -> {
|
||||
s = \\tense,anter,pol,form => case form of {
|
||||
QDir => ss.s ++ (combineSentence (combineClause cl tense anter pol VQFalse)) ! SPreS ! PreS ! OVS ;
|
||||
QIndir => ss.s ++ (combineSentence (combineClause cl tense anter pol VQFalse)) ! SPreO ! PreO ! OSV
|
||||
QDir => ss.s ++ (combineSentence (combineClause cl tense anter pol VQFalse)) ! SPreS ! PreS ! CPreV ! OVS ;
|
||||
QIndir => ss.s ++ (combineSentence (combineClause cl tense anter pol VQFalse)) ! SPreO ! PreO ! CPreV ! OSV
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user