Ctl254 2004k: GramKit Practical Work
1. Introduction to GramKit.
-
This exercise relates to Sag & Wasow
Chapter 2: Some Simple Theories of Grammar.
-
Copy the following 4 files into your own directory:
-
Start prolog by
sicstus -l loadCFG and check that
everything is working by
?- test_parse.
-
Start the parser by the query
?- parse.
and type in your own test sentences.
-
Exit by EOF (ctrl-D).
2. Chart parsing with GramKit.
-
Copy the same 4 files as last week
(SW2-CFG1.pl,
parse-gen1.pl,
tree-print.pl,
loadCFG.pl) into your directory.
Start prolog by
sicstus -l loadCFG and check that everything is
working by ?- test_parse.
-
Switch on tracing of inactive edges in the chart by
?-
trace(inactive).
Start the parser by
?- parse. and type in a short phrase such as
the dog. The parser should list the inactive edges it
found.
Exit from the parser by EOF (ctrl-D). but don't exit from
prolog yet.
-
Switch on tracing of active edges by
?- trace(active).
Start the parser again and type in the same phrase as before.
This time the parser lists both inactive and active edges.
Exit from the parser but stay in prolog.
-
Switch off tracing by
?- trace(off). then
switch on tracing of active edges by ?- trace(active).
Start the parser again and type in the same phrase as before.
This time the parser lists only active edges.
-
Repeat the above steps a few times, using different short phrases
and then some longer sentences.
3. Parsing and generating with GramKit.
-
Copy a new grammar
DCG-Grammar1.pl and
load file loadDCG.pl
into your directory.
Use the same GramKit parser/generator
parse-gen1.pl and
tree printer tree-print.pl
as last week,
Start prolog by sicstus -l loadDCG and
check that the parser is working by ?- test_parse.
-
Study DCG-Grammar1.pl carefully.
Each category has the following 4 arguments:
- Semantic index
- Phonology (a difference list Px-Py)
- Subcategorization list (ordinary Prolog list)
- Logical Form (a difference list Lx-Ly)
-
Start the parser by
?- parse. and
type in different phrases and sentences.
See how the grammar works by switching on tracing of active
or inactive edges in the chart.
See how syntactic items are crossed off the subcat list
and semantic items are composed into the logical form.
-
This grammar includes a logical form (semantic representation),
so generation is possible as well as parsing.
Check that the generator is working by ?- test_gen.
-
It's inconvenient to type in logical forms in order
to test the generator. It's much easier to type in a sentence.
So we do "echo generation": input a sentence, parse it to get a
logical form, then generate output from the logical form.
Check that the echo generator is working by ?- test_echo.
-
Start the echo generator by
?- echo. and
type in different phrases and sentences.
The output usually "echoes" the input.
Sometimes the generator produces surprising outputs.
This is a good way to test your grammar.
4. Using ProFIT with GramKit.
-
Copy the ProFIT software
profit3.pl
into your directory.
Also copy a new version
parse-gen2.pl
of the GramKit parser/generator.
Use the same tree printer
tree-print.pl as before.
-
Copy a new grammar
SW9-HPSG1.fit and
load file loadHPSG1.pl
into your directory.
Start prolog by sicstus -l loadHPSG1 and
check that the parser is working by ?- test_parse.
You should see the test sentence [Kim,walks]
with a tree diagram and a semantic representation.
-
Switch on the display of HPSG signs by
?- show(signs).
and again do ?- test_parse.
You should see an additional HPSG sign feature structure
including phon,syn,sem substructures.
Switch off the displays by ?- show(off).
and again do ?- test_parse.
Switch on the display of trees by ?- show(trees).
and again do ?- test_parse.
Switch on the display of semantics by ?- show(sems).
and again do ?- test_parse.
-
Select the display of signs only, by
?- show(off).
followed by ?- show(signs).
Then start the parser by ?- parse. and
type in different words, phrases and sentences.
Look at the sign for Kim, the sign for walks, and
the sign for Kim walks.
-
Then study GDE - Handout 3
by Paul Bennett (Manchester), starting from Section 2.
The grammar he calls firstgram.fit is the same as
SW9-HPSG1.fit.
You can copy this shell script for the
tidy command.
5. The Lexicon in GramKit
-
Copy a new grammar
SW13-HPSG1.fit and load file:
loadSW13.pl
into your directory.
Use the same ProFIT profit3.pl and
GramKit parse-gen2.pl,
tree-print.pl as last week.
Start prolog by sicstus -l loadSW13 and
check that the parser is working by ?- test_parse.
-
Then study GDE - Handout 4
by Paul Bennett (Manchester), starting from Section 2.
The grammar he calls english.fit is the same as
SW13-HPSG1.fit.
Using GDE - Handout 4, study pronouns (Section 2),
main verbs (Section 3), and adjectives (Section 5).
We'll study auxiliary verbs (Section 4) and
negation (Section 6) next week.
6. Lexical Rules and Auxiliary Verbs in GramKit
-
Use the same
SW13-HPSG1.fit,
loadSW13.pl,
profit3.pl,
parse-gen2.pl and
tree-print.pl as last week.
Start prolog by sicstus -l loadSW13 and
check that the parser is working by ?- test_parse.
-
Find the following in
SW13-HPSG1.fit,
and compare the ProFIT versions with the textbook versions.
-
Passive Lexical Rule
-
Negation Lexical Rule
-
Auxiliary Verb Lexemes be, have, do, will
-
Start the parser by
?- parse., test the following
and study the results.
-
the duck saw the fish
-
the fish was seen by the duck
-
* the duck saw not the fish
-
the duck did not see the fish
-
the fish was not seen by the duck
-
the duck has seen the fish
-
the duck will see the fish
-
the duck will have seen the fish
-
the fish has been seen by the duck
-
the fish will have been seen by the duck
-
the fish will not have been seen by the duck
Graham Wilcock