Added exclusion to KorapQuery wrapper
diff --git a/src/main/java/de/ids_mannheim/korap/KorapQuery.java b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
index 28fbcc0..bb6261c 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
@@ -40,6 +40,10 @@
// Logger
private final static Logger log = LoggerFactory.getLogger(KorapQuery.class);
+ // This advices the java compiler to ignore all loggings
+ public static final boolean DEBUG = false;
+
+
/**
* Constructs a new base object for query generation.
* @param field The specific index field for the query.
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
index ad97152..7e4ee9e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
@@ -19,6 +19,9 @@
import java.util.Map;
import java.util.Set;
+/**
+ * @author Nils Diewald
+ */
/** Matches spans wrapped by an element. */
public class SpanElementQuery extends SpanQuery {
@@ -121,7 +124,9 @@
return new ElementSpans(postings, element);
// element does exist, but has no positions
- throw new IllegalStateException("field \"" + element.field() + "\" was indexed without position data; cannot run SpanElementQuery (element=" + element.text() + ")");
+ throw new IllegalStateException("field \"" + element.field() + "\" was indexed " +
+ "without position data; cannot run " +
+ "SpanElementQuery (element=" + element.text() + ")");
};
public String getElementStr () {
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
index f10809c..a44ed49 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
@@ -23,7 +23,7 @@
// TODO: Store payloads in 12 byte instead of the complicated ByteBuffer stuff!
/**
- * @author ndiewald
+ * @author Nils Diewald
*/
public class ElementSpans extends Spans {
@@ -47,6 +47,10 @@
private final static Logger log = LoggerFactory.getLogger(ElementSpans.class);
+
+ /**
+ * The constructor.
+ */
public ElementSpans(DocsAndPositionsEnum postings, Term term) {
this.postings = postings;
this.term = term;
@@ -61,7 +65,7 @@
};
// only for EmptyElementSpans (below)
- ElementSpans() {
+ public ElementSpans() {
term = null;
postings = null;
};
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
index 5fa21d0..e6c0488 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
@@ -90,25 +90,37 @@
};
public SpanSequenceQueryWrapper withConstraint (int min, int max) {
+ return this.withConstraint(min, max, false);
+ };
+
+ public SpanSequenceQueryWrapper withConstraint (int min, int max, boolean exclusion) {
if (this.constraints == null)
this.constraints = new ArrayList<DistanceConstraint>(1);
- this.constraints.add(new DistanceConstraint(min, max,false));
+ this.constraints.add(new DistanceConstraint(min, max, exclusion));
return this;
};
public SpanSequenceQueryWrapper withConstraint (int min, int max, String unit) {
+ return this.withConstraint(min, max, unit, false);
+ };
+
+ public SpanSequenceQueryWrapper withConstraint (int min,
+ int max,
+ String unit,
+ boolean exclusion) {
if (this.constraints == null)
this.constraints = new ArrayList<DistanceConstraint>(1);
if (unit.equals("w"))
- this.constraints.add(new DistanceConstraint(min, max,false));
+ this.constraints.add(new DistanceConstraint(min, max, exclusion));
else
this.constraints.add(
new DistanceConstraint(
- new SpanElementQuery(this.field, unit), min, max,false)
+ new SpanElementQuery(this.field, unit), min, max, exclusion)
);
return this;
};
+
public SpanQuery toQuery () {
if (this.segments.size() == 0) {
return (SpanQuery) null;
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index e876668..c5ac092 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,6 +1,6 @@
## logger file can be used with
-# log4j.rootLogger = DEBUG, stdout
+log4j.rootLogger = DEBUG, stdout
# Spans:
#log4j.logger.de.ids_mannheim.korap.query.spans.ElementSpans = TRACE, stdout