Predication: factored out Prep as Adv/NP; added linref's to test with chunking

This commit is contained in:
aarne
2014-02-05 09:31:23 +00:00
parent bda94ebb95
commit ddc40ee2fd
7 changed files with 119 additions and 77 deletions

View File

@@ -1,4 +1,4 @@
abstract Pred = Cat [Ant,Tense,Pol,NP,Utt,IP,IAdv,Conj,Prep] ** {
abstract Pred = Cat [Ant,Tense,Pol,NP,Utt,IP,IAdv,Conj] ** {
cat
Arg ;
@@ -12,13 +12,12 @@ cat
ClC Arg ; -- conjunction of Cl
PrQCl Arg ;
-- NP ;
PrAdv ;
PrAdv Arg ;
PrS ;
-- Utt ;
PrAP Arg ;
PrCN Arg ; -- the country he became the president of
-- IP ;
-- Prep ;
-- Conj ;
-- IAdv ;
@@ -50,7 +49,6 @@ fun
PredVP : (a : Arg) -> NP -> PrVP a -> PrCl a ;
PrepCl : Prep -> (a : Arg) -> PrCl a -> PrCl (aNP a) ; -- slash creation (S/NP): hon tittar på (oss)
SlashClNP : (a : Arg) -> PrCl (aNP a) -> NP -> PrCl a ; -- slash consumption: hon tittar på + oss
ReflVP : (a : Arg) -> PrVP (aNP a) -> PrVP a ; -- refl on first position (direct object)
@@ -64,20 +62,13 @@ fun
UseCl : PrCl aNone -> PrS ;
UseQCl : PrQCl aNone -> PrS ; -- deprecate QS
UseAdvCl : PrAdv -> PrCl aNone -> PrS ; -- lift adv to front
UseAdvCl : PrAdv aNone -> PrCl aNone -> PrS ; -- lift adv to front
UttS : PrS -> Utt ;
-- when to add adverbs
---- AdvVP : Adv -> (a : Arg) -> PrVP a -> PrVP a ; ---- these create many ambiguities
---- "hon tvingar oss att sova idag": 196 parses, 13s. With AdvVP restricted to top level: 32 parses, 7s
---- with AdvCl, just 16 parses, 0.2 s
AdvCl : Adv -> (a : Arg) -> PrCl a -> PrCl a ;
AdvQCl : Adv -> (a : Arg) -> PrQCl a -> PrQCl a ;
AdvCl : (a : Arg) -> PrAdv a -> PrCl aNone -> PrCl a ;
AdvQCl : (a : Arg) -> PrAdv a -> PrQCl aNone -> PrQCl a ;
-- participles as adjectives
@@ -96,5 +87,6 @@ fun
ContClC : (a : Arg) -> PrCl a -> ClC a -> ClC a ;
UseClC : (a : Arg) -> ClC a -> PrCl a ;
ComplAdv : (a : Arg) -> PrAdv (aNP a) -> NP -> PrAdv a ; -- typically: formation of preposition phrase
}

View File

@@ -170,7 +170,7 @@ lincat
c3 : ComplCase ;
} ;
PrAdv = {s : Str ; isAdV : Bool} ;
PrAdv = {s : Str ; isAdV : Bool ; c1 : Str} ;
PrS = {s : Str} ;
PrAP = {
@@ -189,11 +189,28 @@ lincat
-- language specific
NP = {s : NPCase => Str ; a : Agr} ;
IP = {s : NPCase => Str ; n : IPAgr} ; ---- n : Number in Eng
Prep = {s : Str} ;
Conj = {s1,s2 : Str ; n : Number} ;
-}
-- reference linearizations for chunking
linref
PrVP = \vp ->
let
agr = defaultAgr ;
vagr = agr2vagr agr ;
verb = vp.v ! vagr ;
in
verb.p1 ++ verb.p2 ++ vp.adV ++ verb.p3 ++ vp.part ++
vp.adj ! agr ++ vp.obj1.p1 ! agr ++ vp.obj2.p1 ! agr ++ vp.adv ++ vp.ext ;
PrCl = \cl -> declCl cl ;
---- PrQCl = \qcl -> questCl (lin PrQCl qcl) ;
PrAdv = \adv -> adv.c1 ++ adv.s ;
PrAP = \ap -> ap.s ! UUnit ++ ap.obj1 ! defaultAgr ;
PrCN = \cn -> cn.s ! Sg ++ cn.obj1 ! defaultAgr ;
----------------------------
--- linearization rules ----
----------------------------

View File

@@ -15,13 +15,12 @@ cat
ClC Arg ; -- conjunction of Cl
QCl Arg ;
NP ;
Adv ;
Adv Arg ; -- preposition is Adv aNP
S ;
Utt ;
AP Arg ;
CN Arg ; -- the country he became the president of
CN Arg ; -- the country he became the president of
IP ;
Prep ;
Conj ;
IAdv ;
@@ -53,8 +52,7 @@ fun
PredVP : (a : Arg) -> NP -> VP a -> Cl a ;
PrepCl : Prep -> (a : Arg) -> Cl a -> Cl (aNP a) ; -- slash creation (S/NP): hon tittar på (oss)
SlashClNP : (a : Arg) -> Cl (aNP a) -> NP -> Cl a ; -- slash consumption: hon tittar på + oss
SlashClNP : (a : Arg) -> Cl (aNP a) -> NP -> Cl a ; -- slash consumption: hon tittar på + oss
ReflVP : (a : Arg) -> VP (aNP a) -> VP a ; -- refl on first position (direct object)
ReflVP2 : (a : Arg) -> VP (aNP (aNP a)) -> VP (aNP a) ; -- refl on second position (indirect object)
@@ -67,7 +65,7 @@ fun
UseCl : Cl aNone -> S ;
UseQCl : QCl aNone -> S ; -- deprecate QS
UseAdvCl : Adv -> Cl aNone -> S ; -- lift adv to front
UseAdvCl : Adv aNone -> Cl aNone -> S ; -- lift adv to front
UttS : S -> Utt ;
@@ -77,9 +75,9 @@ fun
---- "hon tvingar oss att sova idag": 196 parses, 13s. With AdvVP restricted to top level: 32 parses, 7s
---- with AdvCl, just 16 parses, 0.2 s
AdvCl : Adv -> (a : Arg) -> Cl a -> Cl a ;
AdvCl : (a : Arg) -> Adv a -> Cl aNone -> Cl a ;
AdvQCl : Adv -> (a : Arg) -> QCl a -> QCl a ;
AdvQCl : (a : Arg) -> Adv a -> QCl aNone -> QCl a ;
-- participles as adjectives
@@ -99,9 +97,10 @@ fun
ContClC : (a : Arg) -> Cl a -> ClC a -> ClC a ;
UseClC : (a : Arg) -> ClC a -> Cl a ;
ComplAdv : (a : Arg) -> Adv (aNP a) -> NP -> Adv a ; -- typically: formation of preposition phrase
--------------- from now on, to be inherited from standard RGL; here just for test purposes
PrepNP : Prep -> NP -> Adv ;
-- lexicon
@@ -132,11 +131,11 @@ fun
she_NP : NP ;
we_NP : NP ;
today_Adv : Adv ;
always_AdV : Adv ;
today_Adv : Adv aNone ;
always_AdV : Adv aNone ;
who_IP : IP ;
with_Prep : Prep ;
with_Prep : Adv (aNP aNone) ;
and_Conj : Conj ;
why_IAdv : IAdv ;

View File

@@ -164,7 +164,7 @@ lincat
c3 : ComplCase ;
} ;
Adv = {s : Str ; isAdV : Bool} ;
Adv = {s : Str ; isAdV : Bool ; c1 : ComplCase} ;
S = {s : Str} ;
AP = {
@@ -183,7 +183,6 @@ lincat
NP = NounPhrase ;
IP = {s : NPCase => Str ; n : IPAgr} ; ---- n : Number in Eng
Prep = Preposition ;
Conj = {s1,s2 : Str ; n : Number} ;
oper
@@ -344,19 +343,30 @@ lin
} ;
QuestSlash x ip cl =
let
ips = cl.c3 ++ ip.s ! objCase ; -- in Cl/NP, c3 is the only prep ---- appComplCase for ip
let
prep = cl.c3 ;
ips = ip.s ! objCase ; -- in Cl/NP, c3 is the only prep ---- appComplCase for ip
focobj = case cl.focType of {
NoFoc => <ips, [], FocObj> ; -- put ip object to focus if there is no focus yet
t => <[], ips, t> -- put ip object in situ if there already is a focus
NoFoc => <ips, [], FocObj,prep> ; -- put ip object to focus if there is no focus yet
t => <[], prep ++ ips, t,noComplCase> -- put ip object in situ if there already is a focus
} ;
in cl ** {
foc = focobj.p1 ;
in
cl ** { -- preposition stranding
foc = focobj.p1 ;
focType = focobj.p3 ;
subj = cl.subj ;
obj1 = cl.obj1 ++ focobj.p2 ; ---- just add to a field?
c3 = noComplCase ;
obj1 = cl.obj1 ++ focobj.p2 ; ---- just add to a field?
c3 = focobj.p4 ;
} ;
{-
---- this is giving four records instead of two AR 5/2/2014
|
cl ** { -- pied piping
foc = focobj.p4 ++ focobj.p1 ;
focType = focobj.p3 ;
obj1 = cl.obj1 ++ focobj.p2 ; ---- just add to a field?
c3 = noComplCase ;
} ;
-}
UseCl cl = {s = declCl cl} ;
UseQCl cl = {s = questCl cl} ;
@@ -365,9 +375,15 @@ lin
UttS s = s ;
AdvCl a x cl = cl ** case a.isAdV of {True => {adV = cl.adV ++ a.s ; adv = cl.adv} ; False => {adv = cl.adv ++ a.s ; adV = cl.adV}} ;
AdvCl x a cl = case a.isAdV of {
True => cl ** {adV = cl.adV ++ a.s ; adv = cl.adv ; c3 = a.c1} ;
False => cl ** {adv = cl.adv ++ a.s ; adV = cl.adV ; c3 = a.c1}
} ;
AdvQCl a x cl = cl ** {adv = cl.adv ++ a.s} ;
AdvQCl x a cl = case a.isAdV of {
True => cl ** {adV = cl.adV ++ a.s ; adv = cl.adv ; c3 = a.c1} ;
False => cl ** {adv = cl.adv ++ a.s ; adV = cl.adV ; c3 = a.c1}
} ;
PresPartAP x v = {
@@ -442,7 +458,7 @@ lin
qforms = <[],[]> ; ---- qforms
} ;
ComplAdv x p np = {s = p.c1 ++ np.s ! objCase ; isAdV = p.isAdV ; c1 = []} ;
---- the following may become parameters for a functor
@@ -673,14 +689,12 @@ lin
she_NP = {s = table {NCase Nom => "she" ; _ => "her"} ; a = AgP3Sg Fem} ;
we_NP = {s = table {NCase Nom => "we" ; _ => "us"} ; a = AgP1 Pl} ;
today_Adv = {s = "today" ; isAdV = False} ;
always_AdV = {s = "always" ; isAdV = True} ;
today_Adv = {s = "today" ; isAdV = False ; c1 = []} ;
always_AdV = {s = "always" ; isAdV = True ; c1 = []} ;
who_IP = {s = \\_ => "who" ; n = Sg} ;
PrepNP p np = {s = p.s ++ np.s ! objCase ; isAdV = False} ;
with_Prep = {s = "with"} ;
with_Prep = {s = [] ; c1 = "with" ; isAdV = False} ;
and_Conj = {s1 = [] ; s2 = "and" ; n = Pl} ;

View File

@@ -22,6 +22,7 @@ param
oper
defaultAgr = Sg ;
ComplCase = Str ; -- preposition
objCase = Acc ;
lincat
Arg = {s : Str} ;
@@ -82,7 +83,7 @@ lincat
Pol = {s : Str ; p : Polarity} ;
NP = {s : Case => Str ; a : Agr} ;
Adv = {s : Str ; isAdV : Bool} ;
Adv = {s : Str ; isAdV : Bool ; c1 : ComplCase} ;
S = {s : Str} ;
Utt = {s : Str} ;
AP = {
@@ -98,7 +99,6 @@ lincat
Agr => Str
} ;
IP = {s : Str ; a : Agr} ;
Prep = {s : Str} ;
Conj = {s : Str} ;
IAdv = {s : Str} ;
@@ -210,10 +210,6 @@ lin
c3 = noComplCase ; -- for one more prep to build ClSlash
} ;
PrepCl p x cl = cl ** { -- Cl/NP ::= Cl PP/NP
c3 = prepComplCase p ;
} ;
SlashClNP x cl np = cl ** { -- Cl ::= Cl/NP NP
adv = cl.adv ++ appComplCase cl.c3 np ; ---- again, adv just added
c3 = noComplCase ; -- complCase has been consumed
@@ -235,20 +231,34 @@ lin
c3 = noComplCase ; -- for one more prep to build ClSlash ---- ever needed for QCl?
} ;
QuestSlash x ip cl =
let
ips = cl.c3 ++ ip.s ; -- in Cl/NP, c3 is the only prep ---- appComplCase for ip
let
prep = cl.c3 ;
ips = ip.s ; -- in Cl/NP, c3 is the only prep ---- appComplCase for ip
focobj = case cl.focType of {
NoFoc => <ips, [], FocObj> ; -- put ip object to focus if there is no focus yet
t => <[], ips, t> -- put ip object in situ if there already is a focus
NoFoc => <ips, [], FocObj,prep> ; -- put ip object to focus if there is no focus yet
t => <[], prep ++ ips, t,noComplCase> -- put ip object in situ if there already is a focus
} ;
in cl ** {
foc = focobj.p1 ;
in
cl ** { -- preposition stranding
foc = focobj.p1 ;
focType = focobj.p3 ;
subj = cl.subj ;
obj1 = cl.obj1 ++ focobj.p2 ; ---- just add to a field?
c3 = noComplCase ;
obj1 = cl.obj1 ++ focobj.p2 ; ---- just add to a field?
c3 = focobj.p4 ;
} ;
{-
---- this is giving four records instead of two AR 5/2/2014
|
cl ** { -- pied piping
foc = focobj.p4 ++ focobj.p1 ;
focType = focobj.p3 ;
obj1 = cl.obj1 ++ focobj.p2 ; ---- just add to a field?
c3 = noComplCase ;
} ;
-}
UseCl cl = {s = declCl cl} ;
UseQCl cl = {s = questCl cl} ;
@@ -257,10 +267,15 @@ lin
UttS s = s ;
AdvCl a x cl = cl ** case a.isAdV of {True => {adV = cl.adV ++ a.s ; adv = cl.adv} ; False => {adv = cl.adv ++ a.s ; adV = cl.adV}} ;
AdvQCl a x cl = cl ** {adv = cl.adv ++ a.s} ;
AdvCl x a cl = case a.isAdV of {
True => cl ** {adV = cl.adV ++ a.s ; adv = cl.adv ; c3 = a.c1} ;
False => cl ** {adv = cl.adv ++ a.s ; adV = cl.adV ; c3 = a.c1}
} ;
AdvQCl x a cl = case a.isAdV of {
True => cl ** {adV = cl.adV ++ a.s ; adv = cl.adv ; c3 = a.c1} ;
False => cl ** {adv = cl.adv ++ a.s ; adV = cl.adV ; c3 = a.c1}
} ;
PresPartAP x v = {
s = \\a => v.v ! PresPart ;
@@ -326,6 +341,8 @@ lin
c3 = cl.c3 ;
} ;
ComplAdv x p np = {s = p.c1 ++ np.s ! objCase ; isAdV = p.isAdV ; c1 = []} ;
---- the following may become parameters for a functor
oper
@@ -386,7 +403,7 @@ oper
noComplCase : ComplCase = [] ;
prepComplCase : Prep -> ComplCase = \p -> p.s ;
prepComplCase : {s : Str} -> ComplCase = \p -> p.s ;
noObj : Agr => Str = \\_ => [] ;
@@ -434,14 +451,14 @@ lin
she_NP = {s = table {Nom => "hon" ; Acc => "henne"} ; a = Sg} ;
we_NP = {s = table {Nom => "vi" ; Acc => "oss"} ; a = Pl} ;
today_Adv = {s = "idag" ; isAdV = False} ;
always_AdV = {s = "alltid" ; isAdV = True} ;
today_Adv = {s = "idag" ; isAdV = False ; c1 = []} ;
always_AdV = {s = "alltid" ; isAdV = True ; c1 = []} ;
who_IP = {s = "vem" ; a = Sg} ;
PrepNP p np = {s = p.s ++ np.s ! Acc ; isAdV = False} ;
with_Prep = {s = "med"} ;
with_Prep = {s = [] ; isAdV = False ; c1 = "med"} ;
and_Conj = {s = "och"} ;

View File

@@ -13,7 +13,7 @@ flags
meta_token_prob=1.1965149246222233e-9;
fun
LiftV : V -> PrV aNone ;
LiftV : V -> PrV aNone ;
LiftV2 : V2 -> PrV (aNP aNone) ;
LiftVS : VS -> PrV aS ;
LiftVQ : VQ -> PrV aQ ;
@@ -29,8 +29,10 @@ fun
LiftV2N : V2A -> PrV (aNP aN) ; ----
LiftAP : AP -> PrAP aNone ;
LiftCN : AP -> PrCN aNone ;
LiftAdv : Adv -> PrAdv ;
LiftAdV : Adv -> PrAdv ;
LiftAdv : Adv -> PrAdv aNone ;
LiftAdV : Adv -> PrAdv aNone ;
LiftPrep : Prep -> PrAdv (aNP aNone) ;
}

View File

@@ -7,6 +7,9 @@ concrete TransEng of Trans =
** open ResEng, Prelude in {
flags
literal=Symb ;
lin
LiftV v = v ** {v = v.s ; c1,c2 = [] ; isSubjectControl, isAux = False} ;
LiftV2 v = v ** {v = v.s ; c1 = v.c2 ; c2 = [] ; isSubjectControl, isAux = False} ;
@@ -14,13 +17,11 @@ lin
LiftAP ap = {s = \\_ => ap.s ! AgP3Sg Neutr ; c1,c2 = [] ; obj1 = \\_ => []} ; --- agr, isPre
LiftAdv a = a ** {isAdV = False} ;
LiftAdV a = a ** {isAdV = True} ;
LiftAdv a = a ** {isAdV = False ; c1 = []} ;
LiftAdV a = a ** {isAdV = True ; c1 = []} ;
LiftPrep p = {s = [] ; isAdV = False ; c1 = p.s} ;
{-
LiftV2 : V2 -> PrV (aNP aNone) ;
LiftVS : VS -> PrV aS ;
LiftVQ : VQ -> PrV aQ ;
LiftVV : VV -> PrV aV ;
LiftVA : VA -> PrV aA ;