mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
optimizing Fin
This commit is contained in:
@@ -78,7 +78,7 @@ lincat
|
|||||||
|
|
||||||
S = {s : Str} ;
|
S = {s : Str} ;
|
||||||
Cl = Clause ;
|
Cl = Clause ;
|
||||||
-- = {s : Bool => SForm => Str} ;
|
-- = {s : Str ; s1,s2 : Bool => SForm => Str ; s3 : Str} ;
|
||||||
|
|
||||||
Slash = Sentence ** {s2 : Str ; c : Case} ;
|
Slash = Sentence ** {s2 : Str ; c : Case} ;
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ lincat
|
|||||||
IP = {s : NPForm => Str ; n : Number} ;
|
IP = {s : NPForm => Str ; n : Number} ;
|
||||||
IDet = {s : Gender => Case => Str ; n : Number} ;
|
IDet = {s : Gender => Case => Str ; n : Number} ;
|
||||||
IAdv = {s : Str} ;
|
IAdv = {s : Str} ;
|
||||||
QCl = {s : Bool => SForm => Str} ;
|
QCl = Clause ;
|
||||||
QS = {s : Str} ;
|
QS = {s : Str} ;
|
||||||
Imp = {s : Number => Str} ;
|
Imp = {s : Number => Str} ;
|
||||||
Phr = {s : Str} ;
|
Phr = {s : Str} ;
|
||||||
|
|||||||
@@ -51,22 +51,22 @@ concrete ClauseFin of Clause = CategoriesFin **
|
|||||||
sats2clause (
|
sats2clause (
|
||||||
insertComplement
|
insertComplement
|
||||||
(mkSats subj verb)
|
(mkSats subj verb)
|
||||||
(vp.s ! True ! VIInfinit Simul)
|
(vp.s ! VIInfinit ! subj.n)
|
||||||
) ;
|
) ;
|
||||||
SPredObjV2V subj verb obj vp =
|
SPredObjV2V subj verb obj vp =
|
||||||
sats2clause (
|
sats2clause (
|
||||||
insertComplement
|
insertComplement
|
||||||
(mkSatsObject subj verb obj)
|
(mkSatsObject subj verb obj)
|
||||||
(vp.s ! True ! VIInfinit Simul)
|
(vp.s ! VIInfinit ! subj.n)
|
||||||
) ;
|
) ;
|
||||||
SPredSubjV2V subj verb obj vp =
|
SPredSubjV2V subj verb obj vp =
|
||||||
sats2clause (
|
sats2clause (
|
||||||
insertComplement
|
insertComplement
|
||||||
(mkSatsObject subj verb obj)
|
(mkSatsObject subj verb obj)
|
||||||
(vp.s ! True ! VIInfinit Simul)
|
(vp.s ! VIInfinit ! subj.n)
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
SPredProgVP np vp = sats2clause (progressiveSats np vp) ;
|
----- SPredProgVP np vp = sats2clause (progressiveSats np vp) ;
|
||||||
|
|
||||||
SPredAP subj adj =
|
SPredAP subj adj =
|
||||||
sats2clause (mkSatsCopula subj (complAdjPhrase subj.n adj)) ;
|
sats2clause (mkSatsCopula subj (complAdjPhrase subj.n adj)) ;
|
||||||
|
|||||||
@@ -985,7 +985,7 @@ caseTable : Number -> CommonNoun -> Case => Str = \n,cn ->
|
|||||||
tulleena = Predef.tk 2 tullut + ("een" + a) ;
|
tulleena = Predef.tk 2 tullut + ("een" + a) ;
|
||||||
tulleen = (noun2adj (nhn (sRae tullut tulleena))).s ;
|
tulleen = (noun2adj (nhn (sRae tullut tulleena))).s ;
|
||||||
tullun = (noun2adj (nhn (sKukko tultu tullun (tultu + ("j"+a))))).s ;
|
tullun = (noun2adj (nhn (sKukko tultu tullun (tultu + ("j"+a))))).s ;
|
||||||
tulema = Predef.tk 3 tulevat + "m" + a ;
|
tulema = tuje + "m" + a ;
|
||||||
vat = "v" + a + "t"
|
vat = "v" + a + "t"
|
||||||
in
|
in
|
||||||
{s = table {
|
{s = table {
|
||||||
@@ -1022,7 +1022,7 @@ caseTable : Number -> CommonNoun -> Case => Str = \n,cn ->
|
|||||||
Inf3Elat => tulema + "st" + a ;
|
Inf3Elat => tulema + "st" + a ;
|
||||||
Inf3Illat => tulema + a + "n" ;
|
Inf3Illat => tulema + a + "n" ;
|
||||||
Inf3Adess => tulema + "ll" + a ;
|
Inf3Adess => tulema + "ll" + a ;
|
||||||
Inf3Ablat => tulema + "tt" + a
|
Inf3Abess => tulema + "tt" + a
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|||||||
@@ -90,9 +90,15 @@ lin
|
|||||||
UseA2S x = x ;
|
UseA2S x = x ;
|
||||||
UseA2V x = x ;
|
UseA2V x = x ;
|
||||||
|
|
||||||
UseCl tp cl = {s = tp.s ++ cl.s ! tp.b ! VFinite SDecl tp.t tp.a} ;
|
UseCl tp cl = {s =
|
||||||
UseQCl tp cl = {s = tp.s ++ cl.s ! tp.b ! VFinite SQuest tp.t tp.a} ;
|
tp.s ++ cl.s ++ cl.s1 ! tp.b ! VFinite tp.t tp.a ++
|
||||||
UseRCl tp cl = {s = \\n => tp.s ++ cl.s ! tp.b ! VFinite SDecl tp.t tp.a ! n} ;
|
cl.s2 ! tp.b ! VFinite tp.t tp.a ++ cl.s3
|
||||||
|
} ;
|
||||||
|
UseQCl tp cl = {s =
|
||||||
|
tp.s ++ questPart (cl.s1 ! tp.b ! VFinite tp.t tp.a) ++ cl.s ++
|
||||||
|
cl.s2 ! tp.b ! VFinite tp.t tp.a ++ cl.s3
|
||||||
|
} ;
|
||||||
|
UseRCl tp cl = {s = \\n => tp.s ++ cl.s ! tp.b ! VFinite tp.t tp.a ! n} ;
|
||||||
|
|
||||||
PosTP t a = {s = t.s ++ a.s ; b = True ; t = t.t ; a = a.a} ;
|
PosTP t a = {s = t.s ++ a.s ; b = True ; t = t.t ; a = a.a} ;
|
||||||
NegTP t a = {s = t.s ++ a.s ; b = False ; t = t.t ; a = a.a} ;
|
NegTP t a = {s = t.s ++ a.s ; b = False ; t = t.t ; a = a.a} ;
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ oper
|
|||||||
Tense = Present | Past | Future | Conditional ;
|
Tense = Present | Past | Future | Conditional ;
|
||||||
Anteriority = Simul | Anter ;
|
Anteriority = Simul | Anter ;
|
||||||
|
|
||||||
SForm = VFinite SType Tense Anteriority ;
|
SForm = VFinite Tense Anteriority ;
|
||||||
|
|
||||||
SType = SDecl | SQuest ;
|
SType = SDecl | SQuest ;
|
||||||
|
|
||||||
@@ -517,7 +517,7 @@ oper
|
|||||||
SVIForm = SCl SForm | SVI VIForm ;
|
SVIForm = SCl SForm | SVI VIForm ;
|
||||||
|
|
||||||
oper
|
oper
|
||||||
Clause : Type = {s : Bool => SForm => Str} ;
|
Clause : Type = {s : Str ; s1,s2 : Bool => SForm => Str ; s3 : Str} ;
|
||||||
VerbPhraseInf : Type = {s : VIForm => Number => Str ; sc : Case} ;
|
VerbPhraseInf : Type = {s : VIForm => Number => Str ; sc : Case} ;
|
||||||
VerbClauseInf : Type = {s : Bool => Anteriority => VIForm => Number => Str ; sc : Case} ;
|
VerbClauseInf : Type = {s : Bool => Anteriority => VIForm => Number => Str ; sc : Case} ;
|
||||||
|
|
||||||
@@ -528,24 +528,18 @@ oper
|
|||||||
inf : Str
|
inf : Str
|
||||||
} ;
|
} ;
|
||||||
obj : Bool => SVIForm => Str ;
|
obj : Bool => SVIForm => Str ;
|
||||||
comp : Str ;
|
comp : Str
|
||||||
vpi : Bool => VerbPhraseInf
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
sats2clause : Sats -> Clause = \sats ->
|
sats2clause : Sats -> Clause = \sats ->
|
||||||
{s = \\b,sf =>
|
let
|
||||||
let
|
subj = sats.subj ;
|
||||||
subj = sats.subj ;
|
pred = sats.pred ;
|
||||||
pred = sats.pred ! b ! sf ;
|
in
|
||||||
fin = pred.fin ;
|
{s = subj ;
|
||||||
inf = pred.inf ;
|
s1 = \\b,sf => (pred ! b ! sf).fin ;
|
||||||
obj = sats.obj ! b ! (SCl sf) ;
|
s2 = \\b,sf => (pred ! b ! sf).inf ++ sats.obj ! b ! (SCl sf) ;
|
||||||
comp = sats.comp
|
s3 = sats.comp
|
||||||
in
|
|
||||||
case sf of {
|
|
||||||
VFinite SQuest _ _ => questPart fin ++ subj ++ inf ++ obj ++ comp ;
|
|
||||||
_ => subj ++ fin ++ inf ++ obj ++ comp
|
|
||||||
}
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
{-
|
{-
|
||||||
@@ -574,11 +568,7 @@ oper
|
|||||||
{subj = subj.s ! NPCase sc ; -- "minusta tulee poliisi"
|
{subj = subj.s ! NPCase sc ; -- "minusta tulee poliisi"
|
||||||
pred = \\b,sf => vi b (SCl sf) ;
|
pred = \\b,sf => vi b (SCl sf) ;
|
||||||
obj = \\_,_ => [] ;
|
obj = \\_,_ => [] ;
|
||||||
comp = [] ;
|
comp = []
|
||||||
vpi = \\b => {
|
|
||||||
s = \\f,n => let vp = vi b (SVI f) in vp.fin ++ vp.inf ;
|
|
||||||
sc = sc
|
|
||||||
}
|
|
||||||
} ;
|
} ;
|
||||||
{- ----
|
{- ----
|
||||||
progressiveSats : NounPhrase -> VerbPhraseInf -> Sats = \subj,vp ->
|
progressiveSats : NounPhrase -> VerbPhraseInf -> Sats = \subj,vp ->
|
||||||
@@ -614,8 +604,7 @@ oper
|
|||||||
inf = spred.inf
|
inf = spred.inf
|
||||||
} ;
|
} ;
|
||||||
obj = \\b,f => sats.obj ! b ! f ++ pPosit prep pos (obj.s ! complCase b c f) ;
|
obj = \\b,f => sats.obj ! b ! f ++ pPosit prep pos (obj.s ! complCase b c f) ;
|
||||||
comp = sats.comp ;
|
comp = sats.comp
|
||||||
vpi = sats.vpi
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
insertComplement : Sats -> Str -> Sats =
|
insertComplement : Sats -> Str -> Sats =
|
||||||
@@ -623,8 +612,7 @@ oper
|
|||||||
{subj = sats.subj ;
|
{subj = sats.subj ;
|
||||||
pred = sats.pred ;
|
pred = sats.pred ;
|
||||||
obj = sats.obj ;
|
obj = sats.obj ;
|
||||||
comp = sats.comp ++ comp ;
|
comp = sats.comp ++ comp
|
||||||
vpi = sats.vpi
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
complCase : Bool -> ComplCase -> SVIForm -> NPForm = \b,c,v -> case c of {
|
complCase : Bool -> ComplCase -> SVIForm -> NPForm = \b,c,v -> case c of {
|
||||||
@@ -641,21 +629,21 @@ oper
|
|||||||
inflectVerb : Verb -> Number -> Person -> Bool -> SVIForm -> {fin, inf : Str} =
|
inflectVerb : Verb -> Number -> Person -> Bool -> SVIForm -> {fin, inf : Str} =
|
||||||
\verb,n,p,b,sf ->
|
\verb,n,p,b,sf ->
|
||||||
let
|
let
|
||||||
vs = verb.s ;
|
vs : VAuxForm => Str = \\f => verb.s ! verbAuxForm f ;
|
||||||
olla = verbOlla.s ;
|
olla = verbAuxOlla ;
|
||||||
tulla = (v2v (vJuosta "tulla" "tulen" "tullut" "tultu")).s ;
|
tulla = table {ANF f => verbAuxNegTulla ! f ; _ => []} ;
|
||||||
eis = verbEi.s ;
|
eis = table {ANF f => verbAuxNegEi ! f ; _ => []} ;
|
||||||
part = PastPartAct (AN (NCase n Nom)) ;
|
part = APastPart n ;
|
||||||
abess = vs ! Inf3Abess ;
|
abess = vs ! AInf3Abess ;
|
||||||
illat = vs ! Inf3Illat ;
|
illat = vs ! AInf3Illat ;
|
||||||
ei : Anteriority -> VForm -> VForm -> {fin,inf : Str} =
|
ei : Anteriority -> VAuxForm -> VAuxForm -> {fin,inf : Str} =
|
||||||
\a,vf,neg -> case <b,a> of {
|
\a,vf,neg -> case <b,a> of {
|
||||||
<True, Simul> => {fin = vs ! vf ; inf = []} ;
|
<True, Simul> => {fin = vs ! vf ; inf = []} ;
|
||||||
<True, Anter> => {fin = olla ! vf ; inf = vs ! part} ;
|
<True, Anter> => {fin = olla ! vf ; inf = vs ! part} ;
|
||||||
<False,Simul> => {fin = eis ! vf ; inf = vs ! neg} ;
|
<False,Simul> => {fin = eis ! vf ; inf = vs ! neg} ;
|
||||||
<False,Anter> => {fin = eis ! vf ; inf = olla ! neg ++ vs ! part}
|
<False,Anter> => {fin = eis ! vf ; inf = olla ! neg ++ vs ! part}
|
||||||
} ;
|
} ;
|
||||||
fut : Anteriority -> VForm -> VForm -> {fin,inf : Str} =
|
fut : Anteriority -> VAuxForm -> VAuxForm -> {fin,inf : Str} =
|
||||||
\a,vf,neg -> case <b,a> of {
|
\a,vf,neg -> case <b,a> of {
|
||||||
<True, Simul> => {fin = tulla ! vf ; inf = illat} ;
|
<True, Simul> => {fin = tulla ! vf ; inf = illat} ;
|
||||||
<True, Anter> => {fin = olla ! vf ; inf = tulla ! part ++ illat} ;
|
<True, Anter> => {fin = olla ! vf ; inf = tulla ! part ++ illat} ;
|
||||||
@@ -665,7 +653,9 @@ oper
|
|||||||
} ;
|
} ;
|
||||||
inf : VIForm -> Anteriority -> {fin,inf : Str} =
|
inf : VIForm -> Anteriority -> {fin,inf : Str} =
|
||||||
\if,a ->
|
\if,a ->
|
||||||
let i = case if of {
|
let i = AInf ---- is this ever needed?
|
||||||
|
{-
|
||||||
|
case if of {
|
||||||
VIInf3Iness => Inf3Iness ;
|
VIInf3Iness => Inf3Iness ;
|
||||||
VIInf3Elat => Inf3Elat ;
|
VIInf3Elat => Inf3Elat ;
|
||||||
VIInf3Illat => Inf3Illat ;
|
VIInf3Illat => Inf3Illat ;
|
||||||
@@ -673,6 +663,7 @@ oper
|
|||||||
VIInf3Abess => Inf3Abess ;
|
VIInf3Abess => Inf3Abess ;
|
||||||
_ => Inf --- not used for imperative
|
_ => Inf --- not used for imperative
|
||||||
}
|
}
|
||||||
|
-}
|
||||||
in
|
in
|
||||||
case <b,a> of {
|
case <b,a> of {
|
||||||
<True, Simul> => {fin = vs ! i ; inf = []} ;
|
<True, Simul> => {fin = vs ! i ; inf = []} ;
|
||||||
@@ -682,23 +673,69 @@ oper
|
|||||||
} ;
|
} ;
|
||||||
älä : Number -> {fin,inf : Str} =
|
älä : Number -> {fin,inf : Str} =
|
||||||
\nu -> case b of {
|
\nu -> case b of {
|
||||||
True => {fin = vs ! Imper nu ; inf = []} ;
|
True => {fin = vs ! ANF (AImper nu) ; inf = []} ;
|
||||||
False => {fin = eis ! Imper nu ;
|
False => {fin = eis ! ANF (AImper nu) ;
|
||||||
inf = vs ! case nu of {
|
inf = vs ! case nu of {
|
||||||
Sg => Imper n ;
|
Sg => ANF (AImper n) ;
|
||||||
Pl => ImpNegPl}
|
Pl => AImpNegPl}
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
in case sf of {
|
in case sf of {
|
||||||
SCl (VFinite _ Past a) => ei a (Impf n p) (part) ;
|
SCl (VFinite Present a) => ei a (ANF (APres n p)) (ANF (AImper Sg)) ;
|
||||||
SCl (VFinite _ Conditional a) => ei a (Cond n p) (Cond Sg P3) ;
|
SCl (VFinite Past a) => ei a (AImpf n p) (part) ;
|
||||||
SCl (VFinite _ Present a) => ei a (Pres n p) (Imper Sg) ;
|
SCl (VFinite Conditional a) => ei a (ACond n p) (ACond Sg P3) ;
|
||||||
SCl (VFinite _ Future a) => fut a (Pres n p) (Imper Sg) ;
|
SCl (VFinite Future a) => fut a (ANF (APres n p)) (ANF (AImper Sg)) ;
|
||||||
SVI (VIImperat ) => älä n ;
|
SVI (VIImperat ) => älä n ;
|
||||||
SVI i => inf i Simul ---- Anter
|
SVI i => inf i Simul ---- Anter
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
--- these are the only forms needed in auxiliary positions.
|
||||||
|
|
||||||
|
param
|
||||||
|
VAuxForm =
|
||||||
|
ANF VAuxNegForm
|
||||||
|
| AImpf Number Person
|
||||||
|
| ACond Number Person
|
||||||
|
| AInf
|
||||||
|
| APastPart Number
|
||||||
|
| AImpNegPl
|
||||||
|
| AInf3Illat
|
||||||
|
| AInf3Abess
|
||||||
|
;
|
||||||
|
|
||||||
|
VAuxNegForm =
|
||||||
|
APres Number Person
|
||||||
|
| AImper Number
|
||||||
|
| AImperP3 Number
|
||||||
|
| AImperP1Pl
|
||||||
|
;
|
||||||
|
|
||||||
|
oper
|
||||||
|
|
||||||
|
verbAuxNegEi : VAuxNegForm => Str = \\f => verbEi.s ! verbAuxNegForm f ;
|
||||||
|
verbAuxOlla : VAuxForm => Str = \\f => verbOlla.s ! verbAuxForm f ;
|
||||||
|
verbAuxNegTulla : VAuxNegForm => Str = \\f =>
|
||||||
|
(v2v (vJuosta "tulla" "tulen" "tullut" "tultu")).s ! verbAuxNegForm f ;
|
||||||
|
|
||||||
|
verbAuxForm : VAuxForm -> VForm = \f -> case f of {
|
||||||
|
ANF a => verbAuxNegForm a ;
|
||||||
|
AImpf n p => Impf n p ;
|
||||||
|
ACond n p => Cond n p ;
|
||||||
|
AInf => Inf ;
|
||||||
|
APastPart n => PastPartAct (AN (NCase n Nom)) ;
|
||||||
|
AImpNegPl => ImpNegPl ;
|
||||||
|
AInf3Illat => Inf3Illat ;
|
||||||
|
AInf3Abess => Inf3Abess
|
||||||
|
} ;
|
||||||
|
|
||||||
|
verbAuxNegForm : VAuxNegForm -> VForm = \f -> case f of {
|
||||||
|
APres n p => Pres n p ;
|
||||||
|
AImper n => Imper n ;
|
||||||
|
AImperP3 n => ImperP3 n ;
|
||||||
|
AImperP1Pl => ImperP1Pl
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
-- Verb phrases are discontinuous: the two parts of a verb phrase are
|
-- Verb phrases are discontinuous: the two parts of a verb phrase are
|
||||||
-- (s) an inflected verb, (s2) a complement.
|
-- (s) an inflected verb, (s2) a complement.
|
||||||
@@ -1002,7 +1039,7 @@ oper
|
|||||||
-- "luku x siten että x on parillinen".
|
-- "luku x siten että x on parillinen".
|
||||||
|
|
||||||
relSuch : Clause -> RelClause = \A ->
|
relSuch : Clause -> RelClause = \A ->
|
||||||
{s = \\b,s,_ => advSiten ++ conjEtta ++ A.s ! b ! s} ;
|
{s = \\b,s,_ => A.s ++ advSiten ++ conjEtta ++ A.s1 ! b ! s ++ A.s2 ! b ! s ++ A.s3} ;
|
||||||
|
|
||||||
-- N.B. the construction "sellainen että" is not possible with the present
|
-- N.B. the construction "sellainen että" is not possible with the present
|
||||||
-- typing of the relative clause, since it should also be inflected in
|
-- typing of the relative clause, since it should also be inflected in
|
||||||
@@ -1128,7 +1165,11 @@ oper
|
|||||||
|
|
||||||
questAdverbial : IntAdverb -> Clause -> QuestClause =
|
questAdverbial : IntAdverb -> Clause -> QuestClause =
|
||||||
\miksi, cl ->
|
\miksi, cl ->
|
||||||
{s = \\b,f => miksi.s ++ cl.s ! b ! f} ;
|
{s = miksi.s ++ cl.s ;
|
||||||
|
s1 = cl.s1 ;
|
||||||
|
s2 = cl.s2 ;
|
||||||
|
s3 = cl.s3
|
||||||
|
} ;
|
||||||
|
|
||||||
--2 Imperatives
|
--2 Imperatives
|
||||||
--
|
--
|
||||||
|
|||||||
Reference in New Issue
Block a user