Advertisement

Simple text parser

Started by May 18, 2001 01:13 PM
2 comments, last by NewDeal 23 years, 8 months ago
Some time ago i asked a question about information on NTL (natural language parsers) and how to implement them. It was for a school asignment and since my previous question the problem has been scaled down a bit. Now i have to make a parser capable of parsing time expressions formulated in a formal language. The parser is part of a system for handling reservations of various resources. An example of such an expression could be: "Every monday and every other tuesday from 14pm to 18pm in november this year except the third tuesday in that month." The example above is nothing more than an example and the expression could look alot different. Im almost done making the parser. However, im not quite satisfied with my solution and i was wondering how you guys would go about making something like this. Thanks in advance
It depends on the category in which the formal language falls ... I''ve been outta school for a few years now .. so the terms are all gone ... but I know that my first thing would be to see if this formal language is the type that can be expressed in a BNF grammer ... if so ... I''d do that, cause it''s the first step (that I''m comfortable with) for breaking down structuring rules systematically. Also, catagorizing all of the words in your language, and seeing if there is any overlap - if not that simplifies things dramatically ... but just the act of identifying the overlap helps. Oh well .. gotta get back to work ...
Advertisement
I think what you describe is very much like the approach i used. What i hoped (actually didnt hope since im done) was that i could build some sort of tree-structure describing the sentence (not a sentence i know).

I once made a mathematical parser and all the operators and values fitted perfectly into a binary tree. Was trying to find something similar for this problem.

Guess not though .

Thanks for the reply, made me feel a little better.
If you can express the language in terms of a context-free BNF grammar, you can use a parser-generator tool like Yacc or Bison to write the parser, given that grammer.

That''s what we''ve done in my compiler course, and I''m quite impressed with how easy it is to use those tools, along with tools like Lex or Flex to perform lexical analysis on the input. Of course, those are LALR(1) parser generator tools, meaning that you won''t be able to necessarily parse everything with them. Still, they are quite effective at making parsing easy.

This topic is closed to new replies.

Advertisement