Support alternative doublequotes (fix #56)
Change-Id: Ieca17628983dbef610b8cbeeedb5db2ec7715b7d
diff --git a/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4 b/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
index d911511..81dbec7 100644
--- a/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
+++ b/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
@@ -13,6 +13,9 @@
-- author: Joachim Bingel
-- date: 14-06-27
+ -- updated: 28-09-2018 (diewald)
+
+
Poliqarp Query Language lexer
Language documentations:
@@ -104,9 +107,8 @@
fragment RE_occ : (RE_char | RE_chgroup | ( '(' RE_expr ')')) FOCC;
fragment RE_group : '(' RE_expr ')';
fragment RE_expr : ('.' | RE_char | RE_alter | RE_chgroup | RE_opt | RE_quant | RE_group)+;
-fragment RE_dquote : '"' (RE_expr | '\'' | ':' )* '"';
-// fragment RE_squote : '\'' (RE_expr | '\"' | ':' )* '\'';
-
+fragment RE_dquote : ('"'|'„'|'“') (RE_expr | '\'' | ':' )* ('"'|'“'|'”');
+
REGEX : RE_dquote;
ESC_SQUOTE : BACKSLASH SQUOTE;
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
index f59d769..c194f94 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
@@ -180,6 +180,27 @@
assertEquals("orth", res.at("/query/wrap/layer").asText());
assertEquals("match:eq", res.at("/query/wrap/match").asText());
+ // issue #56
+ query = "„.*?Mann.*?“";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:token", res.at("/query/@type").asText());
+ assertEquals("koral:term", res.at("/query/wrap/@type").asText());
+ assertEquals(".*?Mann.*?", res.at("/query/wrap/key").asText());
+ assertEquals("type:regex", res.at("/query/wrap/type").asText());
+ assertEquals("orth", res.at("/query/wrap/layer").asText());
+ assertEquals("match:eq", res.at("/query/wrap/match").asText());
+
+ query = "“.*?Mann.*?”";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:token", res.at("/query/@type").asText());
+ assertEquals("koral:term", res.at("/query/wrap/@type").asText());
+ assertEquals(".*?Mann.*?", res.at("/query/wrap/key").asText());
+ assertEquals("type:regex", res.at("/query/wrap/type").asText());
+ assertEquals("orth", res.at("/query/wrap/layer").asText());
+ assertEquals("match:eq", res.at("/query/wrap/match").asText());
+
query = "z.B./x";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());