1
0
forked from GitHub/gf-core

simple problem tracing

This commit is contained in:
aarne
2005-11-24 09:25:39 +00:00
parent b29877c590
commit e583ecc830
64 changed files with 8932 additions and 5 deletions

View File

@@ -1,36 +0,0 @@
abstract Cat = {
cat
S ;
Cl ;
QS ;
QCl ;
Slash ;
VP ;
AP ;
Comp ;
V ;
V2 ;
V3 ;
VV ;
VS ;
VQ ;
Adv ;
CN ;
N ;
N2 ;
N3 ;
NP ;
PN ;
Pron ;
Det ;
Predet ;
Quant ;
Num ;
}

View File

@@ -1,31 +0,0 @@
concrete CatEng of Cat = open ResEng in {
lincat
S = {s : Str} ;
Cl = {s : Tense => Anteriority => Polarity => Ord => Str} ;
Slash = {s : Tense => Anteriority => Polarity => Ord => Str} ** {c2 : Str} ;
VP = {
s : Tense => Anteriority => Polarity => Ord => Agr => {fin, inf : Str} ;
s2 : Agr => Str
} ;
AP = {s : Str} ;
Comp = {s : Agr => Str} ;
V, VS, VQ = Verb ; -- = {s : VForm => Str} ;
V2, VV = Verb ** {c2 : Str} ;
V3 = Verb ** {c2, c3 : Str} ;
Adv = {s : Str} ;
Det, Quant = {s : Str ; n : Number} ;
Predet, Num = {s : Str} ;
CN,N = {s : Number => Case => Str} ;
PN = {s : Case => Str} ;
Pron, NP = {s : Case => Str ; a : Agr} ;
N2 = {s : Number => Case => Str} ** {c2 : Str} ;
N3 = {s : Number => Case => Str} ** {c2,c3 : Str} ;
}

View File

@@ -1,18 +0,0 @@
abstract Lex = Cat ** {
fun
walk_V : V ;
kill_V2 : V2 ;
show_V3 : V3 ;
want_VV : VV ;
claim_VS : VS ;
ask_VQ : VQ ;
big_AP : AP ;
dog_N : N ;
son_N2 : N2 ;
way_N3 : N3 ;
i_Pron, he_Pron, we_Pron : Pron ;
here_Adv : Adv ;
}

View File

@@ -1,24 +0,0 @@
concrete LexEng of Lex = CatEng ** open ResEng in {
lin
walk_V = regV "walk" ;
kill_V2 = regV "kill" ** {c2 = []} ;
show_V3 = regV "show" ** {c2 = [] ; c3 = "to"} ;
want_VV = regV "want" ** {c2 = "to"} ;
claim_VS = regV "claim" ;
ask_VQ = regV "ask" ;
big_AP = {s = "big"} ;
dog_N = regN "dog" ;
son_N2 = regN "son" ** {c2 = "of"} ;
way_N3 = regN "way" ** {c2 = "from" ; c3 = "to"} ;
here_Adv = {s = "here"} ;
-- structural
i_Pron = mkNP "I" "me" "my" Sg P1 ;
he_Pron = mkNP "he" "him" "his" Sg P3 ;
we_Pron = mkNP "we" "us" "our" Pl P1 ;
}

View File

@@ -1,38 +0,0 @@
abstract Noun = Cat ** {
fun
DetCN : Det -> CN -> NP ;
UsePN : PN -> NP ;
UsePron : Pron -> NP ;
MkDet : Predet -> Quant -> Num -> Det ;
PossPronSg, PossPronPl : Pron -> Quant ; --- PossNP not in romance
NoNum : Num ;
NumInt : Int -> Num ;
NoPredet : Predet ;
DefSg, DefPl : Quant ;
IndefSg, IndefPl : Quant ;
-- Num_Pl ::= Ordinal ;
-- Num_Pl ::= Numeral ;
ComplN2 : N2 -> NP -> CN ;
ComplN3 : N3 -> NP -> N2 ;
AdjCN : AP -> CN -> CN ;
SentCN : CN -> S -> CN ;
QuestCN : CN -> QS -> CN ;
UseN : N -> CN ;
-- structural
only_Predet : Predet ;
this_Quant : Quant ;
} ;

View File

@@ -1,36 +0,0 @@
concrete NounEng of Noun = CatEng ** open ResEng in {
flags optimize=all_subs ;
lin
DetCN det cn = {s = \\c => det.s ++ cn.s ! det.n ! c} ** agrP3 det.n ;
UsePN pn = pn ** agrP3 Sg ;
UsePron p = p ; --- causes mcfg error, even if expanded
MkDet pred quant num = {
s = pred.s ++ quant.s ++ num.s ;
n = quant.n
} ;
PossPronSg p = {s = p.s ! Gen ; n = Sg} ;
PossPronPl p = {s = p.s ! Gen ; n = Pl} ;
NoNum, NoPredet = {s = []} ;
NumInt n = n ;
DefSg = {s = "the" ; n = Sg} ;
DefPl = {s = "the" ; n = Pl} ;
IndefSg = {s = "a" ; n = Sg} ;
IndefPl = {s = [] ; n = Pl} ;
UseN n = n ;
ComplN2 f x = {s = \\n,c => f.s ! n ! Nom ++ f.c2 ++ x.s ! c} ;
ComplN3 f x = {s = \\n,c => f.s ! n ! Nom ++ f.c2 ++ x.s ! c ; c2 = f.c3} ;
-- structural
only_Predet = {s = "only"} ;
}

View File

@@ -1,13 +0,0 @@
resource ParamX = {
param
Number = Sg | Pl ;
Person = P1 | P2 | P3 ;
Anteriority = Simul | Anter ;
Tense = Pres | Past | Fut | Cond ;
Polarity = Pos | Neg ;
QForm = QDir | QIndir ;
}

View File

@@ -1,161 +0,0 @@
resource ResEng = ParamX ** {
param
Case = Nom | Acc | Gen ;
VForm = VInf | VPres | VPast | VPPart | VPresPart ;
Ord = ODir | OQuest ;
oper
Agr = {n : Number ; p : Person} ;
agrP3 : Number -> {a : Agr} = \n -> {a = {n = n ; p = P3}} ;
regN : Str -> {s : Number => Case => Str} = \car -> {
s = table {
Sg => table {
Gen => car + "'s" ;
_ => car
} ;
Pl => table {
Gen => car + "s'" ;
_ => car + "s"
}
}
} ;
regV : Str -> {s : VForm => Str} = \walk -> {
s = table {
VInf => walk ;
VPres => walk + "s" ;
VPast | VPPart => walk + "ed" ;
VPresPart => walk + "ing"
}
} ;
mkNP : (i,me,my : Str) -> Number -> Person -> {s : Case => Str ; a : Agr} =
\i,me,my,n,p -> {
s = table {
Nom => i ;
Acc => me ;
Gen => my
} ;
a = {
n = n ;
p = p
}
} ;
Verb : Type = {
s : VForm => Str
} ;
VP : Type = {
s : Tense => Anteriority => Polarity => Ord => Agr => {fin, inf : Str} ;
s2 : Agr => Str
} ;
predV : Verb -> VP = \verb -> {
s = \\t,ant,b,ord,agr =>
let
inf = verb.s ! VInf ;
fin = presVerb verb agr ;
past = verb.s ! VPast ;
part = verb.s ! VPPart ;
vf : Str -> Str -> {fin, inf : Str} = \x,y ->
{fin = x ; inf = y} ;
in
case <t,ant,b,ord> of {
<Pres,Simul,Pos,ODir> => vf fin [] ;
<Pres,Simul,Pos,OQuest> => vf (does agr) inf ;
<Pres,Simul,Neg,_> => vf (doesnt agr) inf ;
<Pres,Anter,Pos,_> => vf (have agr) part ;
<Pres,Anter,Neg,_> => vf (havent agr) part ;
<Past,Simul,Pos,ODir> => vf past [] ;
<Past,Simul,Pos,OQuest> => vf "did" inf ;
<Past,Simul,Neg,_> => vf "didn't" inf ;
<Past,Anter,Pos,_> => vf "had" part ;
<Past,Anter,Neg,_> => vf "hadn't" part ;
<Fut, Simul,Pos,_> => vf "will" inf ;
<Fut, Simul,Neg,_> => vf "won't" inf ;
<Fut, Anter,Pos,_> => vf "will" ("have" ++ part) ;
<Fut, Anter,Neg,_> => vf "won't" ("have" ++ part) ;
<Cond,Simul,Pos,_> => vf "would" inf ;
<Cond,Simul,Neg,_> => vf "wouldn't" inf ;
<Cond,Anter,Pos,_> => vf "would" ("have" ++ part) ;
<Cond,Anter,Neg,_> => vf "wouldn't" ("have" ++ part)
} ;
s2 = \\_ => []
} ;
predAux : Aux -> VP = \verb -> {
s = \\t,ant,b,ord,agr =>
let
inf = verb.inf ;
fin = verb.pres ! b ! agr ;
past = verb.past ! b ! agr ;
part = verb.ppart ;
vf : Str -> Str -> {fin, inf : Str} = \x,y ->
{fin = x ; inf = y} ;
in
case <t,ant,b,ord> of {
<Pres,Simul,_, _> => vf fin [] ;
<Pres,Anter,Pos,_> => vf (have agr) part ;
<Pres,Anter,Neg,_> => vf (havent agr) part ;
<Past,Simul,_, _> => vf fin [] ;
<Past,Anter,Pos,_> => vf "had" part ;
<Past,Anter,Neg,_> => vf "hadn't" part ;
<Fut, Simul,Pos,_> => vf "will" inf ;
<Fut, Simul,Neg,_> => vf "won't" inf ;
<Fut, Anter,Pos,_> => vf "will" ("have" ++ part) ;
<Fut, Anter,Neg,_> => vf "won't" ("have" ++ part) ;
<Cond,Simul,Pos,_> => vf "would" inf ;
<Cond,Simul,Neg,_> => vf "wouldn't" inf ;
<Cond,Anter,Pos,_> => vf "would" ("have" ++ part) ;
<Cond,Anter,Neg,_> => vf "wouldn't" ("have" ++ part)
} ;
s2 = \\_ => []
} ;
insertObj : (Agr => Str) -> VP -> VP = \obj,vp -> {
s = vp.s ;
s2 = \\a => vp.s2 ! a ++ obj ! a
} ;
presVerb : {s : VForm => Str} -> Agr -> Str = \verb ->
agrVerb (verb.s ! VPres) (verb.s ! VInf) ;
infVP : VP -> Agr -> Str = \vp,a ->
(vp.s ! Fut ! Simul ! Neg ! ODir ! a).inf ++ vp.s2 ! a ;
agrVerb : Str -> Str -> Agr -> Str = \has,have,agr ->
case agr of {
{n = Sg ; p = P3} => has ;
_ => have
} ;
have = agrVerb "has" "have" ;
havent = agrVerb "hasn't" "haven't" ;
does = agrVerb "does" "do" ;
doesnt = agrVerb "doesn't" "don't" ;
Aux = {pres,past : Polarity => Agr => Str ; inf,ppart : Str} ;
auxBe : Aux = {
pres = \\b,a => agrVerb (posneg b "is") (posneg b "are") a ;
past = \\b,a => agrVerb (posneg b "was") (posneg b "were") a ;
inf = "be" ;
ppart = "been"
} ;
posneg : Polarity -> Str -> Str = \p,s -> case p of {
Pos => s ;
Neg => s + "n't"
} ;
conjThat : Str = "that" ;
}

View File

@@ -1,10 +0,0 @@
abstract Sentence = Cat ** {
fun
PredVP : NP -> VP -> Cl ;
SlashV2 : NP -> V2 -> Slash ;
}

View File

@@ -1,20 +0,0 @@
concrete SentenceEng of Sentence = CatEng ** open ResEng in {
flags optimize=all_subs ;
lin
PredVP np vp = {
s = \\t,a,b,o =>
let
agr = np.a ;
verb = vp.s ! t ! a ! b ! o ! agr ;
subj = np.s ! Nom ;
compl = vp.s2 ! agr
in
case o of {
ODir => subj ++ verb.fin ++ verb.inf ++ compl ;
OQuest => verb.fin ++ subj ++ verb.inf ++ compl
}
} ;
}

View File

@@ -1,13 +0,0 @@
abstract Tense = {
cat
Pol ;
Tense ;
Ant ;
fun
PPos, PNeg : Pol ;
TPres, TPast, TFut, TCond : Tense ;
ASimul, AAnter : Ant ;
}

View File

@@ -1,22 +0,0 @@
concrete TenseX of Tense = open (R = ParamX) in {
lincat
Tense = {s : Str ; t : R.Tense} ;
Ant = {s : Str ; a : R.Anteriority} ;
Pol = {s : Str ; p : R.Polarity} ;
lin
PPos = {s = []} ** {p = R.Pos} ;
PNeg = {s = []} ** {p = R.Neg} ;
TPres = {s = []} ** {t = R.Pres} ;
TPast = {s = []} ** {t = R.Past} ;
TFut = {s = []} ** {t = R.Fut} ;
TCond = {s = []} ** {t = R.Cond} ;
ASimul = {s = []} ** {a = R.Simul} ;
AAnter = {s = []} ** {a = R.Anter} ;
}

View File

@@ -1,5 +0,0 @@
abstract Tensed = Cat, Tense ** {
fun
UseCl : Tense -> Ant -> Pol -> Cl -> S ;
}

View File

@@ -1,8 +0,0 @@
concrete TensedEng of Tensed = CatEng, TenseX ** open ResEng in {
flags optimize=all_subs ;
lin
UseCl t a p cl = {s = t.s ++ a.s ++ p.s ++ cl.s ! t.t ! a.a ! p.p ! ODir} ;
}

View File

@@ -1,8 +0,0 @@
abstract Test =
Noun,
Verb,
Sentence,
Untensed,
-- Tensed,
Lex
** {} ;

View File

@@ -1,8 +0,0 @@
concrete TestEng of Test =
NounEng,
VerbEng,
SentenceEng,
UntensedEng,
-- TensedEng,
LexEng
** {} ;

View File

@@ -1,6 +0,0 @@
abstract Untensed = Cat ** {
fun
PosCl, NegCl : Cl -> S ;
}

View File

@@ -1,9 +0,0 @@
concrete UntensedEng of Untensed = CatEng ** open ResEng in {
flags optimize=all_subs ;
lin
PosCl cl = {s = cl.s ! Pres ! Simul ! Pos ! ODir} ;
NegCl cl = {s = cl.s ! Pres ! Simul ! Neg ! ODir} ;
}

View File

@@ -1,21 +0,0 @@
abstract Verb = Cat ** {
fun
UseV : V -> VP ;
ComplV2 : V2 -> NP -> VP ;
ComplV3 : V3 -> NP -> NP -> VP ;
ComplVV : VV -> VP -> VP ;
ComplVS : VS -> S -> VP ;
ComplVQ : VQ -> QS -> VP ;
UseComp : Comp -> VP ;
AdvVP : VP -> Adv -> VP ;
UseVV : VV -> V2 ;
UseVQ : VQ -> V2 ;
UseVS : VS -> V2 ;
CompAP : AP -> Comp ;
CompNP : NP -> Comp ;
CompAdv : Adv -> Comp ;
}

View File

@@ -1,23 +0,0 @@
concrete VerbEng of Verb = CatEng ** open ResEng in {
flags optimize=all_subs ;
lin
UseV = predV ;
ComplV2 v np = insertObj (\\_ => v.c2 ++ np.s ! Acc) (predV v) ;
ComplV2 v np = insertObj (\\_ => v.c2 ++ np.s ! Acc) (predV v) ;
ComplV3 v np np2 =
insertObj (\\_ => v.c2 ++ np.s ! Acc ++ v.c3 ++ np2.s ! Acc) (predV v) ;
ComplVV v vp = insertObj (\\a => v.c2 ++ infVP vp a) (predV v) ;
ComplVS v s = insertObj (\\_ => conjThat ++ s.s) (predV v) ;
ComplVQ v q = insertObj (\\_ => q.s) (predV v) ;
UseComp comp = insertObj comp.s (predAux auxBe) ;
AdvVP vp adv = insertObj (\\_ => adv.s) vp ;
UseVV, UseVS, UseVQ = \vv -> {s = vv.s ; c2 = []} ; -- no "to"
CompAP ap = {s = \\_ => ap.s} ;
CompNP np = {s = \\_ => np.s ! Acc} ;
CompAdv a = {s = \\_ => a.s} ;
}