From: Kal A. <ka...@te...> - 2005-03-07 21:11:47
|
Hi Richard, Lets try with the 2.5MB file to start with - if its a real pain, I'll yell ;-) Cheers, Kal On 7 Mar 2005, at 19:51, Richard Gregory wrote: > Hi Kal, > > Thanks for the prompt reply, as ever. > > I have a small 2.5MB TM (compared with my other TM's which are 50MB > and over) which I can send you > tomorrow, and which was produced for the same project these queries > were generated for. If that is > still too large, let me know what size you are after and I'll generate > one for you tomorrow. > > Cheers, > > Richard. > > > --- Kal Ahmed <ka...@te...> wrote: >> Hi Richard, >> >> Some of these NPEs probably are bugs in the tolog code. I don't think >> that the parser currently supports the = operator, but it should >> support /=. That said, the changes that were introduced to tolog 1.2 >> may have caused the implementation of /= to break. Biggest problem in >> implementing this query language is that Ontopia hadn't produced a >> formal language specification when I wrote the code, so a lot was my >> guess work based on what documentation was available. I don't know if >> that is changed now or not. >> >> Anyway, thanks for your detailed report. Its going to take me some >> time >> to get through all of these, but if you have time to make a minimum >> test set (small TM and a set of queries which work on Omnigator and >> fail in TM4J), then it would really help me out in sorting out "bugs" >> from *ahem* "features" :-). If you don't have time, don't worry - I'll >> get on to it and let you know how things go. >> >> Cheers, >> >> Kal >> >> On 7 Mar 2005, at 15:46, Richard Gregory wrote: >> >>> Hi All, >>> >>> I'm trying to execute a tolog query in a TM4J program, and I've >>> encountered a number of problems. >>> Apologies for the length of this mail, but it seemed that whichever >>> way I tried to solve the >>> problem I hit another one which confused me. >>> >>> The query I want to execute, which works fine in the Omnigator, is: >>> >>> TologResultsSet results = queryEval.execute("select $PROTEIN from " + >>> "at-has-go(t-protein-ydl101c : tt-protein, $RESULT : tt-go), " + >>> "$RESULT /= t-go-0000004, " + >>> "$RESULT /= t-go-0000006, " + >>> "at-has-go($PROTEIN : tt-protein, $RESULT : tt-go), " + >>> "$PROTEIN /= t-protein-ydl101c " + >>> "order by $PROTEIN?"); >>> >>> This give an NullPointerException >>> >>> Exception caught: java.lang.NullPointerException >>> java.lang.NullPointerException >>> at org.tm4j.tologx.parser.Variable.equals(Variable.java:31) >>> at java.util.ArrayList.indexOf(ArrayList.java:220) >>> at java.util.ArrayList.contains(ArrayList.java:201) >>> at >>> org.tm4j.tologx.parser.ClauseList.addVariable(ClauseList.java:156) >>> at >>> org.tm4j.tologx.parser.ClauseList.addClause(ClauseList.java:165) >>> at >>> org.tm4j.tologx.parser.TologParser.opclause(TologParser.java:1134) >>> at >>> org.tm4j.tologx.parser.TologParser.clause(TologParser.java:789) >>> at >>> org.tm4j.tologx.parser.TologParser.clauselist(TologParser.java:443) >>> at >>> org.tm4j.tologx.parser.TologParser.query(TologParser.java:498) >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.prepareQuery(QueryEvaluator >>> Im >>> pl.java:151) >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.execute(QueryEvaluatorImpl. >>> ja >>> va:165) >>> at >>> mips.genre.topicmaps.TologBugTests.main(TologBugTests.java:150) >>> >>> I think the source of the problem is the lines: >>> >>> "$RESULT /= t-go-0000004, " + >>> "$RESULT /= t-go-0000006, " + >>> >>> If I comment these out, as below, it works fine, even with the >>> similar >>> "$PROTEIN /= >>> t-protein-ydl101c " still in the query. Both these topics exist in >>> the >>> topic map. so I know that >>> isn't the problem. From the testing I've done with various quries, I >>> get the same excpetion if I >>> use a statement like this in a query, except when it's the last >>> statement (apart from an "order >>> by"), so could there be a problem with the comma after a topic id, >>> used in this way is parsed? >>> >>> TologResultsSet results = queryEval.execute("select $PROTEIN from " + >>> "at-has-go(t-protein-ydl101c : tt-protein, $RESULT : tt-go), " + >>> //"$RESULT /= t-go-0000004, " + >>> //"$RESULT /= t-go-0000006, " + >>> "at-has-go($PROTEIN : tt-protein, $RESULT : tt-go), " + >>> "$PROTEIN /= t-protein-ydl101c " + >>> "order by $PROTEIN?"); >>> >>> Having encountered this problem, I looked for other ways to formulate >>> the query. First I tried >>> using "not" statements with an "=", instead of using the "/=". >>> >>> TologResultsSet results = queryEval.execute("select $PROTEIN from " + >>> "at-has-go(t-protein-ydl101c : tt-protein, $RESULT : tt-go), " + >>> "not($RESULT = t-go-0000004), " + >>> "not($RESULT = t-go-0000006), " + >>> "at-has-go($PROTEIN : tt-protein, $RESULT : tt-go), " + >>> "$PROTEIN /= t-protein-ydl101c " + >>> "order by $PROTEIN?"); >>> >>> Again, this query works fine in the omnigator, but I get an excpetion >>> with TM4J. >>> >>> Exception caught: org.tm4j.tologx.TologParserException: Error parsing >>> query string. >>> org.tm4j.tologx.TologParserException: Error parsing query string. >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.prepareQuery(QueryEvaluator >>> Im >>> pl.java:155) >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.execute(QueryEvaluatorImpl. >>> ja >>> va:165) >>> at >>> mips.genre.topicmaps.TologBugTests.main(TologBugTests.java:150) >>> Caused by: line 1:103: unexpected char: '=' >>> at >>> org.tm4j.tologx.parser.TologLexer.nextToken(TologLexer.java:212) >>> at antlr.TokenBuffer.fill(TokenBuffer.java:69) >>> at antlr.TokenBuffer.LA(TokenBuffer.java:80) >>> at antlr.LLkParser.LA(LLkParser.java:52) >>> at antlr.Parser.match(Parser.java:212) >>> at >>> org.tm4j.tologx.parser.TologParser.clause(TologParser.java:776) >>> at >>> org.tm4j.tologx.parser.TologParser.clauselist(TologParser.java:437) >>> at >>> org.tm4j.tologx.parser.TologParser.notclause(TologParser.java:851) >>> at >>> org.tm4j.tologx.parser.TologParser.clause(TologParser.java:734) >>> at >>> org.tm4j.tologx.parser.TologParser.clauselist(TologParser.java:443) >>> at >>> org.tm4j.tologx.parser.TologParser.query(TologParser.java:498) >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.prepareQuery(QueryEvaluator >>> Im >>> pl.java:151) >>> ... 2 more >>> >>> It seems the query parser is taking exception (excuse the pun) to the >>> "=". I did some more testing >>> with other query variations using the "=" comparator, such as >>> >>> TologResultsSet results = queryEval.execute("select $PROTEIN from " + >>> "at-has-go(t-protein-ydl101c : tt-protein, $RESULT : tt-go), " + >>> "$RESULT = t-go-0006468, " + >>> "at-has-go($PROTEIN : tt-protein, $RESULT : tt-go), " + >>> "$PROTEIN /= t-protein-ydl101c " + >>> "order by $PROTEIN?"); >>> >>> String[] replacements = {"GO:0006468"}; >>> TologResultsSet results = queryEval.execute( >>> "select $PROTEIN from " + >>> "at-has-go(t-protein-ydl101c : tt-protein, $RESULT : tt-go), " + >>> "topic-name($GO1, $GO1_NAME), " + >>> "value($GO1_NAME, %1), " + >>> "$RESULT = $GO1, " + >>> "at-has-go($PROTEIN : tt-protein, $RESULT : tt-go), " + >>> "$PROTEIN /= t-protein-ydl101c" + >>> "order by $PROTEIN?", replacements); >>> >>> These give the same excpetion. >>> >>> I next looked at getting topics by name, and going back to using the >>> "/=" comparator. >>> >>> TologResultsSet results = queryEval.execute( >>> "select $PROTEIN from " + >>> "at-has-go(t-protein-ydl101c : tt-protein, $RESULT : tt-go), " + >>> "topic-name($GO1, $GO1_NAME), " + >>> "value($GO1_NAME, \"GO:0000004\"), " + >>> "topic-name($GO2, $GO2_NAME), " + >>> "value($GO2_NAME, \"GO:0000006\"), " + >>> "$RESULT /= $GO1, " + >>> "$RESULT /= $GO2, " + >>> "at-has-go($PROTEIN : tt-protein, $RESULT : tt-go), " + >>> "$PROTEIN /= t-protein-ydl101c " + >>> "order by $PROTEIN?"); >>> >>> Again, this query worked fine in the omnigator, but I got an >>> exception >>> with TM4J. >>> >>> Exception caught: org.tm4j.tologx.TologParserException: Error parsing >>> query string. >>> org.tm4j.tologx.TologParserException: Error parsing query string. >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.prepareQuery(QueryEvaluator >>> Im >>> pl.java:155) >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.execute(QueryEvaluatorImpl. >>> ja >>> va:165) >>> at >>> mips.genre.topicmaps.TologBugTests.main(TologBugTests.java:120) >>> Caused by: line 1:128: unexpected token: "GO:0000004" >>> at >>> org.tm4j.tologx.parser.TologParser.expr(TologParser.java:1244) >>> at >>> org.tm4j.tologx.parser.TologParser.pair(TologParser.java:1151) >>> at >>> org.tm4j.tologx.parser.TologParser.predclause(TologParser.java:1085) >>> at >>> org.tm4j.tologx.parser.TologParser.clause(TologParser.java:786) >>> at >>> org.tm4j.tologx.parser.TologParser.clauselist(TologParser.java:443) >>> at >>> org.tm4j.tologx.parser.TologParser.query(TologParser.java:498) >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.prepareQuery(QueryEvaluator >>> Im >>> pl.java:151) >>> ... 2 more >>> >>> I next tried to pass the topic names in from an array. Because I >>> ultimately want to repeat the >>> query with other protein topic ID's, I tried to pass this in from the >>> array as well. >>> >>> String[] replacements = {"t-protein-ydl101c", "GO:0000004", >>> "GO:0000006"}; >>> TologResultsSet results = queryEval.execute( >>> "select $PROTEIN from " + >>> "at-has-go(%1 : tt-protein, $RESULT : tt-go), " + >>> "topic-name($GO1, $GO1_NAME), " + >>> "value($GO1_NAME, %2), " + >>> "topic-name($GO2, $GO2_NAME), " + >>> "value($GO2_NAME, %3), " + >>> "$RESULT /= $GO1, " + >>> "$RESULT /= $GO2, " + >>> "at-has-go($PROTEIN : tt-protein, $RESULT : tt-go), " + >>> "$PROTEIN /= %1 " + >>> "order by $PROTEIN?", replacements); >>> >>> This gives yet another excpetion. >>> >>> Exception caught: org.tm4j.tologx.TologProcessingException: Type >>> mismatch in replacement %1. A >>> Topic was expected. >>> org.tm4j.tologx.TologProcessingException: Type mismatch in >>> replacement >>> %1. A Topic was expected. >>> at >>> org.tm4j.tologx.parser.ClauseList.doReplacement(ClauseList.java:216) >>> at >>> org.tm4j.tologx.parser.TologQuery.execute(TologQuery.java:154) >>> at >>> org.tm4j.tologx.memory.PreparedQueryImpl.execute(PreparedQueryImpl.ja >>> va >>> :56) >>> at >>> org.tm4j.tologx.memory.QueryEvaluatorImpl.execute(QueryEvaluatorImpl. >>> ja >>> va:174) >>> at >>> mips.genre.topicmaps.TologBugTests.main(TologBugTests.java:119) >>> >>> I did find away around it, creating a string variable to hold the >>> topic ID, and concatenating this >>> into the query string. >>> >>> String[] replacements = {"GO:0000004", "GO:0000006"}; >>> String proteinID = "t-protein-ydl101c"; >>> TologResultsSet results = queryEval.execute( >>> "select $PROTEIN from " + >>> "at-has-go(" + proteinID + " : tt-protein, $RESULT : tt-go), " + >>> "topic-name($GO1, $GO1_NAME), " + >>> "value($GO1_NAME, %2), " + >>> "topic-name($GO2, $GO2_NAME), " + >>> "value($GO2_NAME, %3), " + >>> "$RESULT /= $GO1, " + >>> "$RESULT /= $GO2, " + >>> "at-has-go($PROTEIN : tt-protein, $RESULT : tt-go), " + >>> "$PROTEIN /= " + proteinID + " " + >>> "order by $PROTEIN?", replacements); >>> >>> This now works, and gives me the functionality I want, but I've no >>> idea why the earleir queries >>> gave the exceptions they did. >>> >>> Has anyone else experienced anything like these problems, or can >>> anyone explain them? I'm really >>> confused by these, especially when the queries worked in the >>> omnigator, so if anyone can offer an >>> explanation, even "tm4j bug" (sorry, Kal) I'd be grateful. >>> >>> Cheers, >>> >>> Richard. >>> >>> Send instant messages to your online friends >>> http://uk.messenger.yahoo.com >>> >>> >>> ------------------------------------------------------- >>> SF email is sponsored by - The IT Product Guide >>> Read honest & candid reviews on hundreds of IT Products from real >>> users. >>> Discover which products truly live up to the hype. Start reading now. >>> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >>> _______________________________________________ >>> Tm4j-users mailing list >>> Tm4...@li... >>> https://lists.sourceforge.net/lists/listinfo/tm4j-users >>> >>> >> >> > > Send instant messages to your online friends > http://uk.messenger.yahoo.com > > |