updated createSentence/add defaultSentence

This commit is contained in:
Herbert Lange
2019-11-12 14:48:54 +01:00
parent f46cbfe51e
commit 6864f61e92
6 changed files with 76 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ concrete AdverbLat of Adverb = CatLat ** open ResLat, Prelude, ParadigmsLat in
-- ComparAdvAdjS : CAdv -> A -> S -> Adv ; -- more warmly than he runs -- ComparAdvAdjS : CAdv -> A -> S -> Adv ; -- more warmly than he runs
ComparAdvAdjS cadv a s = ComparAdvAdjS cadv a s =
mkAdv (cadv.s ++ a.adv.s ! Compar ++ cadv.p ++ combineSentence s ! SPreS ! PreV ! CPreV ! SOV ) ; mkAdv (cadv.s ++ a.adv.s ! Compar ++ cadv.p ++ defaultSentence s ! SOV ) ;
-- AdAdv : AdA -> Adv -> Adv ; -- very quickly -- AdAdv : AdA -> Adv -> Adv ; -- very quickly
AdAdv ada adv = mkAdv (ada.s ++ (adv.s ! Posit) ) ; AdAdv ada adv = mkAdv (ada.s ++ (adv.s ! Posit) ) ;
@@ -29,7 +29,7 @@ concrete AdverbLat of Adverb = CatLat ** open ResLat, Prelude, ParadigmsLat in
-- Subordinate clauses can function as adverbs. -- Subordinate clauses can function as adverbs.
-- SubjS : Subj -> S -> Adv ; -- when she sleeps -- SubjS : Subj -> S -> Adv ; -- when she sleeps
SubjS subj s = mkAdv (subj.s ++ combineSentence s ! SPreS ! PreV ! CPreV ! SOV ) ; SubjS subj s = mkAdv (subj.s ++ defaultSentence s ! SOV ) ;
-- AdnCAdv : CAdv -> AdN ; -- less (than five) -- AdnCAdv : CAdv -> AdN ; -- less (than five)
AdnCAdv cadv = {s = cadv.s ++ cadv.p} ; AdnCAdv cadv = {s = cadv.s ++ cadv.p} ;

View File

@@ -90,7 +90,7 @@ concrete CatLat of Cat = CommonX-[Adv] ** open ResLat, ParamX, Prelude in {
linref linref
NP = \np -> combineNounPhrase np ! PronNonDrop ! APreN ! DPostN ! Nom ; NP = \np -> combineNounPhrase np ! PronNonDrop ! APreN ! DPostN ! Nom ;
VP = \vp -> vp.adv ++ vp.inf ! VInfActPres ++ vp.obj ++ vp.compl ! Ag Masc Sg Nom ; VP = \vp -> vp.adv ++ vp.inf ! VInfActPres ++ vp.obj ++ vp.compl ! Ag Masc Sg Nom ;
S = \s -> combineSentence s ! SPreO ! PreO ! CPreV ! SOV ; S = \s -> defaultSentence s ! SOV ;
V, VS, VQ, VA, VV = \v -> v.act ! (VAct VSim (VPres VInd) Sg P1) ; V, VS, VQ, VA, VV = \v -> v.act ! (VAct VSim (VPres VInd) Sg P1) ;
V2, V2A, V2Q, V2S = \v -> v.act ! (VAct VSim (VPres VInd) Sg P1) ; V2, V2A, V2Q, V2S = \v -> v.act ! (VAct VSim (VPres VInd) Sg P1) ;
Pron = \p -> p.pers.s ! PronNonDrop ! PronNonRefl ! Nom ; Pron = \p -> p.pers.s ! PronNonDrop ! PronNonRefl ! Nom ;

View File

@@ -3,7 +3,7 @@ concrete PhraseLat of Phrase = CatLat ** open Prelude, ResLat in {
PhrUtt pconj utt voc = {s = pconj.s ++ utt.s ++ voc.s} ; PhrUtt pconj utt voc = {s = pconj.s ++ utt.s ++ voc.s} ;
-- --
-- UttS : S -> Utt -- UttS : S -> Utt
UttS s = { s = combineSentence s ! SPreS ! PreS ! CPreV ! SOV }; UttS s = { s = defaultSentence s ! SOV };
-- UttQS : QS -> Utt -- UttQS : QS -> Utt
UttQS qs = {s = qs.s ! QDir } ; UttQS qs = {s = qs.s ! QDir } ;

View File

@@ -25,11 +25,19 @@ param
det : Determiner det : Determiner
} ; } ;
param param
-- Parameters to determine word order
-- top level order, e.g. subject verb object
Order = SVO | VSO | VOS | OSV | OVS | SOV ; Order = SVO | VSO | VOS | OSV | OVS | SOV ;
-- determiner position in a noun phrase, e.g. before or after noun
DetPos = DPreN | DPostN ;
-- verb position, eithe regular or interleaved in the subject
VPos = VReg | VInS ;
-- (verb-modifying) adverb position -- (verb-modifying) adverb position
AdvPos = APreS | APreV | APreO | APreNeg | AInV | AInS | APreN | APostN ; -- | InO AdvPos = APreS | APreV | APreO | APreNeg | AInV | AInS | APreN | APostN ; -- | InO
-- verb complement position in relation to verb
ComplPos = CPreV | CPostV ; ComplPos = CPreV | CPostV ;
SAdvPos = SPreS | SPreV | SPreO | SPreNeg ; -- sentence adverb position
SAdvPos = SAPreS | SAPreV | SAPreO | SAPreNeg ;
param param
Agr = Ag Gender Number Case ; -- Agreement for NP et al. Agr = Ag Gender Number Case ; -- Agreement for NP et al.
oper oper
@@ -1303,10 +1311,12 @@ oper
Sentence = Sentence =
{ {
s,o,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 ; v : AdvPos => Str ;
t : C.Tense ; -- tense marker t : C.Tense ; -- tense marker
p : C.Pol ; -- polarity marker p : C.Pol ; -- polarity marker
sadv : Str -- sentence adverb¡ sadv : Str ; -- sentence adverb¡
det : { s , sp : Case => Str } ;
compl : Str -- verb complement
} ; } ;
Clause = Clause =
@@ -1379,32 +1389,70 @@ oper
p = pol ; p = pol ;
} ; } ;
combineSentence : Sentence -> ( SAdvPos => AdvPos => ComplPos => Order => Str ) = \s -> combineSentence : Sentence -> ( SAdvPos => AdvPos => DetPos => VPos => ComplPos => Order => Str ) = \s ->
let let
pres : SAdvPos -> Str = \ap -> case ap of { SPreS => s.sadv ; _ => [] } ; advpres : SAdvPos -> Str = \ap -> case ap of { SAPreS => s.sadv ; _ => [] } ;
prev : SAdvPos -> Str = \ap -> case ap of { SPreV => s.sadv ; _ => [] } ; advprev : SAdvPos -> Str = \ap -> case ap of { SAPreV => s.sadv ; _ => [] } ;
preo : SAdvPos -> Str = \ap -> case ap of { SPreO => s.sadv ; _ => [] } ; advpreo : SAdvPos -> Str = \ap -> case ap of { SAPreO => s.sadv ; _ => [] } ;
preneg : SAdvPos -> Str = \ap -> case ap of { SPreNeg => s.sadv ; _ => [] } advpreneg : SAdvPos -> Str = \ap -> case ap of { SAPreNeg => s.sadv ; _ => [] } ;
detpren : DetPos -> { s, sp : Case => Str } = \dp -> case dp of { DPreN => s.det; _ => { s,sp = \\_ => [] } } ;
detpostn : DetPos -> { s, sp : Case => Str } = \dp -> case dp of { DPostN => s.det ; _ => { s , sp = \\_ => [] } } ;
verbins : VPos -> ResLat.AdvPos => Str = \vp -> case vp of { VInS => s.v ; _ => \\_ => [] } ;
verbreg : VPos -> ResLat.AdvPos => Str = \vp -> case vp of { VReg => s.v ; _ => \\_ => [] } ;
complprev : ComplPos -> Str = \cp -> case cp of { CPreV => s.compl ; _ => [] } ;
complpostv : ComplPos -> Str = \cp -> case cp of { CPostV => s.compl ; _ => [] }
in in
-- sap is the position of the sentence adverbial -- sadvpos is the position of the sentence adverbial
-- ap is the position of the adverb -- advpos is the position of the adverb
-- cp is the position of the verb complement -- detpos is the position of the determiner (relative to the noun)
\\sap,ap,cp,order => case order of { -- vpos is the position of the main verb (either regular or interleaved)
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; -- complosp is the position of the verb complement
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; \\sadvpos,advpos,detpos,verbpos,complpos,order => case order of {
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 ; SVO =>
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; s.t.s ++ s.p.s ++
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 ; advpres sadvpos ++ (detpren detpos).s ! Nom ++ s.s ! advpos ++ (verbins verbpos) ! advpos ++ (detpostn detpos).s ! Nom ++ (detpren detpos).sp ! Nom ++
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 advpreneg sadvpos ++ s.neg ! advpos ++
advprev sadvpos ++ (complprev complpos) ++ (verbreg verbpos) ! advpos ++ (complpostv complpos) ++
advpreo sadvpos ++ s.o ! advpos;
VSO =>
s.t.s ++ s.p.s ++
advpreneg sadvpos ++ s.neg ! advpos ++
advprev sadvpos ++ (complprev complpos) ++ (verbreg verbpos) ! advpos ++ (complpostv complpos) ++
advpres sadvpos ++ (detpren detpos).s ! Nom ++ s.s ! advpos ++ (verbins verbpos) ! advpos ++ (detpostn detpos).s ! Nom ++ (detpren detpos).sp ! Nom ++
advpreo sadvpos ++ s.o ! advpos;
VOS =>
s.t.s ++ s.p.s ++
advpreneg sadvpos ++ s.neg ! advpos ++
advprev sadvpos ++ (complprev complpos) ++ (verbreg verbpos) ! advpos ++ (complpostv complpos) ++
advpreo sadvpos ++ s.o ! advpos ++
advpres sadvpos ++ (detpren detpos).s ! Nom ++ s.s ! advpos ++ (verbins verbpos) ! advpos ++ (detpostn detpos).s ! Nom ++ (detpren detpos).sp ! Nom ;
OSV =>
s.t.s ++ s.p.s ++
advpreo sadvpos ++ s.o ! advpos ++
advpres sadvpos ++ (detpren detpos).s ! Nom ++ s.s ! advpos ++ (verbins verbpos) ! advpos ++ (detpostn detpos).s ! Nom ++ (detpren detpos).sp ! Nom++
advpreneg sadvpos ++ s.neg ! advpos ++
advprev sadvpos ++ (complprev complpos) ++ (verbreg verbpos) ! advpos ++ (complpostv complpos) ;
OVS =>
s.t.s ++ s.p.s ++
advpreo sadvpos ++ s.o ! advpos ++
advpreneg sadvpos ++ s.neg ! advpos ++
advprev sadvpos ++ (complprev complpos) ++ (verbreg verbpos) ! advpos ++ (complpostv complpos) ++
advpres sadvpos ++ (detpren detpos).s ! Nom ++ s.s ! advpos ++ (verbins verbpos) ! advpos ++ (detpostn detpos).s ! Nom ++ (detpren detpos).sp ! Nom ;
SOV =>
s.t.s ++ s.p.s ++
advpres sadvpos ++ (detpren detpos).s ! Nom ++ s.s ! advpos ++ (verbins verbpos) ! advpos ++ (detpostn detpos).s ! Nom ++ (detpren detpos).sp ! Nom ++
advpreo sadvpos ++ s.o ! advpos ++
advpreneg sadvpos ++ s.neg ! advpos ++
advprev sadvpos ++ (complprev complpos) ++ (verbreg verbpos) ! advpos ++ (complpostv complpos)
} ; } ;
defaultSentence : Sentence -> Order => Str = \s -> combineSentence s ! SAPreS ! APreV ! DPreN ! VReg ! CPreV ;
-- questions -- questions
mkQuestion : SS -> Clause -> QClause = \ss,cl -> { mkQuestion : SS -> Clause -> QClause = \ss,cl -> {
s = \\tense,anter,pol,form => case form of { s = \\tense,anter,pol,form => case form of {
QDir => ss.s ++ (combineSentence (combineClause cl tense anter pol VQFalse)) ! SPreS ! PreS ! CPreV ! OVS ; QDir => ss.s ++ (defaultSentence (combineClause cl tense anter pol VQFalse)) ! OVS ;
QIndir => ss.s ++ (combineSentence (combineClause cl tense anter pol VQFalse)) ! SPreO ! PreO ! CPreV ! OSV QIndir => ss.s ++ (combineSentence (combineClause cl tense anter pol VQFalse)) ! SAPreO ! APreO ! DPreN ! VReg ! CPreV ! OSV
} }
}; };

View File

@@ -52,8 +52,8 @@ concrete SentenceLat of Sentence = CatLat ** open Prelude, ResLat in {
{ {
s = let qs = combineClause cl t t.a p VQTrue in s = let qs = combineClause cl t t.a p VQTrue in
\\q => case q of { \\q => case q of {
QDir => cl.q ++ combineSentence qs ! SPreS ! PreV ! CPostV ! SVO ; -- t.s ++ p.s ++ cl.q ++ cl.s ! PreV ++ cl.v ! t.t ! t.a ! VQTrue ! PreV ! CPostV ++ cl.o ! PreV ; QDir => cl.q ++ defaultSentence qs ! SVO ; -- t.s ++ p.s ++ cl.q ++ cl.s ! PreV ++ cl.v ! t.t ! t.a ! VQTrue ! PreV ! CPostV ++ cl.o ! PreV ;
QIndir => cl.q ++ combineSentence qs ! SPreS ! PreV ! CPostV ! SOV -- t.s ++ p.s ++ cl.q ++ cl.s ! PreV ++ cl.o ! PreV ++ cl.v ! t.t ! t.a ! VQTrue ! PreV ! CPostV QIndir => cl.q ++ defaultSentence qs ! SOV -- t.s ++ p.s ++ cl.q ++ cl.s ! PreV ++ cl.o ! PreV ++ cl.v ! t.t ! t.a ! VQTrue ! PreV ! CPostV
} }
} ; } ;
-- UseRCl : Temp -> Pol -> RCl -> RS ; -- UseRCl : Temp -> Pol -> RCl -> RS ;

View File

@@ -20,7 +20,7 @@ concrete VerbLat of Verb = CatLat ** open (S=StructuralLat),ResLat,IrregLat,Extr
ComplVS vs s = -- insertObj ( dummyNP (S.that_Subj.s ++ s.s ! PreS)) Nom_Prep (predV v) ; ComplVS vs s = -- insertObj ( dummyNP (S.that_Subj.s ++ s.s ! PreS)) Nom_Prep (predV v) ;
vs ** { vs ** {
s = \\af,qf => vs.act ! af ; s = \\af,qf => vs.act ! af ;
compl = \\ag => combineSentence s ! SPreS ! PreV ! CPostV ! SOV ; -- s.s ! QIndir ; compl = \\ag => defaultSentence s ! SOV ; -- s.s ! QIndir ;
adv = [] ; adv = [] ;
obj = [] obj = []
} ; } ;