aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2021-11-12 15:24:49 +0000
committerFederico Igne <federico.igne@cs.ox.ac.uk>2021-11-12 15:24:49 +0000
commitdc9209dd91980ed67f0f4b46e0bb223a6854914a (patch)
treecc8c99ae877c85300a26f565ed598249755a78bc
parent81ace9b58bf736e317b3a348a9bc724177479327 (diff)
downloadRSAComb-dc9209dd91980ed67f0f4b46e0bb223a6854914a.tar.gz
RSAComb-dc9209dd91980ed67f0f4b46e0bb223a6854914a.zip
Make query parsing more forgiving on syntax errors
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala
index 4153fac..fe1abf7 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/util/RDFoxUtil.scala
@@ -260,7 +260,7 @@ object RDFoxUtil {
260 path: os.Path, 260 path: os.Path,
261 prefixes: Prefixes = new Prefixes() 261 prefixes: Prefixes = new Prefixes()
262 ): List[ConjunctiveQuery] = { 262 ): List[ConjunctiveQuery] = {
263 val header = raw"\^\[[Qq]uery(\d+)\]".r 263 val header = "#?\\^\\[[Qq]uery(\\d+)\\]".r
264 val comment = "^#.*".r 264 val comment = "^#.*".r
265 val queries = os.read 265 val queries = os.read
266 .lines(path) 266 .lines(path)
@@ -270,9 +270,13 @@ object RDFoxUtil {
270 case (line, (acc, query)) => { 270 case (line, (acc, query)) => {
271 line match { 271 line match {
272 case header(id) => { 272 case header(id) => {
273 val cq = 273 if (query.isEmpty) {
274 ConjunctiveQuery.parse(id.toInt, query.mkString(" "), prefixes) 274 (acc, List.empty)
275 (cq :: acc, List.empty) 275 } else {
276 val cq =
277 ConjunctiveQuery.parse(id.toInt, query.mkString(" "), prefixes)
278 (cq :: acc, List.empty)
279 }
276 } 280 }
277 case comment() => (acc, query) 281 case comment() => (acc, query)
278 case _ => (acc, line :: query) 282 case _ => (acc, line :: query)