An implementation of token dependency semantics using the PETFSG grammar …matsd/tds/1/itds.pdf ·...

Preview:

Citation preview

An implementation oftokendependency semantics

using the PETFSG grammar tool

MatsDahllofDepartmentof Linguistics,UppsalaUniversity

E-mail:mats.d ahllof@li ng.uu.seJanuary7, 2002

Work in progress! Demo, updates, and related material:http: //stp.lin g.uu.se/˜ matsd/tds /1/

1 Intr oduction

This report1 describesan implementationof an HPSG-style formal grammarandsemantics,which will becalled‘tokendependency semantics’(henceforthTDS),version1. The theoreticalbackgroundis given in my article ‘Tokendependencysemanticsandtheparatacticanalysisof intensionalconstructions’(availablefromthe author).The relationbetweenthe presentationsis fairly direct. The presentreportgivesa technicalaccountof the implemented grammar, whoselinguisticaspectsareexplainedanddefendedin theotherarticle.Themainpurposeof thepresentdocumentis to give the readersomehelp in understanding the imple-mentedTDS grammarandtheauxiliaryPrologprocedures.They arelisted,alongwith commentsandexplanations, in the appendices.The grammarmainly pro-videstreatmentsof anumberof intensionalconstructions, andit coversonly sim-pleexamplesof otherkindsof phrase.

The grammaras implemented hereusesthe systemandformalism‘Prolog-embedding typed feature structure grammar’ (henceforth PETFSG) version3. (Seehttp://s tp.ling.u u.se/˜mat sd/petfsg /3/ for documenta-tion.) This systemusestyped featurestructuresin which Prolog-termsmay beembedded.Prologproceduresmaybecalledfrom inside therules.Here,Prolog-termsareusedto representsemanticobjects.Prologis only usedto appendlistsandto createtokenidentifiers.Otherwise,thegrammarreliesonunification.

The grammarassociatessentenceswith semanticrepresentationswhich (in1A report on a previousversionof this work wasgivenin RUUL (Reportsfrom UppsalaUni-

versityDeptof Linguistics)34, 1999.

many cases)areunderspecifiedwith respectto scopalrelations.Additional Pro-log procedures,externalto thegrammar, areusedto computethepossiblescopalresolutions.Theseareappliedas‘postparseoperations’,seebelow.

The files of the implementation are available at the URLhttp://st p.ling.uu .se/˜mats d/tds/3/f / . An overview is given inappendixD.

1.1 The sign type and its features

The type sign is a subtypeof the type aops , to be understoodas absentorpresentsign. Theonly othersubtypeis neg s , which is usedto negatethepres-enceof a sign.(This possibility is usedto preventexpressions from beingassoci-atedwith headsasamodifiers.Seebelow.)

A sign FS is associatedwith featuresasfollows:

sign featur es[token:pr olog_term ,

head:hea d_sort,spr:list ,spr_inc: boolean,comps:li st,slash:li st,cont:con t_sort,pm:punct _mark]

The featuresareusedasdescribedin the backgroundarticle,with theexceptionof spr inc , slash , andpm. The booleanfeaturespr inc means‘specifierincorporated’and is usedto distinguishphraseswhich containa specifiercon-stituentfrom thosethatdo not (in caseswherespr is theemptylist). spr incplaysa role in the treatmentof adjectives. The slash featureis not yet put touse.The valueof the featurepm is thepunctuationmarkdelimiting a phrase,ora valueindicating theabsenceof apunctuationmark.(Consultthegrammarcodefor details.)

1.2 cont (ent) features

Thevalueof thesign featurecont (ent)hasavalueof thetypecont sort .

cont_so rt featur es[hook:ho le_type,

h:holes ,tds:pro log_term,

2

glob:pr olog_term ,tree:pr olog_term ,rss:pro log_term] ,

Thefeatureshook andtds (tokendependency statements),areusedasdescribedin thebackgroundarticle.Theholefeaturesarecollectedunderthefeatureh (seebelow). Thefeaturesglob (al), tree , andrss (reading-specificstatements) areusedin thecomputationof scopallyresolvedreadings(seebelow).

Theholefeaturesareof thetypehole type , definedasfollows by relevantpartsof thetypeandfeaturedeclaration:

hole_ty pe subsumes [closed subsumes [],hole subsumes [

hole_n subsumes [],hole_v subsumes []]],

hole featur es[ltop:pr olog_term ],

hole_n features[key:pro log_term] ,

hole_v features[extarg: prolog_te rm],

Thenon-closed holesareof two kinds: nominal(hole n) ones,carryingltopandkey features,andverbal(hole v ) ones,carrying ltop andextarg fea-tures.

Thefeatureh carriesaholes value,asfollows:

holes subsu mes [holes_v subsumes [],holes_d subsumes []],

holes featu res[mod_hol e:hole_ty pe],

holes_v features[subj_ho le:hole_t ype,

comp_holes:list] ,

3

holes_d features[spec_ho le:hole_t ype]

So, the hole collections (of the holes type) are either verbal (holes v )or determiner-related (holes d). The holes v hole collections comprisea mod hole , a subj hole , and the complementholes, collected undercomp holes (seebelow). The holes v structurescarry a mod hole and aspec hole . Thecomp holes featurecarrya list value.Its elementsareholeobjects,eachassociatedwith thecorrespondingelementon thecomps list.

2 Tense,perfectivity, and progressivity

Thegrammaronly ‘records’ tense,perfectivity, andprogressivity. The treatmentpresentedshouldbereplacedby a betterone.

The tense,perfectivity, and progressivity information is associatedwith averbal head featurev sf (verbal semanticfeatures).Its value is a complexterm ‘ [ T, P, Q] ’ containingthreefeatures,T for basictense,preteritbeingthe‘+’ case.Threepossible values:present(‘ - ’), preterit (‘+’), and tenseless(‘n’,for the caseof infinitive). The P valuerepresentsperfectivity, non-perfect(‘ - ’)andperfect(‘+’ ) beingthealternatives. Finally, Q standsfor progressivity. Non-progressive (‘ - ’) andprogressive (‘+’) arethepossibilitieshere.Examples:

‘ [-,-,-] ’ pres,non-perf,non-progr Mary smiles.‘ [-,-,+] ’ pres,non-perf,progr Mary is smiling.‘ [-,+,-] ’ pres,perf,non-progr Mary hassmiled.‘ [-,+,+] ’ pres,perf,progr Mary hasbeensmiling.‘ [+,-,-] ’ pret,non perf,non-progr Mary smiled.‘ [+,-,+] ’ pret,non-perf,progr Mary wassmiling.‘ [+,+,-] ’ pret,perf,non-progr Mary hadsmiled.‘ [+,+,+] ’ pret,perf,progr Mary hadbeensmiling.

Thesetriplesaretransferredto theverbEPs,connectedto thefeaturesf . Thethreefeaturesareconsequentlyseenaspropertiesof themainverbtoken.

3 Token identifier assignment

The TDS grammarpresupposesthat thegrammaticaldescriptionsuniquelyiden-tify the tokens to which they apply. This meansthat eachtoken must be as-signedauniqueidentifier. This is doneprocedurallywith thehelpof thepredicatelabel token/3 , which is calledjust beforea lexical inactiveedgeis storedinthechart:

4

label_tok en(Desc,N ,Str):-name( N,Name),name( Str,StrN) ,appen d([116|Na me],[95|S trN],NN),name( TokId,NN) ,path_ value(Des c,token,p rolog_ter m(TokId,_ )).

The label token/3 argumentsaretheFS andthenumbergiving theposi-tion of theword in the input string(an integer).The tokenidentifier, assignedtothefeaturetoken , is anatomformedby ‘ t ’ followedby thepositionnumber, anunderscorecharacter, andthe ortographicform, e.g.‘ t3 house ’ if the token isaninstanceof houseat position3.

4 Inflectional morphology

The following Prologclausesdefinethe (very simple) morphological processesusedby thegrammar:

morpholog y(id,X,X) .

morpholog y(affx(A) ,X,Y):-name( X,N),name( A,AN),appen d(N,AN,NN ),name( Y,NN).

Theidentifier‘ id ’ representsidentityand‘affx( A) ’ additionof theaffix A.

5 The representation of TDS information

TheTDS relationsappearasfollows:

‘c1 ’: Coindexationbetweena quantifieranda predicatewith respectto thefirstargumentposition.

‘c2 ’: Coindexationbetweena quantifieranda predicatewith respectto thesec-ondargumentposition.

‘ restr ’: Immediateoutscoping betweenaquantifierandits restriction.

‘body ’: Immediateoutscopingbetweenaquantifierandits body.

5

‘ptop ’: Immediateoutscopingbetweena paratacticpredicateandthe scopallytopmostnon-quantifiernodeof theparatacticargument.

‘ptop ’: Therelationequalitymoduloquantifiers, dueto Copestakeetal. (2001).It makesit possible to statescopeconstraints(of lexical origin).

‘L’: This relationis three-placehere.It holdsof a token,thelexical expression ofwhich it is aninstance,anda termdescribingits logicalvalency, seebelow.

‘parg ’: Holdsof aparatacticrelationandthewholeparatacticargumentsubtree.

‘anchor ’ : Holdsof aparatacticrelationandits anchorargument.

‘ Ind ’: Is usedin suchaway that‘ Ind( N, T) ’ is theindividualassociatedwithargumentposition N of thetokenT given currentbindings.

Semanticvalenciesarerepresentedby termsasfollows:

‘q1 ’: One-placequantifier(i.e. aname).

‘q2 ’: Two-placequantifier(i.e. two).

‘p([a1]) ’ : Intransitivenon-paratacticrelation(i.e. smile).

‘p([a1,a2]) ’: Transitivenon-paratacticrelation(i.e. read).

‘p([para]) ’ : Intransitiveparatacticrelation(i.e. probably).

‘p([a1,para ]) ’: Transitive relationwith a secondparatacticargumentposi-tion (i.e. say).

6 Postparseoperations

The postparsealternatives make partial selectionsof information to displayandcomputescopalresolutionsfrom underspecifiedsemanticrepresentations.Thefollowing aredefined:

� ‘nomod’ : No postparseoperationis applied.

� ‘cont ’: Only thevalueof thefeaturecont is selectedfor output.

� ‘ resl1 ’ : The setof scopalresolutions of the cont valuearecomputed.Thisversionassumesthatnamestakewidestpossiblescope.Only thevalueof thefeaturecont is thenselectedfor output.

� ‘ resl2 ’ : The ‘ resl2 ’ resolution is different from ‘ resl1 ’ resolutiononly in allowing namesto beoutscopedby otherquantifiers.Only thevalueof thefeaturecont is thenselectedfor output.

6

6.1 Specification of readings

Thecont [ent] featuresglob (al), rss , andtree areusedin thespecificationofscopallyresolvedreadings.Thefeatureglob (al) is a list of thea priori topmostquantifiersin the caseof ‘ resl1 ’ resolution.The rss (reading-specificstate-ments)featurecarriesa list of additionalTDS statementspertainingto thereadingin question.Thetree feature,which is redundantgiventheotherfeatures,givesusaneasyto readpictureof theTDS treerepresentingthereading.(Thepredicatedisp prolog term/3 is responsible for displaying thesetreestructuresin asuitablefashion.)

The specificationof scopallyresolved readingsis bestexplainedwith refer-enceto an example.(This examplealso appearsin appendixA.) The sentenceMary saysthat two studentssmiled receives the following underspecifiedTDS

representation.

[L(t1_Mar y,Mary,q1 ),L(t2_say s,say,p([ a1,para]) ),c1(t1_Ma ry,t2_say s),ptop(t2_ says,P0),P0 qeq t6_sm iled,L(t4_two ,two,q2),restr(t4 _two,P1),P1 qeq t5_st udents,L(t5_stu dents,stu dent,p([a 1])),c1(t4_tw o,t5_stud ents),L(t6_smi led,smile ,p([a1])) ,c1(t4_tw o,t6_smil ed)]

Here,underspecificationis dueto thePrologvariables‘P0’ and‘P1’ andto theabsenceof ‘body ’ statements.Thescoperesolutionalgorithmswork by instanc-ing variablesandcomputingadditionalinformation.

Oneof the (two) readingsof this examplegiven by the ‘ resl1 ’ resolutionalgorithmcanbecharacterizedasfollows:

t1 Mary -t4 two� t5 students

t2 says - t6 smiled

This readingcorrespondsto tds , glob , rss , andtree valuesasfollows. Thetds valueis aninstanceof thecorrespondingunderspecifiedtds value:

[L(t1_Mar y,Mary,q1 ),L(t2_say s,say,p([ a1,para]) ),c1(t1_Ma ry,t2_say s),

7

ptop(t2_ says,t6_s miled),t6_smile d qeq t6_smil ed,L(t4_two ,two,q2),restr(t4 _two,t5_s tudents),t5_stude nts qeq t5_st udents,L(t5_stu dents,stu dent,p([a 1])),c1(t4_tw o,t5_stud ents),L(t6_smi led,smile ,p([a1])) ,c1(t4_tw o,t6_smil ed)]

Theglob (al) valueis thelist of theonly a priori topmostquantifier:

[t1_Mary]

The rss TDS statementsdefinea quantifierbody, a paratacticargument,andananchor:

[body(t4_ two,t2_sa ys),parg(t2_ says,t6_s miled),anchor(t 2_says,[t (t6_smile d,1,Ind(t 6_smiled, 1))])]

The tree valuegivesan overview of the scopalsituationandis printedasfol-lows:

[t4_two:q 2n(t5_stu dents,t2_ says),[t5_stude nts:[]],[t2_says: ptop(t6_s miled),

[t6_sm iled:[]]] ]

7 Phrasestructure rules

A few commentsshouldbemadeconcerningthephrasestructurerules.TheHPSG

head-complementrule is implementedwith the help of two rules.Oneof themis for the casein which no complementis present.The otheroneallows a headto find a complement sister, oneat a time. Due to semantics,the specifier-headconstructiongives us two rules.One is for the subjectcase,in which the (ver-bal) headis alsothesemantichead.Theotherrule is for thedeterminerspecifiercase,in whichadeterminer, whichis asemantichead,is associatedwith syntactic(nominal)head.

phrase from word : Thisrulecoversthecasewhenthehead-complementruleapplieswith anemptylist of complements, i.e. whenthemotherphras edominatesaheadword withoutsisters.

8

hd comps: This rule covers the casewhen the head-complementrule applieswith a non-emptycomps list on the head.Only one complementis in-corporatedon eachapplicationof the rule. The complement holesin thecomp holes list correspondone-by-oneto thecomps list items.So,thevaluesof thetwo featureson themotherareequalto thetails of thecorre-spondingvalueson theheaddaughter.

subj spr hd : This rule is for specifier-headconstructionsin which thespeci-fier is asubjectto averbal(syntactic)head,whichis alsothesemantichead.

det spr hd : This rule is for specifier-headconstructionsin which thespecifierisadeterminerandthesyntacticheadanoun.Thedetermineris thesemanticheadhere.

mod hd : Premodifier-headrule.

phr punct : Phrase-punctuation-markrule. A phrasewithout a punctuationmark—formally, pm:neg p—combineswith apunctuation markandformsa phrasewith the featurepm specifyingthe sisterpunctuation mark. Themotheranddaughterphrasesotherwisecarrythesamefeaturevalues.

In orderto make it easierto seewhich rule hasproducedananalysis,thereisa subtypeto thetypephrase for eachphrasestructurerule:

phrase wp phrasefrom wordconstructionphrase hc head-complementconstructionphrase ssh subjectspecifier-headconstructionphrase sph determinerspecifier-headconstructionphrase mh modifier-head constructionphrase hp head-punctuation-markconstruction

Thesedistinctionsdonotplayany linguistic role.

References

Copestake, A., D. Flickinger, I. A. Sag, & C. Pollard (1999), ‘Minim al Re-cursion Semantics:An Introduction’. UnpublishedMS, available under URL:http://ww w-csli.st anford.ed u/˜aac/ paper s/newmrs. ps (asof December14,2001).

Pollard,C.andI. A. Sag:1994,Head-DrivenPhraseStructureGrammar, Chicago& London,TheUniversity of ChicagoPress.

9

Appendix A: Sampleanalyses

The sentenceMary saysthat two studentssmiledhastwo readings.This is theanalysisgiven directly by the grammar. The semanticrepresentationis scopallyunderspecified:

Thetwo readingsaregeneratedby the‘ resl1 ’ postoperation.Thenamequanti-fier is assignedglobalscope.First reading:

10

Secondreading:

11

Thesearea few examplesof lexical entries.Theverbform says:

12

Theadverb intentionally:

13

Theadverbprobably:

14

Appendix B: The grammar

This appendixgives a full listing of the grammar(‘gram tds.pl ’ ) describedin this report.Commentsappearwithin boxed paragraphs.Thereis a file withadditionallexical entries(‘ lex tds.pl ’ ).

grammar ’TD S-1’.

Declaration of types and featuresdecla rati on

[aops sub sumes [ % abse nt or prese nt sig nneg_s subs umes [], % abse nt sig nsig n subsu mes [ % pres ent sign

lex item subs umes [ % lexi cal itemlxm subs umes [ % lexe me

infl _lxm sub sumes []] , % infl ected lex emewor d sub sumes [ % word

word _sat sub sumes [], % sat urate dword _uns at subs umes []] ], % uns atura ted

phr ase sub sumes [ % phra se-l evel sign sphr ase_wp subs umes [], % phra se from wor dphr ase_h c subs umes [], % head -comp leme ntphr ase_s sh sub sumes [], % subj ect-h eadphr ase_d sh sub sumes [], % spec ifier -hea dphr ase_mh subs umes [], % modi fier- headphr ase_h p subs umes []]] ], % head -punc tuat ion

head _sor t subsu mes [ver b subsu mes [ % ver bal

v sub sumes [], % ordi nary pos verbcpl zer sub sumes []], % compleme ntiz er

nom sub sumes [ % nominalcnn oun sub sumes [], % common nounsper spron sub sumes [], % pers onal pro nounprn oun sub sumes []], % prop er nouns

adj sub sumes [], % adj ectiv eadv sub sumes [], % adv erbcon j subsu mes [], % con junct iondet ermi n sub sumes [], % det ermin erpre p subsu mes []], % pre posit ion

cont _sor t subsu mes [], % con tent stru cture

15

hole s subs umes [ % hol e col lect ionhol es_v subs umes [], % for verb alshol es_d subs umes []], % for dete rmin ers

hole _typ e subsu mes [ % hol e typ eclo sed subsu mes [], % "clo sed" (un avail able )hol e subsu mes [ % "ope n" hol e

hol e_n sub sumes [], % for nomi nalshol e_v sub sumes []]], % for verb als

bool ean subsu mes [ % tru e/fal se booleanno subs umes [],yes sub sumes []] ,

number_s ort sub sumes [ % numbersin g subsu mes [],plu r subsu mes []],

def_ sort subs umes [ % def inite nessdef sub sumes [],ind ef subs umes []] ,

case _sor t subsu mes [ % cas enomin subs umes [ % i.e. non- geni tive

subc subs umes [], % subje ct for mobjc subs umes []], % objec t form

gen sub sumes []] , % genit ive

pers _sor t subsu mes [ % per son:p1 subs umes [], % firs tp2 subs umes [], % seco ndp3 subs umes []], % thir d

vfor m_sort subs umes [ % ver bal inf lect ionfin ite subsu mes [

pres ent sub sumes [],pret erit subs umes []],

inf init e sub sumes [infi nitiv e subs umes [],prp subsu mes [], % pres ent part icipl epsp subsu mes []]], % past par tici ple

16

v_ki nd_s ort sub sumes [ % kin d of verbaux sub sumes [], % auxi liar y verbnot aux subsu mes []], % non- auxi liar y ver b

punc t_ma rk subs umes [ % punctuat ion marks :neg_p subs umes [], % no punctua tion markful l_st op subs umes [],comma subs umes [],col on subs umes [],semi_co lon sub sumes [],exc lam subsu mes [],questnm subs umes []]]

where

[sign fea tures[tok en:p rolog _ter m,

head:he ad_so rt,spr :lis t,spr _inc :bool ean, % spec ifie r inc orpo ratedcomps:l ist,sla sh:l ist,con t:co nt_so rt,pm:punc t_mar k],

lexi tem featu res[lex eme: prolo g_te rm],

cont _sor t featu res[hoo k:ho le_ty pe,

h:h oles ,tds :pro log_t erm,glo b:pr olog_ term ,rss :pro log_t erm,tre e:pr olog_ term ],

hole fea tures[lto p:pr olog_ term ],

hole _n fea tures[key :pro log_t erm] ,

hole _v fea tures

17

[ext arg: prolo g_te rm],

hole s feat ures[mod _hol e:hol e_ty pe],

hole s_v featu res[sub j_ho le:ho le_t ype,

comp_ho les:l ist] ,

hole s_d featu res[spe c_ho le:ho le_t ype],

head _sor t featu res[mod :aop s, % allo wed to modi fy

pre mod: boole an, % premodifi erspe c:si gn], % "spe cifie d"

% (see rule det_ spr_ hd)nom feat ures

[num :num ber_s ort, % numberdef :def _sort , % defi niten esscas e:ca se_so rt, % caseper s:pe rs_so rt], % pers on

verb fea tures[vfo rm:v form_ sort , % infl ectio n

v_k ind: v_kin d_so rt, % kind of ver bv_s f:pr olog_ term ]]. % semantic fea tures

Information concerning tense, perfectivity, and progressivity is associated with a theverbal head feature v sf (verbal semantic features). Its value is a complex term‘ [ T, P, Q] ’ containing threefeatures,T for basictense, preterit being the‘+’ case. Threepossiblevalues:present (‘ - ’), preterit (‘+’ ), andtenseless(‘n’ , for thecaseof infinitive).Prepresentsperfectivity, non-perfect(‘ - ’) andperfect (‘+’) beingthealterntives.Finally, Qstands for progressivity. Non-progressive (‘ - ’) andprogressive (‘+’) arethepossibiliti eshere.(This is only a tentative treatmentof thesefeatures.)

Initial symbol definitioniniti al_s ymbol

[hea d:[v form: fini te], % I.e . sente ncespr :{},comps:{ },sla sh:{ }].

Leaf symbol definition

18

leaf_ symbol word .

The phrase structure rules

Phrase from word rulephras e_fr om_word rul e

[phra se_wp,toke n: <>T1,head :xHF P,comps:{} ,spr: xSpr ,spr_ inc: no,slas h:{} ,cont :xCo nt,pm:n eg_p ] ===>

[ [wor d_un sat,tok en: <>T1,head:xH FP,comps:{ },spr :xSp r,spr _inc :no,sla sh:{ },con t:xC ont,pm:neg_ p]].

The head-complement ruleThisversionof thehead-complementrulecombinestheheadwith thefirst complementasrequiredby thefirst item on thecomps list. This meansthatoneapplicationof this rulepercomplement is required.The‘+’ operator representsphysical aggregation. ThePrologcall computes themother’s slash andtds values.

hd_co mps rule

[xMtr ,phra se_h c,toke n: <>( T1+T2),head :xHF P,comps:xC omps,spr: xSpr ,spr_ inc: xSpr Inc,cont :[ho ok:x Hook,

19

h:[s ubj_h ole: xSH,comp_hol es:x CHs,mod_hole :xMH]],

pm:n eg_p ] ===>

[ [xHe ad,tok en: <>T1,head:xH FP,spr :xSp r,spr _inc :xSpr Inc,comps:x CompˆxComps,con t:[h ook:x Hook,

h:[s ubj_h ole: xSH,comp_hol es:x CHˆxCHs,mod_hole :xMH]],

pm:neg_ p],

[xCo mp,tok en: <>T2,con t:[h ook:x CH],pm:neg_ p],

prol og [mother_ daug hters ,xMtr, xHead,xC omp]] .

The specifier-head rule, subject case

subj_ spr_ hd rule

[xMtr ,phra se_s sh,toke n: <>( T1+T2),head :xHF P,spr: {},spr_ inc: yes,comps:{} ,cont :[ho ok:x Hook,

h:[s ubj_h ole: clos ed,comp_hol es:x CHs,mod_hole :xMH]],

pm:n eg_p ] ===>

[ [xSp r,tok en: <>T1, % Spec-pr incip le not need ed.

20

con t:[h ook:x SH],pm:neg_ p],

[xHe ad,tok en: <>T2,head:xH FP,spr :{xS pr},comps:{ },con t:[h ook:x Hook,

h:[ subj_ hole :xSH,comp_hole s:xCH s,mod_hole: xMH]] ,

pm:neg_ p],

pro log [moth er_d augh ters,xMtr ,xSp r,xH ead]] .

The specifier-head rule, determiner casePollard’s andSag’s (1994: 51) ‘SpecPrinciple’ is hard-codedinto therule.

det_s pr_h d rule

[xMtr ,phra se_d sh,toke n: <>( T1+T2),head :xHF P,spr: {},spr_ inc: yes,comps:{} ,cont :[ho ok:x Hook,

h:[s pec_h ole: clos ed,mod_hole :xMH]],

pm:n eg_p ] ===>

[ [xSp r,tok en: <>T1,head:[d eterm in,

spe c:xHe ad],con t:[h ook:x Hook,

h:[ spec_ hole :xSpe cHook,mod_hole: xMH]] ,

pm:neg_ p],

21

[xHe ad,tok en: <>T2,head:xH FP,spr :{xS pr},comps:{ },con t:[h ook:x SpecHook],pm:neg_ p],

prol og [mother_ daug hters ,xMtr, xSpr ,xHe ad]].

The premodifier-head rule

mod_hd rule

[xMtr ,phra se_mh,toke n: <>( T1+T2),head :xHF P,spr: xSpr ,spr_ inc: xSpr Inc,comps:xC omps,cont :[ho ok:x ModHook,

h:[s ubj_h ole: xSH,comp_hol es:x CHs,mod_hole :xMH]],

pm:n eg_p ] ===>

[ [xMo d,tok en: <>T1,head:[m od:xH ead,

pre mod:y es],spr :{},comps:{ },con t:[h ook:x ModHook,

h:[ mod_hole: xHdHook]] ,pm:neg_ p],

[xHe ad,tok en: <>T2,head:xH FP,spr :xSp r,spr _inc :xSpr Inc,

22

comps:x Comps,con t:[h ook:x HdHook,

h:[ subj_ hole :xSH,comp_hole s:xCH s,mod_hole: xMH]] ,

pm:neg_ p],

prol og [mother_ daug hters ,xMtr, xMod,xHe ad]].

Phrase-punctuation-mark ruleIncorporates a punctuationmark in a phrase:A phrasewith pm:neg p combines with apunctuationmarkandformsaphrasewith thefeaturepmspecifying thesisterpunctuationmark.Themotheranddaughterphrasesotherwisecarrythesamefeaturevalues.

phr_p unct rul e

[phra se_h p,toke n: <>Token,head :xHd ,spr: {},spr_ inc: xSpr Inc,comps:{} ,cont :xCo nt,pm:x PM] ===>

[ [phr ase,tok en: <>Tok en,head:xH d,spr :{},spr _inc :xSpr Inc,comps:{ },con t:xC ont,pm:neg_ p],

[xPM,punct_m ark]] .

Punctuation mark entries’.’ >>>

full _sto p.

’,’ >>>

23

comma.

’?’ >>>ques tnm.

’!’ >>>excl am.

’:’ >>>colo n.

’;’ >>>semi _col on.

Lexical information

General definitions

conte nt_l exit em is_s hort _for[toke n: <>Token,

cont :[ho ok:[l top: <>Token] ],slas h:{} ,spr_ inc: no,pm:n eg_p ].

‘cont ent lexit em’ appliesto lexical entrieswhich contribute to semantics.Thefea-turestoke n andcon t :hook :ltop aredefined.

form_ lexi tem is_sh ort_ for[slas h:{} ,

spr_ inc: no,pm:n eg_p ].

‘ form lex item ’ applies to lexical entrieswhich do not contribute to semantics. Thefeaturestoke n andcont :hook :ltop arenot defined.

np_su bj is_ short _for[hea d:[n om,

cas e:sub c],spr :{},comps:{ },sla sh:{ },pm:neg_ p].

Subjectform NPs.

24

np_ob j is_s hort_ for[hea d:[n om,

cas e:obj c],spr :{},comps:{ },sla sh:{ },pm:neg_ p].

Objectform NPs.

sente nce is_s hort_ for[hea d:[v ,

vfo rm:fi nite ],spr :{},spr _inc :yes,comps:{ }].

Definition of sentence.

inf_p hras e_pl ain is_ shor t_for[hea d:[v ,

vfo rm:in fini tive] ,comps:{ },pm:neg_ p].

Infinitival phraseswithout a to complementizer.

inf_p hras e_to is_s hort _for[hea d:[c plzer ,

vfo rm:in fini tive] ,comps:{ },pm:neg_ p].

Infinitival phraseswith a to complementizer.

prp_p hras e is_sh ort_ for[hea d:[v ,

vfo rm:pr p],comps:{ },pm:neg_ p].

Presentparticiple phrases.

psp_p hras e is_sh ort_ for[hea d:[v ,

vfo rm:ps p],comps:{ },pm:neg_ p].

25

Pastparticiple phrases.

no_mod is_s hort_ for[hea d:[m od:ne g_s] ,

con t:[h :[mod _hol e:cl osed] ]].

For signs which cannot occuras(pre-or post-) modifiers.

Proper nouns

prope r_no un is_s hort _for[nfs con tent_ lexi tem,

tok en: <>Tok en,lex eme: <>Lexeme,head:[p rnoun ,

num:sing ,per s:p3] ,

spr :{},comps:{ },nfs no_mod,con t:[h ook:[ key: <>Token] ,

tds : <>[ ’L’( Token ,Lex eme, q1)]] ].

’Gali leo’ >>>[wor d_un sat,

nfs pro per_n oun,lex eme: <>’G alil eo’] .

Personal pronouns

perso nal_ pron oun is_ shor t_for[nfs con tent_ lexi tem,

tok en: <>Tok en,lex eme: <>Lexeme,head:pe rspro n,spr :{},comps:{ },nfs no_mod,con t:[h ook:[ key: <>Token] ,

tds : <>[ ’L’( Token ,Lex eme, q1)]] ].

he >>>[nfs per sonal _pro noun ,

head:[p ers:p 3,

26

num:sing ],lex eme: <>’h e’].

Determiners

deter mine r is_sh ort_ for[nfs for m_lex item ,

wor d_sa t,tok en: <>Tok en,lex eme: <>Lexeme,head:de termi n,spr :{},comps:{ },nfs no_mod,con t:[h ook:[ key: <>Token] ,

h:[ spec_ hole :[key : <>Token,ltop : <>LTOP]],

tds : <>[ ’L’( Token ,Lex eme, q2),rest r(Tok en,R estr ),Rest r qeq LTOP]]] .

many >>>[nfs det ermin er,

head:[s pec:[ head :[nu m:plu r]]] ,lex eme: <>’m any’ ].

the >>>[nfs det ermin er,

head:[s pec:[ head :[nu m:sin g]]] ,lex eme: <>’t he_s ing’ ].

the >>>[nfs det ermin er,

head:[s pec:[ head :[nu m:plu r]]] ,lex eme: <>’t he_p lur’ ].

Two senses of the, asnumber is reflected (lexically) in the lo value.

Noun morphology

lexru le sin g_nou nmorph idinput [inf l_lxm ,

tok en:x0 ,

27

lex eme:x 1,head:[x2 ,

cnno un],spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7]

outpu t [wor d_uns at,tok en:x0 ,lex eme:x 1,head:[x2 ,

cnno un,num: sing ],

spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7] .

lexru le plu r_nou nmorph affx (s)input [inf l_lxm ,

tok en:x0 ,lex eme:x 1,head:[x2 ,

cnno un],spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7]

outpu t [wor d_uns at,tok en:x0 ,lex eme:x 1,head:[x2 ,

cnno un,num: plur ],

spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7] .

28

Thecommonkind of singular/plural noun inflection in English.

Common nouns requiring a specifier

common_no un_s pr is_s hort _for[nfs con tent_ lexi tem,

tok en: <>Tok en,lex eme: <>Lexeme,head:[c nnoun ,

per s:p3] ,spr :{[h ead:d eter min,

pm:n eg_p] },comps:{ },nfs no_mod,con t:[h ook:[ key: <>SprKey ,

ltop : <>Tok en],h:[ subj_ hole :clos ed],tds : <>[ ’L’( Token ,Lex eme, p([a1 ])),

c1(S prKey ,Tok en)] ]].

This doesnot give usbareplurals.

book >>>[inf l_lx m,

nfs common_noun_ spr,lex eme: <>book].

Verbs: general aspects

verb_ gene ral is_sh ort_ for[nfs con tent_ lexi tem,

head:v,nfs no_mod].

Verb form abbreviations

prese nt_t hird _sing ular is_s hort _for[hea d:[v form: pres ent,

v_s f: <>[’ -’,’ -’,’- ’]],spr :{[h ead:[ pers :p3,

num: sing ]]}].

prese nt_t hird _plur al is_ short _for[hea d:[v form: pres ent,

v_s f: <>[’ -’,’ -’,’- ’]],

29

spr :{[h ead:[ pers :p3,num: plur ]]}].

prete rit_ thir d_sin gula r is_sh ort_ for[head :[vf orm:p rese nt,

v_s f: <>[’ +’,’ -’,’- ’]],spr: {[he ad:[p ers: p3,

num:sin g]]}] .

prete ritu m is_sh ort_ for[hea d:[v form: pret erit ,

v_s f: <>[’ +’,’ -’,’- ’]]] .

infin itiv e_fo rm is_s hort _for[hea d:[v form: infi niti ve,

v_sf : <>[ ’n’, ’-’,’ -’]] ].

prp_f orm is_s hort_ for[hea d:[v form: prp,

v_sf : <>[ _,_, ’+’]] ].

psp_f orm is_s hort_ for[hea d:[v form: psp,

v_sf : <>[ _,’+ ’,’-’ ]]].

Verb inflection

lexru le v_i nfl_i nfinmorph idinput [inf l_lxm ,

tok en:x0 ,lex eme:x 1,head:[x2 ,

verb ],spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7]

outpu t [wor d_uns at,nfs infi niti ve_fo rm,tok en:x0 ,lex eme:x 1,head:x2,

30

spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7] .

lexru le v_i nfl_t hird _plu ralmorph idinput [inf l_lxm ,

tok en:x0 ,lex eme:x 1,head:[x2 ,

verb ],spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7]

outpu t [wor d_uns at,nfs pres ent_ third _plu ral,tok en:x0 ,lex eme:x 1,head:x2,spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7] .

lexru le v_i nfl_t hird _sin gularmorph affx (s)input [inf l_lxm ,

tok en:x0 ,lex eme:x 1,head:[x2 ,

verb ],spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7]

outpu t [wor d_uns at,nfs pres ent_ third _sin gula r,

31

tok en:x0 ,lex eme:x 1,head:x2,spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7] .

lexru le v_i nfl_p retmorph affx _ch_e (ed)input [inf l_lxm ,

tok en:x0 ,lex eme:x 1,head:[x2 ,

verb ],spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7]

outpu t [wor d_uns at,nfs pret erit um,tok en:x0 ,lex eme:x 1,head:x2,spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7] .

lexru le v_i nfl_p spmorph affx _ch_e (ed)input [inf l_lxm ,

tok en:x0 ,lex eme:x 1,head:[x2 ,

verb ],spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,

32

con t:x7]outpu t [wor d_uns at,

nfs psp_ form ,tok en:x0 ,lex eme:x 1,head:x2,spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7] .

lexru le v_i nfl_p rpmorph affx _ch_e (ing )input [inf l_lxm ,

tok en:x0 ,lex eme:x 1,head:[x2 ,

verb ],spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7]

outpu t [wor d_uns at,nfs prp_ form ,tok en:x0 ,lex eme:x 1,head:x2,spr :x3,spr _inc: x4,comps:x5 ,sla sh:x6 ,con t:x7] .

Intransitive verbs

verb_ intr ansi tive is_s hort_ for[nfs ver b_gen eral ,

tok en: <>Tok en,lex eme: <>Lexeme,spr :{[n fs np_s ubj] },comps:{ },con t:[h ook:[ exta rg: <>SubjKey ],

33

h:[ subj_ hole :[key : <>SubjKey ]],tds : <>[ ’L’( Token ,Lex eme, p([a1 ])),

c1(S ubjKe y,To ken) ]]].

smile >>>[inf l_lx m,

nfs ver b_int rans itiv e,lex eme: <>smile] .

Ordinary transitive verbs

verb_ tran siti ve is_s hort _for[nfs ver b_gen eral ,

tok en: <>Tok en,lex eme: <>Lexeme,spr :{[n fs np_s ubj] },comps:{ [nfs np_o bj]} ,con t:[h ook:[ exta rg: <>SubjKey ],

h:[ subj_ hole :[key : <>SubjKey ],comp_hole s:{[k ey: <>ObjKey] }],

tds : <>[ ’L’( Token ,Lex eme, p([a1 ,a2] )),c1(S ubjKe y,To ken) ,c2(O bjKey ,Tok en)] ]].

Thean feature is giventhenil value’-’ to indicatethatanchoringis not applicable.

help >>>[inf l_lx m,

nfs ver b_tra nsit ive,lex eme: <>help].

Paratactic verbs

verb_ para tact ic is_s hort _for[nfs ver b_gen eral ,

tok en: <>Tok en,lex eme: <>Lexeme,spr :{[n fs np_s ubj] },comps:{ [head :ver b,

comps:{} ,spr: {},

pm:ne g_p] },con t:[h ook:[ exta rg: <>SubjKey ],

h:[ subj_ hole :[key : <>SubjKey ],comp_hole s:{[l top: <>LTOP]} ],

34

tds : <>[ ’L’( Token ,Lex eme, p([a1 ,par a])),c1(S ubjKe y,To ken) ,ptop (Toke n,CT T),CTT qeq LTOP]]] .

claim >>>[in fl_l xm,

nfs verb _para tact ic,lexe me: <>cla im].

Raising verbs

verb_ subj _rai sing is_s hort_ for[nfs ver b_gen eral ,

tok en: <>Tok en,lex eme: <>Lexeme,spr :{[x Spr,

nfs np_s ubj] },comps:{ [spr: {xSp r},

pm:n eg_p ]},con t:[h ook:[ exta rg: <>SubjKey ],

h:[ subj_ hole :[key : <>SubjKey ],comp_hole s:{[l top: <>LTOP,

exta rg: <>SubjKey ]}],tds : <>[ ’L’( Token ,Lex eme, p([pa ra]) ),

ptop (Toke n,CT T),CTT qeq LTOP]]] .

verb_ subj _rai sing_ plai n is_sh ort_ for[nfs ver b_sub j_ra isin g,

comps:{ nfs inf _phr ase_p lain }].

Takesascomplement aninfinitival phrasewithout a to complementizer.

would >>>[wor d_un sat,

nfs ver b_sub j_ra isin g_pla in,nfs pre terit um,lex eme: <>would] .

verb_ subj _rai sing_ to is_ short _for[nfs ver b_sub j_ra isin g,

comps:{ nfs inf _phr ase_t o}].

Takesascomplement aninfinitival phrasewith a to complementizer.

35

ought >>>[wor d_un sat,

nfs ver b_sub j_ra isin g_to,nfs pre terit um,lex eme: <>ought] .

Subject control verbs

verb_ subj _con trol is_s hort_ for[nfs ver b_gen eral ,

tok en: <>Tok en,lex eme: <>Lexeme,spr :{[x Spr,

nfs np_su bj]} ,comps:{ [nfs inf_ phra se_to ,

spr: {xSp r},pm:n eg_p ]},

con t:[h ook:[ exta rg: <>SubjKey ],h:[ subj_ hole :[key : <>SubjKey ],

comp_hole s:{[l top: <>LTOP,exta rg: <>SubjKey ]}],

tds : <>[ ’L’( Token ,Lex eme, p([a1 ,par a])),c1(S ubjKe y,To ken) ,ptop (Toke n,CT T),C TT qeq LTOP]]].

The verb EP andthe complement EP arecoindexed with respect to their a1 arguments.Takesascomplement aninfinitival phrasewith a to complementizer.

inten d >>>[in fl_l xm,

nfs verb _subj _con trol,lexe me: <>int end] .

Object raising verbs

verb_ obj_ rais ing is_ shor t_for[nfs ver b_gen eral ,

tok en: <>Tok en,lex eme: <>Lexeme,spr :{[n fs np_s ubj] },comps:{ [nfs np_o bj],

[nfs inf_ phra se_to ,spr: {[]} ]},

con t:[h ook:[ exta rg: <>SubjKey ],h:[ subj_ hole :[key : <>SubjKey ],

36

comp_hole s:{[k ey: <>ObjKey] ,[lto p: <>LTOP,

ext arg: <>ObjKey ]}],tds : <>[ ’L’( Token ,Lex eme, p([a1 ,par a])),

c1(S ubjKe y,To ken) ,ptop (Toke n,CT T),CTT qeq LTOP]]] .

expec t >>>[in fl_l xm,

nfs verb _obj_ rais ing,lexe me: <>exp ect] .

Object control verbs

verb_ obj_ cont rol is_ shor t_for[nfs ver b_gen eral ,

tok en: <>Tok en,lex eme: <>Lexeme,spr :{[n fs np_s ubj] },comps:{ [nfs np_o bj],

[nfs inf_ phra se_to ,spr:{ []}] },

con t:[h ook:[ exta rg: <>SubjKey ],h:[s ubj_h ole: [key: <>SubjK ey],

comp_hol es:{ [key: <>ObjKey ],[ltop : <>LTOP,

exta rg: <>Obj Key] }],tds : <>[ ’L’( Token ,Lex eme, p([a1 ,par a])),

c1(S ubjKe y,To ken) ,c2(O bjKey ,Tok en),ptop (Toke n,CT T),CTT qeq LTOP]]] .

persu ade >>>[in fl_l xm,

nfs verb _obj_ cont rol,lexe me: <>per suad e].

Auxiliary verbs

verb_ aux is_s hort_ for[wor d_un sat,

nfs for m_lex item ,

37

head:[v ,v_k ind:a ux],

comps:{ []},con t:[h ook:[ exta rg: <>SubjKey ,

ltop : <>LTOP],h:[s ubj_h ole: [key: <>SubjK ey],

comp_hol es:{ [ltop : <>LTOP,exta rg: <>SubjKey ]}],

tds : <>[ ]]].

Theseverbs only serve to specify thev sf featureson themainverb.

Temporal have

verb_ temp _hav e is_ shor t_for[nfs ver b_aux ,

spr :{[x Subj] },comps:{ [nfs psp_ phra se,

spr: {xSu bj}] }].

have >>>[nfs ver b_tem p_ha ve,

nfs inf initi ve_f orm,comps:{ [head :[v_ sf: <>[ ’n’, _,_]] ]}].

has >>>[nfs ver b_tem p_ha ve,

nfs pre sent_ thir d_sin gula r,comps:{ [head :[v_ sf: <>[ ’-’, _,_]] ]}].

have >>>[nfs ver b_tem p_ha ve,

nfs pre sent_ thir d_plu ral,comps:{ [head :[v_ sf: <>[ ’-’, _,_]] ]}].

had >>>[nfs ver b_tem p_ha ve,

nfs pre terit um,comps:{ [head :[v_ sf: <>[ ’+’, _,_]] ]}].

Progressive be

verb_ prog r_be is_s hort _for[wor d_un sat,

38

nfs ver b_aux ,spr :{[x Subj] },comps:{ [nfs prp_ phra se,

head :[v_ kind :nota ux],spr: {xSu bj}] }].

Progressive berequiresa v kind :notau x complement (cf. � is having seen).

is >>>[nfs ver b_pro gr_b e,

nfs pre sent_ thir d_sin gula r,comps:{ [head :[v_ sf: <>[ ’-’, ’-’,_ ]]]} ].

was >>>[nfs ver b_pro gr_b e,

nfs pre terit _thi rd_si ngul ar,comps:{ [head :[v_ sf: <>[ ’+’, ’-’,_ ]]]} ].

be >>>[nfs ver b_pro gr_b e,

nfs inf initi ve_f orm,comps:{ [head :[v_ sf: <>[ ’n’, ’-’,_ ]]]} ].

been >>>[nfs ver b_pro gr_b e,

nfs psp _form ,head:[v _sf: <>[T ense, _,_] ],comps:{ [head :[v_ sf: <>[ Tens e,+,_ ]]]} ].

Adjectives (tentative treatment)

adj_p arat acti c is_ shor t_for[wor d_un sat,

nfs con tent_ lexi tem,tok en: <>Tok en,lex eme: <>Lexeme,head:ad j,spr :{},comps:{ },head:[m od:[h ead: cnno un,

spr _inc :no,comps:{ },pm:neg_ p],

pre mod:y es],

39

con t:[h ook:[ key: <>SprKey ,ltop : <>Tok en],

h:[ mod_hole: [key: <>SprKe y,ltop : <>LTOP]],

tds : <>[ ’L’( Token ,Lex eme, p([a1 ,par a])),c1(S prKey ,Tok en),ptop (Toke n,CT T),CTT qeq LTOP]]] .

Givesa paratacticanalysisof adjectivesin attributive (modifier)position.

false >>>[nfs adj _para tact ic,

lex eme: <>fa lse] .

Sentence adverbsadv_s ent_ fs is_s hort _for

[wor d_sa t,nfs con tent_ lexi tem,tok en: <>Tok en,lex eme: <>Lexeme,head:ad v,spr :{},comps:{ },head:[m od:[w ord,

head:v,pm:neg_ p],

pre mod:y es],con t:[h ook:[ exta rg: <>Spr Key] ,

h:[ mod_hole: [ltop : <>LTOP,exta rg: <>SprKey] ],

tds : <>[ ’L’( Token ,Lex eme, p([pa ra]) ),ptop (Toke n,CT T),CTT qeq LTOP]]] .

Only word-level verbsareallowedto bemodified.

conse quen tly >>>[nfs adv _sent _fs,

lex eme: <>co nseq uentl y].

Subject-relative adverbs

adv_s ent_ subj is_s hort _for[wor d_sa t,

40

nfs con tent_ lexi tem,tok en: <>Tok en,lex eme: <>Lexeme,head:ad v,spr :{},comps:{ },head:[m od:[w ord,

head:v,pm:neg_ p],

pre mod:y es],con t:[h ook:[ exta rg: <>Spr Key] ,

h:[ mod_hole: [ltop : <>LTOP,exta rg: <>SprKey] ],

tds : <>[ ’L’( Token ,Lex eme, p([a1 ,par a])),c1(S prKey ,Tok en),ptop (Toke n,CT T),CTT qeq LTOP]]] .

Only word-level verbsareallowedto bemodified.

inten tion ally >>>[nfs adv _sent _sub j,

lex eme: <>in tent ional ly].

Adjective-modifying adverbs (tentative treatment)

adv_a djmo d is_sh ort_ for[wor d_sa t,

nfs con tent_ lexi tem,tok en: <>Tok en,lex eme: <>Lexeme,head:ad v,spr :{},comps:{ },head:[m od:[h ead: adj,

comps:{ },pm:neg_ p],

premod:ye s],cont :[h: [mod_ hole :[ke y: <>AdjKey ,

ltop: <>LTOP]],tds: <>[’ L’(T oken, Lexe me,p ([a1, para ])),

ci_a 1_a1 (Toke n,Ad jKey) ,ptop (Tok en,CT T),CTT qeq LTOP]]].

41

alleg edly >>>[nfs adv _adjm od,

lex eme: <>al lege dly].

Complementizers

cplze r is_s hort_ for[wor d_sa t,

sla sh:{ },head:[c plzer ,

vfor m:xVf orm,v_s f:xVS F],

nfs no_mod,spr _inc :xSpr Inc,comps:{ [head :[v,

vfor m:xVf orm,v_sf :xVSF ],

spr_ inc: xSpr Inc,comps:{} ]},

con t:[h ook:[ xCH] ,h:[ comp_hole s:{xC H}],tds : <>[ ]]].

A complementizer is a headthatonly changesthehead category of thecomplement,soto speak.

that >>>[nfs cpl zer,

spr :{},comps:{ [head :[vf orm: finit e],

spr: {}]} ].

to >>>[nfs cpl zer,

spr :{xS pr},comps:{ [head :[vf orm: infin ite] ,

spr: {xSp r}]} ].

Interface informationThesepieces of informationdo not belong to thegrammar, properly speaking, but definethe resourcesnecessaryfor using the grammarin a PETFSG application. Someof theseclauses alsodefinetheappearanceof various grammaroutput.

postp arse _opt ions( [con t,res l1,r esl2 ]).

42

‘cont ’: content informationonly. ‘ resl 1’ scope resolution with one-placequantifiers(names)taking global scope. ‘ resl2 ’ scope resolution without theconstraint in thepre-viouscase.

Colour specificationstype_ colo r(si gn,’# FFFFE0’).type_ colo r(wo rd,’# FAEBD7’).type_ colo r(lx m,’#F A8072’).type_ colo r(in fl_lx m,’# FA8072’).type_ colo r(ph rase, ’#FF E4B5’ ).type_ colo r(he ad_so rt,’ #7FFF00’) .type_ colo r(de termi n,’# FFFF33’).type_ colo r(no m,’#7 FFFD4’).type_ colo r(cn noun, ’#7F FFD4’ ).type_ colo r(pr noun, ’#7F FFD4’ ).type_ colo r(pe rspro n,’# 7FFFD4’).type_ colo r(ad j,’#C CFF00’).type_ colo r(ad v,’#C CFF00’).type_ colo r(ve rb,’# FFFFCC’).type_ colo r(v, ’#FFF FCC’).type_ colo r(cp lzer, ’#FF C0CB’).type_ colo r(mo d_sor t,’# E6E6FA’).type_ colo r(co nt_so rt,’ #F5FFFA’) .

Displaycoloursassociated with thevarioustypes.

Resource locationssaved _sta te_f ile(’ /hom e/sta ff/m atsd /petf sg/t ds1.s av’) .

Theversion-dependentfile namefor thePrologsavedstatein which theapplicationbasedon this grammarwill reside.

css_u rl(’ http ://st p.li ng.uu .se/ ˜mat sd/pe tfsg /3/cs s/pg t.cs s’).

Thecascading stylesheet for theoutput pages.

infot ext( [%’An imp leme ntati on of Token Depende ncy Grammar (TDS). See ’, newl,’docu ment atio n <a href ="htt p:// stp. ling. uu.s e/˜ma tsd/ tds/ 1/">h ere< /a>.’ ,

newl , ’The PETFSG gra mmar tool is documente d ’, newl ,’<a hre f="h ttp:/ /stp .lin g.uu. se/˜ matsd /pet fsg/ 3/">h ere< /a>.’ ]).

Documentation note.

Endof file.

43

Appendix C: Auxil iary Prologprocedures

Thisisalistingof theadditionalPrologproceduresof whichtheapplicationmakesuse.(Thefile nameis ‘pl tds.pl ’ .)

Operator declarations:- op(3 00,x fy,qe q).

Equalitymodulo quantifiers,Copestake et al style.

:- op(2 00,x fy,@) .

For token numbering.

Token labeling

label _tok en(D esc,N ,Str ):-name(N,N ame),name(Str ,Str N),append([ 116| Name],[95 |Str N],NN ), %%%e.g. t3_ hous ename(Tok Id,N N),pat h_val ue(D esc, token ,pro log_t erm( TokI d,_)) .

call prologcal l pro log/ 1 providesthe interfacebetween thephrasestructure rulesandgeneralPrologcomputation.

call_ prol og([ mothe r_da ughte rs,M othe r,Dgh tr1, Dghtr 2]): -!,mother_d augh ter_ relat ions (Moth er,D ghtr 1,Dgh tr2) .

call_ prol og([ list_ type _appe nd,A ,B,C ]):-!,lis t_typ e_ap pend (A,B, C).

call_ prol og([ appen d,A, B,C]) :-!,append_w_che ck(A ,B,C) .

call_ prol og(X ):- %%%err or hand ling case!,make_htm l(tx (’Un expec ted prolo g call ’(X)) ),fai l.

44

mothe r_da ught er_re lati ons(M tr,D 1,D2 ):-pat h_val ue(Mtr,s lash, MtrS lash) ,pat h_val ue(D 1,sl ash,D 1Sla sh),pat h_val ue(D 2,sl ash,D 2Sla sh),lis t_typ e_ap pend (D1Sl ash, D2Sla sh,M trSl ash),empty_or _sin glet on(Mt rSla sh),pat h_val ue(Mtr,c ont:t ds,p rolog _ter m(MtrHC,_ )),pat h_val ue(D 1,co nt:td s,pr olog_ term (D1HC,_)) ,pat h_val ue(D 2,co nt:td s,pr olog_ term (D2HC,_)) ,append_w_che ck(D 1HC,D2HC,MtrHC).

Computesthe cont :tds value (PETFSG list) on the motheras the union of the corre-sponding values on the daughters. (The predicatepath valu e/3 is described in thePETFSG documentation.)

empty _or_ sing leton (lis t_typ e(li st_t ype_e <&>f ttrm) ).

empty _or_ sing leton (lis t_typ e(li st_t ype_n e<&>fttr m(_, list_ type (list _typ e_e<&>ftt rm)) )).

List operationslis t typ e appen d/3 is theappend operation for PETFSG lists.

list_ type _app end(A rg1, Arg2, _):-(var (Arg 1);va r(Ar g2)),!,grammar_error (’Er ror (va riab le) in list _type _app end’ ).

list_ type _app end(l ist_ type( list _typ e_ne< &>ft trm(H ead, Tail 1)),LIS T2,

list_ type (lis t_typ e_ne <&>ft trm( Head,Tail 2))) :-!,list _typ e_app end( Tail1 ,LIS T2,T ail2) .

list_ type _app end(l ist_ type( list _typ e_e<&>ftt rm),L IST2 ,LIS T2).

lis t typ e appen d/3 is like ordinary append/3 , but with an argumentcheckasasecurity measure.

appen d_w_chec k(A,B ,C): -is_ list( A),is_ list( B),!,append(A ,B,C ).

45

appen d_w_chec k(A,B ,[]) :-pri nt(’A ttem pt to apply append on non- list’ ), nl,pri nt(A) , prin t(B), nl.

— Morphological operations

morph olog y(id ,X,X) .

morph olog y(af fx(A) ,X,Y ):-name(X,N ),name(A,A N),append(N ,AN, NN),name(Y,N N).

morph olog y(af fx_ch _e(A ),X,Y ):-name(X,N ),name(A,A N),remove_f inal _e(N ,N2),append(N 2,AN ,NN) ,name(Y,N N).

remov e_fi nal_ e(AN, AN2):-rev erse( AN,[ 101| AN3]) ,rev erse( AN3, AN2),!.

remov e_fi nal_ e(AN, AN).

Postparse operations

postp arse _mod(cont ,ALL ,[SEL ]):-!,pat h_val ue(A LL,c ont,C ONT),pat h_val ue(S EL,c ont,C ONT).

Only cont selectedfor output.

postp arse _mod(resl 1,FS ,Bag2 ):-!,pat h_val ue(F S,co nt:td s,pr olog_ term (TDS,_)),pat h_val ue(F S,co nt:ho ok:l top,p rolo g_te rm(Lt op,_ )),fin dall( p(TD S,Tr ee,Im mOutsc),

buil d_tr ee_w_glob als(T DS,Tree, ImmOutsc) ,

46

Bag) ,make_fs( Bag, Bag2,Ltop ).

postp arse _mod(resl 2,FS ,Bag2 ):-!,pat h_val ue(F S,co nt:td s,pr olog_ term (TDS,_)),pat h_val ue(F S,co nt:ho ok:l top,p rolo g_te rm(Lt op,_ )),fin dall( p(TD S,Tr ee,[] ),

buil d_tr ee_no _glo bals( TDS,Tree ),Bag) ,

make_fs( Bag, Bag2,Ltop ).

postp arse _mod(Op,_ ,[]) :-!,make_htm l(tx bi([ ’No pos tpar se op. appl ied.’ ,

’Opti on "’, Op, ’" undefine d. ’]) ).make_fs([ ],[] ,_).

make_fs([ p(TD S,Tre e,Im mOutsc)|B ag], [FS|B ag2] ,Ltop ):-!,col lect_ glob al_b odies (ImmOutsc ,Glo bals ),col lect_ rss_ info (TDS, Tree ,Anch s),pat h_val ue(F S,co nt:gl ob,p rolog _ter m(Gl obals ,_)) ,pat h_val ue(F S,co nt:td s,pr olog_ term (TDS,_)),pat h_val ue(F S,co nt:tr ee,p rolog _ter m(Tr ee,_) ),pat h_val ue(F S,co nt:rs s,pr olog_ term (Anc hs,_) ),pat h_val ue(F S,co nt:ho ok:l top,p rolo g_te rm(Lt op,_ )),make_fs( Bag, Bag2,Ltop ).

colle ct_r ss_i nfo(T DS,Tree,S TTS3):-col lect_ rss_ info 2(TDS,Tre e,STT S),spl it(ST TS,S TTS2),ext ract_ body _sta temen ts(T ree,B odyState ments ),append(B odyState ments ,STT S2,ST TS3) .

colle ct_r ss_i nfo2( TDS,Tree, STTS):-fin dall( para tri( Tok,T okComp,Anch),

(sub tree _para tact ic(Tr ee,[ Tok: ptop( _),SubTree]) ,

comptok (SubT ree, TokComp),anc hori ng(TD S,Su bTree ,Anc h)),

STTS).

47

split ([], []).

split ([pa ratr i(Tok ,Tok Comp,Anch)|Re st1],[pa rg(T ok,To kComp), anc hor( Tok,A nch) |Res t2]): -

spl it(Re st1, Rest 2).

stt(T ree, Tok, CT):-sub tree( Tree ,Tok ,Subt ree) ,comptok( Subt ree, CT).

compt ok([ Tok: _],To k).

compt ok([ Tok: _,Tre e],T ok+CT):-comptok( Tree ,CT) .

compt ok([ Tok: _,Tre e1,T ree2] ,Tok +CT1+CT2) :-comptok( Tree 1,CT 1),comptok( Tree 2,CT 2).

parat ok([ Tok1 :ptop (Tok 2),_] ,Tok 1,To k2).

parat ok([ _,Su bTree ],To k1,To k2): -par atok( SubTree, Tok1, Tok2 ).

parat ok([ _,Su bTree ,_], Tok1, Tok2 ):-par atok( SubTree, Tok1, Tok2 ).

parat ok([ _,_, SubTr ee], Tok1, Tok2 ):-par atok( SubTree, Tok1, Tok2 ).

ancho ring ([], _,[]) .

ancho ring ([c1 (X,Y) |TDS],Sub tree ,[t( Y,1,’ Ind’ (Y,1) )|An ch]) :-rel evant _for (X,Y ,Subt ree) ,!,anc horin g(TD S,Su btree ,Anc h).

ancho ring ([c2 (X,Y) |TDS],Sub tree ,[t( Y,2,’ Ind’ (Y,2) )|An ch]) :-rel evant _for (X,Y ,Subt ree) ,!,anc horin g(TD S,Su btree ,Anc h).

ancho ring ([c3 (X,Y) |TDS],Sub tree ,[t( Y,3,’ Ind’ (Y,3) )|An ch]) :-

48

rel evant _for (X,Y ,Subt ree) ,!,anc horin g(TD S,Su btree ,Anc h).

ancho ring ([_| TDS], Subt ree,A nch) :-!,anc horin g(TD S,Su btree ,Anc h).

relev ant_ for( X,Y,S ubtr ee):-\+c ontai ns(S ubtr ee,X) ,con tains (Sub tree ,Y).

colle ct_g loba l_qua nts( [],[] ).

colle ct_g loba l_qua nts( [’L’( Tok, _,q1 )|Res t],[ Tok|F ound ]):-!,col lect_ glob al_q uants (Res t,Fou nd).

colle ct_g loba l_qua nts( [_|Re st], Found):-!,col lect_ glob al_q uants (Res t,Fou nd).

speci fy_g loba lity( TDRS,GLOBAL,N ewBodySta tms) :-spe cify_ glob alit y2(TD RS,GLOBAL),fin dall( body (X,g lobal ),

( member(X, GLOBAL),\+memberc hk(b ody( X,glo bal) ,TDRS)),

NewBodyStatms ).

speci fy_g loba lity2 ([], _).

speci fy_g loba lity2 ([bo dy(X, glob al)| TDRS],GLOBAL): -memberch k(X, GLOBAL),!,spe cify_ glob alit y2(TD RS,GLOBAL).

speci fy_g loba lity2 ([_| TDRS],GLOBAL) :-!,spe cify_ glob alit y2(TD RS,GLOBAL).

colle ct_g loba l_bod ies( [],[] ).

colle ct_g loba l_bod ies( [body (X,g loba l)|TD RS], [X|Gl obal s]): -

49

!,col lect_ glob al_b odies (TDRS,Glo bals ).

colle ct_g loba l_bod ies( [_|TD RS], Glob als): -!,col lect_ glob al_b odies (TDRS,Glo bals ).

colle ct_n on_g lobal _qua s([], []).

colle ct_n on_g lobal _qua s([’L ’(To k,_, q1)|R est] ,ImmOutsc, [Tok: q1n( Body)|Fou nd]) :-

make_q1_ node (Tok ,ImmOutsc ,Tok: q1n( Body)),\+( Body==glo bal) ,!,col lect_ non_ glob al_qu as(R est,I mmOutsc, Found ).

colle ct_n on_g lobal _qua s([’L ’(To k,_, q2)|R est] ,ImmOutsc,[Tok: q2n( Restr ,Bod y)|F ound] ):-

make_q2_ node (Tok ,ImmOutsc ,Tok: q2n( Rest r,Bod y)),\+( Body==glo bal) , %%This shou ld be tru e.!,col lect_ non_ glob al_qu as(R est,I mmOutsc, Found ).

colle ct_n on_g lobal _qua s([’L ’(To k,_, LogVal)|R est],ImmOutsc,[Tok: ptop (Para )|Fo und] ):-

par atact ic_p redi cate( LogVal),make_par a_no de(T ok,Im mOutsc,To k:pt op(P ara)) ,\+( Para= =glo bal) , %%This shou ld be tru e.!,col lect_ non_ glob al_qu as(R est,I mmOutsc, Found ).

colle ct_n on_g lobal _qua s([_| Rest ],Im mOutsc,Fo und): -!,col lect_ non_ glob al_qu as(R est,I mmOutsc, Found ).

colle ct_n on_g lobal _qua s([], _,[] ).

predi cate (p(_ )).

parat acti c_pr edica te(p (Args )):-memberch k(pa ra,A rgs).

50

make_q1_n ode( _,[], _).

make_q1_n ode( Tok,[ body (Tok, Body)|Im mOutsc],T ok:q1 n(Bo dy)) :-!,make_q1_ node (Tok ,ImmOutsc ,Tok: q1n( Body)).

make_q1_n ode( Tok,[ _|Im mOutsc],T ok:q 1n(Bo dy)) :-!,make_q1_ node (Tok ,ImmOutsc ,Tok: q1n( Body)).

make_q2_n ode( _,[], _).

make_q2_n ode( Tok,[ body (Tok, Body)|Im mOutsc],Tok:q 2n(R estr, Body)):-

!,make_q2_ node (Tok ,ImmOutsc ,Tok: q2n( Rest r,Bod y)).

make_q2_n ode( Tok,[ rest r(Tok ,Res tr)| ImmOutsc] ,Tok:q 2n(R estr, Body)):-

!,make_q2_ node (Tok ,ImmOutsc ,Tok: q2n( Rest r,Bod y)).

make_q2_n ode( Tok,[ _|Im mOutsc],T ok:q 2n(Re str, Body) ):-!,make_q2_ node (Tok ,ImmOutsc ,Tok: q2n( Rest r,Bod y)).

make_para _nod e(Tok ,[pt op(To k,Pa ra)| _],To k:pt op(Pa ra)) :-!.

make_para _nod e(Tok ,[_| ImmOutsc] ,Tok :ptop (Par a)):-!,make_par a_no de(T ok,Im mOutsc,To k:pt op(P ara)) .

colle ct_l eave s([], []).

colle ct_l eave s([’L ’(To k,_,L ogVal)|R est], [(To k:[]) |Fou nd]) :-pre dicat e(Lo gVal ),\+p arata ctic _pre dicat e(Lo gVal) ,!,col lect_ leav es(R est,F ound ).

colle ct_l eave s([_| Rest ],Fou nd): -

51

!,col lect_ leav es(R est,F ound ).

tdr_k inds ([], [],[] ,[], []).

tdr_k inds ([’L ’(A,B ,C)| Rest] ,[’L ’(A, B,C)| LOS],QEQS,ImmOuts c,CIS ):-

!,tdr _kind s(Re st,L OS,QEQS,I mmOutsc,C IS).

tdr_k inds ([A qeq B|Rest] ,LOS,[A qeq B|QEQS],ImmOutsc ,CIS) :-

!,tdr _kind s(Re st,L OS,QEQS,I mmOutsc,C IS).

tdr_k inds ([pt op(A, B)|R est], LOS,QEQS,[pt op(A ,B)|I mmOutsc] ,CIS) :-

!,tdr _kind s(Re st,L OS,QEQS,I mmOutsc,C IS).

tdr_k inds ([bo dy(A, B)|R est], LOS,QEQS,[bo dy(A ,B)|I mmOutsc] ,CIS) :-

!,tdr _kind s(Re st,L OS,QEQS,I mmOutsc,C IS).

tdr_k inds ([re str(A ,B)| Rest] ,LOS,QEQS,[re str( A,B)| ImmOutsc ],CIS ):-

!,tdr _kind s(Re st,L OS,QEQS,I mmOutsc,C IS).

tdr_k inds ([c1 (A,B) |Res t],LO S,QEQS,ImmOuts c,[os (A,B )|CI S]):-

!,tdr _kind s(Re st,L OS,QEQS,I mmOutsc,C IS).

tdr_k inds ([c2 (A,B) |Res t],LO S,QEQS,ImmOuts c,[os (A,B )|CI S]):-

!,tdr _kind s(Re st,L OS,QEQS,I mmOutsc,C IS).

tdr_k inds ([c3 (A,B) |Res t],LO S,QEQS,ImmOuts c,[os (A,B )|CI S]):-

!,

52

tdr _kind s(Re st,L OS,QEQS,I mmOutsc,C IS).

build _tre e_w_globa ls(T DRS,Tree, ImmOutsc2 ):-tdr _kind s(TD RS,L OS,QEQS,I mmOutsc,C IS),col lect_ glob al_q uants (LOS,GLOBAL),spe cify_ glob alit y(TDRS,GLOBAL,NewBodyStatms ),append(I mmOutsc, NewBodySt atms, ImmOutsc 2),col lect_ non_ glob al_qu as(L OS,Im mOutsc2, QUAS),col lect_ leav es(L OS,LEAVES),bui ld_tr ee(_ ,Tre e,QUAS,LE AVES,[],[ ]),che ck_tr ee(T ree, GLOBAL,QEQS,CI S).

build _tre e_no _glob als( TDRS,Tree ):-tdr _kind s(TD RS,L OS,QEQS,I mmOutsc,C IS),col lect_ non_ glob al_qu as(L OS,Im mOutsc,Q UAS),col lect_ leav es(L OS,LEAVES),bui ld_tr ee(_ ,Tre e,QUAS,LE AVES,[],[ ]),che ck_tr ee(T ree, [],QE QS,CIS).

build _tre e(T, [T:[] ],QU AS,LE AVES,QUAS,LEA VES2):-sel ect_a ny(T :[], LEAVES,LE AVES2).

build _tre e(T, [T:q1 n(Bo dy),P tree ],QU AS,LEAVES,QUAS3, LEAVES2): -

sel ect_a ny(T :q1n (Body ),QU AS,QUAS2) ,bui ld_tr ee(B ody, Ptree ,QUAS2,

LEAVES,QUAS3,LEA VES2).

build _tre e(T, [T:q2 n(Re str,B ody) ,Rtr ee,Bt ree] ,QUAS,LEAVES,QUAS4, LEAVES3): -

sel ect_a ny(T :q2n (Rest r,Bo dy),Q UAS,QUAS2),bui ld_tr ee(R estr ,Rtre e,QUAS2,

LEAVES,QUAS3,LEA VES2),bui ld_tr ee(B ody, Btree ,QUAS3,

LEAVES2, QUAS4,LE AVES3).

build _tre e(T, [T:pt op(P ara), Ptre e],Q UAS,LEAVES,QUAS3, LEAVES2): -

sel ect_a ny(T :pto p(Par a),Q UAS,QUAS2),bui ld_tr ee(P ara, Ptree ,QUAS2,

LEAVES,QUAS3,LEA VES2).

selec t_an y(EP ,[EP| REST],RES T).

53

selec t_an y(EP ,[X|R EST1],[X| REST2]): -sel ect_a ny(E P,REST1,R EST2).

check _tre e(Tr ee,GL OBAL,QEQS,CIS ):-!,che ck_tr ee_q eqs( QEQS,Tree ),che ck_tr ee_c is(C IS,Tr ee,G LOBAL).

check _tre e(Tr ee,GL OBAL,QEQS,CIS ,R1, R2):-!,che ck_tr ee_q eqs( QEQS,Tree ,R1),che ck_tr ee_c is(C IS,Tr ee,G LOBAL,R2) .

check _tre e_qe qs([] ,_).

check _tre e_qe qs([T 1 qeq T2|QEQS], Tree) :-!,qeq(T1,T 2,Tr ee),che ck_tr ee_q eqs( QEQS,Tree ).

check _tre e_qe qs([] ,_,o k).

check _tre e_qe qs([T 1 qeq T2|QEQS], Tree, Res) :-qeq(T1,T 2,Tr ee),!,che ck_tr ee_q eqs( QEQS,Tree ,Res) .

check _tre e_qe qs([T 1 qeq T2|_] ,_,f ailin g(T1 qeq T2)) .

qeq(T ,T,_ ):-!.

qeq(T 1,T2 ,[T1 :q2n( _,Tx ),_,B ody] ):-qeq(Tx,T 2,Bo dy).

qeq(T 1,T2 ,[T1 :q1n( Tx), Body] ):-qeq(Tx,T 2,Bo dy).

qeq(T 1,T2 ,[_, Subtr ee]) :-qeq(T1,T 2,Su btre e).

qeq(T 1,T2 ,[_, Subtr ee,_ ]):-

54

qeq(T1,T 2,Su btre e).

qeq(T 1,T2 ,[_, _,Sub tree ]):-qeq(T1,T 2,Su btre e).

check _tre e_ci s([], _,_) .

check _tre e_ci s([os (T1, T2)|C IS], Tree ,GLOBAL): -out scope s(os (T1, T2),T ree, GLOBAL),che ck_tr ee_c is(C IS,Tr ee,G LOBAL).

check _tre e_ci s([], _,_, ok).

check _tre e_ci s([os (T1, T2)|C IS], Tree ,GLOBAL,R es):-out scope s(os (T1, T2),T ree, GLOBAL),!,che ck_tr ee_c is(C IS,Tr ee,G LOBAL,Res ).

check _tre e_ci s([os (T1, T2)|_ ],_, _,fa iling (os( T1,T2 ))): -!.

outsc opes (os( T1,_) ,_,G LOBAL):-memberch k(T1 ,GLOBAL).

outsc opes (os( T1,T2 ),Tr ee,_) :-out scope s_in _tre e(T1, T2,T ree).

outsc opes _in_ tree( T1,T 2,Tre e):-sub tree( Tree ,T1, Subtr ee),con tains (Sub tree ,T2).

subtr ee([ T1:X |Rest ],T1 ,[T1: X|Re st]) .

subtr ee([ _,Re str,_ ],T1 ,Subt ree) :-sub tree( Rest r,T1 ,Subt ree) .

subtr ee([ _,_, Body] ,T1, Subtr ee): -sub tree( Body,T1, Subtr ee).

subtr ee([ _,Pa ra],T 1,Su btree ):-sub tree( Para ,T1, Subtr ee).

subtr ee_p arat actic ([T1 :ptop (X)| Rest ],[T1 :pto p(X)| Rest ]).

55

subtr ee_p arat actic ([_, Restr ,_], Subt ree): -sub tree_ para tact ic(Re str, Subtr ee).

subtr ee_p arat actic ([_, _,Bod y],S ubtr ee):-sub tree_ para tact ic(Bo dy,S ubtre e).

subtr ee_p arat actic ([_, Para] ,Sub tree ):-sub tree_ para tact ic(Pa ra,S ubtre e).

conta ins( [T:_ |_],T ).

conta ins( [_,S ubtre e],T ):-con tains (Sub tree ,T).

conta ins( [_,S ubtre e,_] ,T):-con tains (Sub tree ,T).

conta ins( [_,_ ,Subt ree] ,T):-con tains (Sub tree ,T).

extra ct_b ody_ state ment s([Q: q2n( _,Bo dy),T 1,T2 ],[body (Q,B ody)| More]):-

!,ext ract_ body _sta temen ts(T 1,B1) ,ext ract_ body _sta temen ts(T 2,B2) ,append(B 1,B2 ,Mor e).

extra ct_b ody_ state ment s([Q: q1n( Body),T1] ,[body (Q,B ody)| More]):-

!,ext ract_ body _sta temen ts(T 1,Mor e).

extra ct_b ody_ state ment s([_, T1], More):-!,ext ract_ body _sta temen ts(T 1,Mor e).

extra ct_b ody_ state ment s([_] ,[]) :-!.

Prolog term displayingdisp_ prol og_t erm(T ,Pro VarNr I,Pr oVar NrO): -

ins tanti ate_ vars (T,Pr oVar NrI,P roVa rNrO ),

56

pri nt(’< tt>’ ),pri nt_pr olog _ter ms(T) ,pri nt(’< /tt> ’).

insta ntia te_v ars(T ,Pro VarNr I,Pr oVar NrO): -var (T),!,make_symbol_ for_ var(T ,Pro VarNr I,Pr oVar NrO).

insta ntia te_v ars(T ,Pro VarNr ,Pro VarNr):-sim ple(T ),!.

insta ntia te_v ars([ H|T] ,ProV arNr I,Pr oVarN rO): -!,ins tanti ate_ vars (H,Pr oVar NrI,P roVa rNrM ),ins tanti ate_ vars (T,Pr oVar NrM,P roVa rNrO ).

insta ntia te_v ars(T ,Pro VarNr I,Pr oVar NrO): -!,T =.. List ,ins tanti ate_ vars (List ,Pro VarNr I,Pr oVar NrO).

make_symbol_f or_va r(T, ProVa rNrI ,Pro VarNr O):-name(Pro VarNrI,N ame),append([ 60,1 17,6 2,80| Name],

[60 ,47, 117,6 2],T T),name(T,T T),Pro VarNr O is Pro VarNr I + 1.

print _pro log_ terms (X): -var (X),!,pri nt(X) .

print _pro log_ terms ([X: Y|Z]) :-!,pri nt_tr ee([ X:Y| Z],0) .

This casefindscon t :tree values.

print _pro log_ terms (X): -is_ list( X),!,

57

pri nt_li st(X ).

print _pro log_ terms (X): -pri nt(X) .

print _lis t([X |Rest ]):-Rest\==[ ],\+a tom(X ),!,pri nt(’< pre> ’), nl,pri nt(’[ ’), prin t(X), pri nt(’, ’), nl,pri nt_li st_c ont( Rest) .

print _lis t(X) :-!,pri nt(X) .

print _lis t(X) :-!,pri nt(X) .

print _lis t_co nt([X ]):-!,pri nt(’ ’), prin t(X), pri nt(’] ’), nl,pri nt(’< /pre >’).

print _lis t_co nt([X |Res t]):-!,pri nt(’ ’), prin t(X), pri nt(’, ’), nl,pri nt_li st_c ont( Rest) .

print _tre e(X, Level ):-pri nt(’< pre> ’), nl,pri nt_tr ee2( X,Le vel), nl,pri nt(’< /pre >’).

print _tre e2([ A],Le vel) :-!,ind ent(L evel ), prin t(’[ ’), print (A), prin t(’] ’).

print _tre e2([ A,B], Leve l):-!,ind ent(L evel ), prin t(’[ ’), print (A), prin t(’, ’), nl,

58

Lev el2 is Leve l + 1,pri nt(’ ’), prin t_tre e2(B ,Leve l2), pri nt(’] ’).

print _tre e2([ A,B,C ],Le vel): -!,ind ent(L evel ), prin t(’[ ’), print (A), prin t(’, ’), nl,Lev el2 is Leve l + 1,pri nt(’ ’), prin t_tre e2(B ,Leve l2), pri nt(’, ’), nl,pri nt(’ ’), prin t_tre e2(C ,Leve l2), pri nt(’] ’).

print _tre e2(A ,Leve l):-!,ind ent(L evel ), prin t(’* ’), print (A).

inden t(0) :-!.

inden t(X) :-pri nt(’ ’),XX is X - 1,ind ent(X X).

Endof file.

Appendix D: DownloadableTDS grammar files

These files are described above in this document. They are found inhttp://st p.ling.uu .se/˜mats d/tds/1/f / .

gram tds.pl : TheTDS grammar.

lex tds.p l : More lexical entries.

pl tds.pl : ContainsSICStusPrologproceduresusedby theTDS grammar.

suites tds.pl : Definestestsuites.

make tds.pl : Usedto createtheTDS grammarsavedstate.

59

Recommended