You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "tobiaswjohn (via GitHub)" <gi...@apache.org> on 2024/09/17 14:20:45 UTC

[I] Parsing of double and decimal fails [jena]

tobiaswjohn opened a new issue, #2715:
URL: https://github.com/apache/jena/issues/2715

   ### Version
   
   5.1.0
   
   ### What happened?
   
   Parsing double and decimal numbers in turtle format can fail, even if the numbers are according to the grammar. This can happen, if the numbers have a sign but not a leading '0' before a dot, e.g. as in the following example:
   ```
   <iri1> <iri2> -.2e3 .
   ```
   
   I load it using `RDFDataMgr.loadDataset(<path>)` This leads to an exception. 
   
   I suspect the problem to be in [TokenizerText.java, line 450](https://github.com/apache/jena/blob/def3fdd1dc1abaea5fd39ecfd01bb2d531d27ceb/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java#L450), where it is only checked if a leading sign is followed by a digit, not by a dot, to decide if the following symbols are part of the token (also the comment in [line 429](https://github.com/apache/jena/blob/def3fdd1dc1abaea5fd39ecfd01bb2d531d27ceb/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java#L429) in the same file suggests that this is the misunderstanding). 
   
   Note: The turtle grammar in [turtle.jj](https://github.com/apache/jena/blob/main/jena-arq/Grammar/Turtle/turtle.jj) seems to be correct w.r.t. the shape of doubles and decimals.
   
   ### Relevant output and stacktrace
   
   ```shell
   Exception in thread "main" org.apache.jena.riot.RiotException: [line: 1, col: 15] Unrecognized (expected an RDF Term): [MINUS]
   	at org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.fatal(ErrorHandlerFactory.java:155)
   	at org.apache.jena.riot.lang.LangEngine.raiseException(LangEngine.java:148)
   	at org.apache.jena.riot.lang.LangEngine.exceptionDirect(LangEngine.java:143)
   	at org.apache.jena.riot.lang.LangEngine.exception(LangEngine.java:137)
   	at org.apache.jena.riot.lang.LangTurtleBase.triplesNodeCompound(LangTurtleBase.java:489)
   	at org.apache.jena.riot.lang.LangTurtleBase.triplesNode(LangTurtleBase.java:469)
   	at org.apache.jena.riot.lang.LangTurtleBase.objectList(LangTurtleBase.java:419)
   	at org.apache.jena.riot.lang.LangTurtleBase.predicateObjectItem(LangTurtleBase.java:352)
   	at org.apache.jena.riot.lang.LangTurtleBase.predicateObjectList(LangTurtleBase.java:333)
   	at org.apache.jena.riot.lang.LangTurtleBase.triples(LangTurtleBase.java:314)
   	at org.apache.jena.riot.lang.LangTurtleBase.triplesSameSubject(LangTurtleBase.java:178)
   	at org.apache.jena.riot.lang.LangTurtle.oneTopLevelElement(LangTurtle.java:46)
   	at org.apache.jena.riot.lang.LangTurtleBase.runParser(LangTurtleBase.java:79)
   	at org.apache.jena.riot.lang.LangBase.parse(LangBase.java:43)
   	at org.apache.jena.riot.lang.RiotParsers$AbstractReaderRIOTLang.read(RiotParsers.java:133)
   	at org.apache.jena.riot.lang.RiotParsers$AbstractReaderRIOTLang.read(RiotParsers.java:91)
   	at org.apache.jena.riot.RDFParser.read(RDFParser.java:452)
   	at org.apache.jena.riot.RDFParser.parseURI(RDFParser.java:421)
   	at org.apache.jena.riot.RDFParser.parse(RDFParser.java:383)
   	at org.apache.jena.riot.RDFParserBuilder.parse(RDFParserBuilder.java:547)
   	at org.apache.jena.riot.RDFDataMgr.parseFromURI(RDFDataMgr.java:564)
   	at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:429)
   	at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:406)
   	at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:386)
   	at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:377)
   	at org.apache.jena.riot.RDFDataMgr.loadDataset(RDFDataMgr.java:337)
   ```
   
   
   ### Are you interested in making a pull request?
   
   None


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] Parsing of double and decimal fails [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #2715:
URL: https://github.com/apache/jena/issues/2715#issuecomment-2356866464

   @tobiaswjohn - thank you for the report and analysis. I have reproduced the problem.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] Parsing of double and decimal fails [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs closed issue #2715: Parsing of double and decimal fails
URL: https://github.com/apache/jena/issues/2715


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org