[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters]
![]() |
Chart Parser |
Written by Steven White.
Version 1.0
chart_parser_1_0.zip (189,000 bytes) - source code
sjwhite@apexmail.com Steven White (maintainer) mail address.
Once setup a string is fired at the parser and the parser returns an array of successful parses, if any.
The parse result is a tree. Included is a utility class called TREE_TO_TEXT which will give a parenthesized representation of the parse. For example the string "the nurses on the report see that they suffer the arrows of outrageous fortune" becomes:
(S (NP (DET (ART THE)) (NP (N NURSE)) (PP (PREP ON) (NP (DET (ART THE))(NP(N REPORT))))) (VP (V SEE) (REL THAT)(S (NP (N (PRO THEY))) (VP (V SUFFER) (NP (DET (ART THE)) (NP (N ARROW))) (PP (PREP OF)) (NP (ADJ OUTRAGEOUS) (NP (N FORTUNE)))))))))
Displayed as a tree this is how the parse looks. I tree below I built manually :-)
+--------------S--------------+
| |
+------NP------+ +-------VP-------+
| | | | | |
DET NP +-PP--+ V REL +------S-------+
| | | | | | | |
ART N PREP +-NP--+ SEE THAT NP +------VP------+
| | | | | | | |
THE NURSE ON DET NP N V +-------NP-------+
| | | | | | |
ART N PRO SUFFER DET NP +----PP-----+
| | | | | | |
THE REPORT THEY ART N PREP +---NP----+
| | | | |
THE ARROW OF ADJ NP
| |
OUTRAGEOUS N
|
FORTUNE
This program is based on a C++ program. Unfortunately I don't have to C++ version anymore so I have no idea who wrote the original version. The C++ version tought me that C++ can be a lot more unreadable than C let alone Eiffel!
I did put together a couple of good grammar files but (as always) they have disappeared into the digital eather and what I am left with is not barely parses anything. If you put together a good comprehensive grammar or extend the parser I would appreciate a copy! :-)
This version is fairly slow under Visual Eiffel with ISE Eiffel being almost twice as fast. I have no idea why as Visual Eiffel seems pretty quick with my other programs.
STRING_TOKENS PLAIN_TEXT_FILE BINARY_FILE_SEARCH EIFFELBASE (array and queues...)
If you are not using an ISE compiler then you will need to obtain my ISE File Compatibility class which makes SmallEiffel and Visual Eiffel more compatible with ISE's PLAIN_TEXT_FILE class.
All these classes are available from http://www.eiffel-forum.org/archive/white/ After installing the above support files copy the Parser and Word directories in this archive to a convenient location. Add the paths to your loadpath file if using SmallEiffel. If your using Visual Eiffel use Add Cluster to add the files to your project.
Steven White: sjwhite@apexmail.com
01 April 1999 (Added to Eiffel Forum Archive: 30 December 1999)
[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters]