grammatica-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Grammatica-users] basic question


From: Leo Ferres
Subject: [Grammatica-users] basic question
Date: Fri, 18 Feb 2005 13:46:17 -0500

Dear list;

I'm afraid I've got to ask what I think is a very simple question. So,
my apologies. I seem to have a problem accessing the parser from my java
code. The "standalone" parser works, but when I call it, I get an
"unexpected EOF" error. Here are the details of my implementation:

try {
                        parseFOL(myString);
                } catch (ParserLogException e) {
                        System.out.println(e.getError(0).getMessage());
                } catch (ParserCreationException e) {
                        System.out.println(e.getMessage());
                }

myString is a String object. I get no errors in either the packages or
the classes, but when I put in an expression to be parsed, here's what I
get for some sample runs:

input: BLUE(car)
Sentence(2001)
unexpected end of file, on line 1 column: 10

input: (
unexpected token "(", expected one of <PREDICATE>, or "\neg", on line 1
column: 1

input: hello
unexpected token "hello" <WORD>, expected one of <PREDICATE>, or "\neg",
on line 1 column: 1,

so it seems it's accessing the parser no problem, but it stops short of
giving me the whole parse. If, instead, I run the thing offline

java -jar grammatica-1.4.jar ./myGrammar.grammar --parse ./test.data,

I get the right result:

Parse tree from .\test\test.data:
Sentence(2001)
  ComplexSentence(2003)
    NEGATION(1005): "\neg", line: 1, col: 1
    Sentence(2001)
      simpleSentence(2002)
        PREDICATE(1012): "BLUE", line: 1, col: 6
        LEFT_PAREN(1008): "(", line: 1, col: 10
        WORD(1013): "peter", line: 1, col: 11
        RIGHT_PAREN(1009): ")", line: 1, col: 16

So the problem seems to be in something like the object (or some
modification of it) that I'm inputting the parse method. Here's said
method as I have it implemented:

        private static Node parseFOL(String input) throws
ParserCreationException,
                        ParserLogException {

                Parser parser=null;
                parser = new MyGramParser(new StringReader(input));
                System.out.println(parser.parse());
                return parser.parse();
                
        }

That should be all for now. Thanks for your help and I'm really enjoying
your contribution. 

Best,

Leo

Leo Ferres, PhD
Carleton University, Ottawa, Canada





reply via email to

[Prev in Thread] Current Thread [Next in Thread]