Clause as restructuring of Verbphrase

This commit is contained in:
aarne
2005-02-17 12:56:57 +00:00
parent 0f6649a6ae
commit 55f28a0d3b
13 changed files with 165 additions and 91 deletions

View File

@@ -1,4 +1,8 @@
abstract TestResource = Rules, Clause, Structural ** {
abstract TestResource =
Rules,
---- Verbphrase,
Clause,
Structural ** {
-- a random sample of lexicon to test resource grammar with

View File

@@ -13,6 +13,8 @@
abstract Verbphrase = Categories ** {
flags optimize=all ;
-- These rules produce verb phrases.
fun
@@ -38,6 +40,8 @@ abstract Verbphrase = Categories ** {
PredAV : AV -> VPI -> VP ; -- "is eager to leave"
PredObjA2V : A2V -> NP -> VPI -> VP ; -- "is easy for us to convince"
PredProgVP : VPI -> VP ; -- "is eating fish"
-- These rules *use* verb phrases.
PredVP : NP -> VP -> Cl ; -- "John walks"
@@ -46,7 +50,7 @@ abstract Verbphrase = Categories ** {
PosVP, NegVP : Ant -> VP -> VPI ; -- to eat, not to eat
AdvVP : VP -> AdV -> VP ; -- "always walks"
---- AdvVP : VP -> AdV -> VP ; -- "always walks"
SubjVP : VP -> Subj -> S -> VP ; -- "(a man who) sings when he runs"
}

View File

@@ -3,8 +3,9 @@
instance SyntaxDan of SyntaxScand = TypesDan **
open Prelude, (CO = Coordination), MorphoDan in {
oper
flags optimize=all ;
oper
------ mkAdjForm
-- When common nouns are extracted from lexicon, the composite noun form is ignored.
@@ -108,12 +109,9 @@ instance SyntaxDan of SyntaxScand = TypesDan **
_ => "seg"
} ;
progressiveVerbPhrase : VerbGroup -> VerbGroup = \verb ->
progressiveVerbPhrase : VerbPhrase -> VerbGroup =
complVerbVerb
(verbVara **
{isAux = False} ----- {s3 = ["ved at"]}
)
(predVerbGroup True Simul verb) ;
{s = verbVara.s ; s1 = "ved" ; isAux = False} ;
progressiveClause : NounPhrase -> VerbPhrase -> Clause = \np,vp ->
predVerbGroupClause np

View File

@@ -152,17 +152,38 @@ Language-dependent resources
<!-- NEW -->
<h2>Use as top-level grammar</h2>
<h2>Use as top-level grammar: testing</h2>
Random generation, translation, morphological analysis...
Import a set of $LangX$ grammars:
<pre>
i english/LangEng.gf
i swedish/LangSwe.gf
</pre>
Test with random generation, translation, morphological analysis...
<pre>
<p>
Language learning: translation and morpho quiz
</pre>
<p>
<!-- NEW -->
<h2>Use as top-level grammar: language learning quizzes</h2>
Morpho quiz with words:
<pre>
</pre>
Morpho quiz with phrases:
<pre>
</pre>
Translation quiz with sentences:
<pre>
</pre>
Generate elementary text books from abstract syntax?
@@ -179,10 +200,14 @@ No more dummy <tt>reuse</tt> modules and bulky <tt>.gfr</tt> files!
If you need to convert resource category records to/from strings, use
<pre>
Predef.toStr : L -> Str ;
Predef.fromStr : Str -> L ;
Predef.toStr : (L : Type) -> L -> Str ;
</pre>
<tt>L</tt> must be a linearization type.
<tt>L</tt> must be a linearization type. For instance,
<pre>
toStr LangNor.CN (ModAP (PositADeg old_ADeg) (UseN car_N))
---> "gammel bil"
</pre>
<!-- NEW -->
@@ -205,9 +230,14 @@ Extend vocabulary at need.
</pre>
<!-- NEW -->
<h2>Example application: a small translation system</h2>
<!-- NEW -->
<h2>Implementatin details: the structure of low-level files</h2>
<h2>Implementation details: the structure of low-level files</h2>
<center>
<img src="Low.gif">

View File

@@ -690,10 +690,12 @@ oper
APl P3 => "themselves"
} ;
progressiveClause : NounPhrase -> VerbPhrase -> Clause = \np,vp ->
predBeGroup np (vp.s ! VIPresPart) ;
progressiveVerbPhrase : VerbPhrase -> VerbGroup = \vp ->
predClauseBeGroup (vp.s ! VIPresPart) ;
--- negation of prp ignored: "not" only for "be"
--3 Tensed clauses
@@ -725,16 +727,53 @@ oper
}
} ;
-- These three function are just to restore the $VerbGroup$ ($VP$) based structure.
predVerbGroupClause : NounPhrase -> VerbGroup -> Clause = \np,vp ->
let
ag = np.a ;
it = np.s ! NomP
in
{s = table {
Dir => \\b,sf => it ++ vp.s ! b ! sf ! ag ++ vp.s2 ! b ! sf ! ag ;
Inv => \\b,sf =>
let
does = vp.s ! b ! sf ! ag ;
walk = vp.s2 ! b ! sf ! ag
in
case sf of {
VFinite t Simul => case b of {
True => auxTense b t ag ++ it ++ walk ;
_ => does ++ it ++ walk
} ;
_ => does ++ it ++ walk
}
}
} ;
predClauseGroup : Verb -> Complement -> VerbGroup = \verb,comp ->
let
nvg : Agr -> (Bool => SForm => (Str * Str * Str)) =
\ag -> predVerbClauseGen {s = \\_ => [] ; a = ag} verb comp
\ag -> predVerbClauseGen {s = \\_ => [] ; a = ag} verb comp
in
{s = \\b,f,a => (nvg a ! b ! f).p2 ;
s2 = \\b,f,a => (nvg a ! b ! f).p3 ;
isAux = False ----
isAux = False
} ;
predClauseBeGroup : Complement -> VerbGroup = \comp ->
let
nvg : Agr -> (Bool => SForm => (Str * Str * Str)) =
\ag -> predAuxClauseGen {s = \\_ => [] ; a = ag} auxVerbBe comp
in
{s = \\b,f,a => (nvg a ! b ! f).p2 ;
s2 = \\b,f,a => (nvg a ! b ! f).p3 ;
isAux = True
} ;
-- This is the general predication function for non-auxiliary verbs,
-- i.e. ones with "do" inversion and negation.
predVerbClauseGen : NounPhrase -> Verb -> Complement -> (Bool =>
SForm => (Str * Str * Str)) = \np,verb,comp ->
let
@@ -1025,15 +1064,12 @@ oper
RelClause : Type = {s : Bool => SForm => Agr => Str} ;
RelSentence : Type = {s : Agr => Str} ;
------ relg
relVerbPhrase : RelPron -> VerbGroup -> RelClause = \who,walks ->
{s = \\b,sf,a => []
---- let wa = fromAgr a in
---- (predVerbGroupClause (relNounPhrase who wa.g wa.n) walks).s ! Dir ! b ! sf
{s = \\b,sf,a =>
let wa = fromAgr a in
(predVerbGroupClause (relNounPhrase who wa.g wa.n) walks).s ! Dir ! b ! sf
} ;
--- TODO: full tense variation in relative clauses.
relSlash : RelPron -> ClauseSlashNounPhrase -> RelClause = \who,yousee ->
{s = \\b,sf,a =>
let
@@ -1196,7 +1232,6 @@ oper
in
{s = \\b,sf,_ => whoisold.s ! Dir ! b ! sf} ;
{- --vg
intVerbPhrase : IntPron -> VerbGroup -> Question = \who,walk ->
let
who : NounPhrase = {s = who.s ; a = toAgr who.n P3 who.g} ;
@@ -1204,8 +1239,6 @@ oper
in
{s = \\b,sf,_ => whowalks.s ! Dir ! b ! sf} ;
--vg -}
intVerbClause : IntPron -> Verb -> Complement -> Question = \who,walk,here ->
let
who : NounPhrase = {s = who.s ; a = toAgr who.n P3 who.g} ;

View File

@@ -23,39 +23,43 @@ concrete VerbphraseEng of Verbphrase = CategoriesEng **
open Prelude, SyntaxEng in {
lin
UseV = predVerb ;
UsePassV = passVerb ;
ComplV2 = complTransVerb ;
ComplReflV2 = reflTransVerb ;
ComplVS = complSentVerb ;
ComplVV = complVerbVerb ;
ComplVQ = complQuestVerb ;
ComplVA = complAdjVerb ;
ComplV2A = complDitransAdjVerb ;
ComplSubjV2V = complDitransVerbVerb False ;
ComplObjV2V = complDitransVerbVerb True ;
ComplV2S = complDitransSentVerb ;
ComplV2Q = complDitransQuestVerb ;
UseV v = predClauseGroup v (complVerb v) ;
UsePassV v = predClauseBeGroup (passVerb v) ;
ComplV2 v x = predClauseGroup v (complTransVerb v x) ;
ComplReflV2 v = predClauseGroup v (reflTransVerb v) ;
ComplVS v x = predClauseGroup v (complSentVerb v x) ;
ComplVV v x = predClauseGroup (aux2verb v) (complVerbVerb v x) ;
ComplVQ v x = predClauseGroup v (complQuestVerb v x) ;
ComplVA v x = predClauseGroup v (complAdjVerb v x) ;
ComplV2A v x y = predClauseGroup v (complDitransAdjVerb v x y) ;
ComplSubjV2V v x y = predClauseGroup v (complDitransVerbVerb False v x y) ;
ComplObjV2V v x y = predClauseGroup v (complDitransVerbVerb True v x y) ;
ComplV2S v x y = predClauseGroup v (complDitransSentVerb v x y) ;
ComplV2Q v x y = predClauseGroup v (complDitransQuestVerb v x y) ;
PredAP = predAdjective ;
PredSuperl a = predAdjective (superlAdjPhrase a) ;
PredCN = predCommNoun ;
PredNP = predNounPhrase ;
PredPP = predAdverb ;
PredAV = complVerbAdj ;
PredObjA2V = complVerbAdj2 True ;
PredAP v = predClauseBeGroup (complAdjective v) ;
PredSuperl a = predClauseBeGroup (complAdjective (superlAdjPhrase a)) ;
PredCN v = predClauseBeGroup (complCommNoun v) ;
PredNP v = predClauseBeGroup (complNounPhrase v) ;
PredPP v = predClauseBeGroup (complAdverb v) ;
PredAV v x = predClauseBeGroup (complVerbAdj v x) ;
PredObjA2V v x y = predClauseBeGroup (complVerbAdj2 True v x y) ;
PredProgVP = progressiveVerbPhrase ;
---- SPredProgVP = progressiveClause ;
-- Use VPs
PredVP = predVerbGroupClause ;
RelVP = relVerbPhrase ;
IntVP = intVerbPhrase ;
PosVP tp = predVerbGroup True tp.a ;
NegVP tp = predVerbGroup False tp.a ;
-- PosVP tp = predVerbGroup True tp.a ;
-- NegVP tp = predVerbGroup False tp.a ;
AdvVP = adVerbPhrase ;
---- AdvVP = adVerbPhrase ;
SubjVP = subjunctVerbPhrase ;
}

View File

@@ -3,6 +3,8 @@
instance SyntaxNor of SyntaxScand = TypesNor **
open Prelude, (CO = Coordination), MorphoNor in {
flags optimize=all ;
oper
------ mkAdjForm
@@ -75,7 +77,7 @@ instance SyntaxNor of SyntaxScand = TypesNor **
auxSka = "vil" ;
auxSkulle = "ville" ;
infinAtt = "at" ;
infinAtt = "å" ;
varjeDet : Determiner = mkDeterminerSg (detSgInvar "hver") IndefP ;
allaDet : Determiner = mkDeterminerPl "alle" IndefP ;
@@ -109,12 +111,9 @@ instance SyntaxNor of SyntaxScand = TypesNor **
_ => "seg"
} ;
progressiveVerbPhrase : VerbGroup -> VerbGroup = \verb ->
progressiveVerbPhrase : VerbPhrase -> VerbGroup =
complVerbVerb
(verbVara **
{isAux = False} ----- {s3 = ["ved at"]}
)
(predVerbGroup True Simul verb) ;
({s = verbVara.s ; s1 = "ved" ; isAux = False}) ;
progressiveClause : NounPhrase -> VerbPhrase -> Clause = \np,vp ->
predVerbGroupClause np

View File

@@ -34,7 +34,7 @@ lincat
V = Verb ;
-- = {s : VerbForm => Str ; s1 : Str} ;
VP = {s : SForm => Str ; s2 : Bool => Str ;
VP = {s : SForm => Str ;
s3 : SForm => Gender => Number => Person => Str} ;
VPI = {s : VIForm => Gender => Number => Person => Str} ;
V2 = TransVerb ;

View File

@@ -133,7 +133,7 @@ lin
ImperMany = imperUtterance plural ;
AdvCl = advClause ;
AdvVP = advVerbPhrase ;
---- AdvVP = advVerbPhrase ;
AdvPhr = advSentence ;
AdCPhr = advSentence ;

View File

@@ -9,7 +9,7 @@
interface SyntaxScand = TypesScand ** open Prelude, (CO = Coordination) in {
flags optimize=share ;
flags optimize=parametrize ;
--2 Common Nouns
--
@@ -535,7 +535,7 @@ oper
useVerb : Verb -> (Gender => Number => Person => Str) -> VerbGroup = \verb,arg ->
let aer = verbSForm verb Act in {
s = \\sf => (aer sf).fin ;
s2 = negation ;
--* s2 = negation ;
s3 = \\sf,g,n,p => (aer sf).inf ++ arg ! g ! n ! p
} ;
@@ -553,27 +553,28 @@ oper
VerbGroup : Type = {
s : SForm => Str ;
s2 : Bool => Str ;
--* s2 : Bool => Str ;
s3 : SForm => Gender => Number => Person => Str
} ;
predVerbGroup : Bool -> Anteriority -> VerbGroup -> VerbPhrase = \b,a,vg ->
predVerbGroup : Bool -> {s : Str ; a : Anteriority} -> VerbGroup -> VerbPhrase = \b,ant,vg ->
let
vgs = vg.s ;
vgs3 = vg.s3
vgs3 = vg.s3 ;
a = ant.a ;
in
{s = table {
VIInfinit => \\g,n,p =>
vg.s ! VInfinit a ++ vg.s2 ! b ++ vg.s3 ! VInfinit a ! g ! n ! p ;
vg.s ! VInfinit a ++ ant.s ++ negation ! b ++ vg.s3 ! VInfinit a ! g ! n ! p ;
VIImperat bo => \\g,n,p =>
vg.s ! VImperat ++ vg.s2 ! bo ++ vg.s3 ! VImperat ! g ! n ! p
vg.s ! VImperat ++ ant.s ++ negation ! bo ++ vg.s3 ! VImperat ! g ! n ! p
} ---- bo shadows b
} ;
predVerbGroupI : Bool -> {s : Str ; a : Anteriority} -> VerbGroup -> VerbPhrase =
\b,ant,vg ->
let vp = predVerbGroup b ant.a vg in
{s = \\i,g,n,p => ant.s ++ vp.s ! i ! g ! n ! p
let vp = predVerbGroup b ant vg in
{s = \\i,g,n,p => vp.s ! i ! g ! n ! p
} ;
@@ -589,7 +590,8 @@ oper
predVerb0 : Verb -> Clause = \regna ->
predVerbGroupClause npDet (predVerb regna) ;
progressiveVerbPhrase : VerbGroup -> VerbGroup ;
progressiveVerbPhrase : VerbPhrase -> VerbGroup ;
progressiveClause : NounPhrase -> VerbPhrase -> Clause ;
-- Verb phrases can also be formed from adjectives ("är snäll"),
@@ -662,7 +664,7 @@ oper
passVerb : Verb -> VerbGroup = \se ->
let ses = verbSForm se Pass in {
s = \\sf => (ses sf).fin ;
s2 = negation ;
--* s2 = negation ;
s3 = \\sf,g,n,_ => (ses sf).inf ++ se.s1
} ;
@@ -736,7 +738,7 @@ oper
{
--- this unfortunately generates VP#2 ::= VP#2
s = spelar.s ;
s2 = \\b => ofta.s ++ spelar.s2 ! b ;
--* s2 = \\b => ofta.s ++ spelar.s2 ! b ; ----* the essential use of s2
s3 = \\sf,g,n,p => spelar.s3 ! sf ! g ! n ! p
} ;
@@ -816,7 +818,7 @@ oper
o = osf.o ;
ser = serdiginte.s ! t ;
dig = serdiginte.s3 ! t ! Jag.g ! Jag.n ! Jag.p ;
inte = serdiginte.s2 ! b
inte = negation ! b --* serdiginte.s2 ! b
} in
case o of {
Main => jag ++ ser ++ inte ++ dig ;
@@ -996,9 +998,9 @@ oper
RelClause : Type = {s : Bool => SForm => GenNum => Person => Str} ;
RelSent : Type = {s : GenNum => Person => Str} ;
relVerbGroup : RelPron -> VerbGroup -> RelClause = \som,sover ->
relVerbPhrase : RelPron -> VerbGroup -> RelClause = \som,sover ->
{s = \\b,sf,gn,p =>
som.s ! RNom ! gn ++ sover.s2 ! b ++ sover.s ! sf ++
som.s ! RNom ! gn ++ negation ! b ++ sover.s ! sf ++
sover.s3 ! sf ! mkGenderRel som.g (genGN gn) ! numGN gn ! p
} ;

View File

@@ -1,8 +1,5 @@
--# -path=.:../abstract:../../prelude
incomplete concrete VerbphraseScand of Verbphrase = CategoriesScand **
open Prelude, SyntaxScand in {
--1 The Top-Level English Resource Grammar: Combination Rules
--
-- Aarne Ranta 2002 -- 2003
@@ -22,8 +19,8 @@ incomplete concrete VerbphraseScand of Verbphrase = CategoriesScand **
-- one has to know how the syntactic categories are
-- implemented. The parameter types are defined in $TypesEng.gf$.
concrete VerbphraseEng of Verbphrase = CategoriesEng **
open Prelude, SyntaxEng in {
incomplete concrete VerbphraseScand of Verbphrase = CategoriesScand **
open Prelude, SyntaxScand in {
lin
UseV = predVerb ;
@@ -48,16 +45,18 @@ concrete VerbphraseEng of Verbphrase = CategoriesEng **
PredAV = complVerbAdj ;
PredObjA2V = complVerbAdj2 True ;
PredProgVP = progressiveVerbPhrase ;
-- Use VPs
PredVP = predVerbGroupClause ;
RelVP = relVerbPhrase ;
IntVP = intVerbPhrase ;
PosVP tp = predVerbGroup True tp.a ;
NegVP tp = predVerbGroup False tp.a ;
PosVP tp = predVerbGroup True tp ;
NegVP tp = predVerbGroup False tp ;
AdvVP = adVerbPhrase ;
---- AdvVP = adVerbPhrase ;
SubjVP = subjunctVerbPhrase ;
}
}

View File

@@ -1,4 +1,5 @@
--# -path=.:../scandinavian:../abstract:../../prelude
concrete ClauseSwe of Clause = CategoriesSwe **
ClauseScand with (SyntaxScand=SyntaxSwe) ;
ClauseI with (Rules=RulesSwe), (Verbphrase=VerbphraseSwe) ;
---- ClauseScand with (SyntaxScand=SyntaxSwe) ;

View File

@@ -115,11 +115,10 @@ instance SyntaxSwe of SyntaxScand = TypesSwe **
_ => "sig"
} ;
progressiveVerbPhrase : VerbGroup -> VerbGroup = \verb ->
progressiveVerbPhrase : VerbPhrase -> VerbGroup =
complVerbVerb
(mkVerb "hålla" "håller" "håll" "höll" "hållit" "hållen" **
{isAux = False}) ---- ;{s3 = ["på att"]})
(predVerbGroup True Simul verb) ;
{isAux = False}) ;
progressiveClause : NounPhrase -> VerbPhrase -> Clause = \np,vp ->
predVerbGroupClause np
@@ -131,6 +130,7 @@ instance SyntaxSwe of SyntaxScand = TypesSwe **
strPrep : ComplPrep -> Str = \p -> case p of {
CPnoPrep => [] ;
CPav => "av" ;
---- CPmed => "med" ;
CPför => "för" ;
CPi => "i" ;
CPom => "om" ;