ICL Home >> Lab Sessions >> Lab 5 |
This lab is based on the NLTK-Lite parsing tutorial and the lecture on Context Free Grammars.
Start an interactive Python session from the command line, and enter the following statement:
>>> from nltk_lite.parse.tree import Tree
Following the suggestions in the NLTK_Lite Parsing Tutorial,
experiment using the Tree
constructor to build some
trees. NB: assuming you have already defined tree1
(e.g. as an NP structure), you can
build a nested tree with the following statement:
>>> tree2 = Tree('S', [ tree1, Tree('VP' , ['walked'])])
You can get a graphical version of your tree with the command
>>> tree2.draw()
Next, give the command
>>> from nltk_lite.parse import bracket_parse
Experiment building some trees using the labeled bracket notation given in the
tutorial, parsing them with bracket_parse
, and drawing
them with the draw()
method.
In the next part of this tutorial, you need to think a bit about assigning structures to English phrases and sentences.
Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk Please contact our webadmin with any comments or corrections. Logging and Cookies Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh |