|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SpanNotQuery | Line # 29 | 69 | 44 | 75.8% |
0.7583333
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (25) | |||
| Result | |||
|
0.725
|
org.apache.lucene.search.TestComplexExplanations.testSNot9
org.apache.lucene.search.TestComplexExplanations.testSNot9
|
1 PASS | |
|
0.725
|
org.apache.lucene.search.TestComplexExplanations.testSNot8
org.apache.lucene.search.TestComplexExplanations.testSNot8
|
1 PASS | |
|
0.725
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot10
org.apache.lucene.search.spans.TestSpanExplanations.testSNot10
|
1 PASS | |
|
0.725
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot7
org.apache.lucene.search.spans.TestSpanExplanations.testSNot7
|
1 PASS | |
|
0.71666664
|
org.apache.lucene.search.spans.TestBasics.testSpanWithMultipleNotMany
org.apache.lucene.search.spans.TestBasics.testSpanWithMultipleNotMany
|
1 PASS | |
|
0.71666664
|
org.apache.lucene.search.spans.TestBasics.testSpanNot
org.apache.lucene.search.spans.TestBasics.testSpanNot
|
1 PASS | |
|
0.71666664
|
org.apache.lucene.search.spans.TestBasics.testNpeInSpanNearWithSpanNot
org.apache.lucene.search.spans.TestBasics.testNpeInSpanNearWithSpanNot
|
1 PASS | |
|
0.71666664
|
org.apache.lucene.search.spans.TestBasics.testSpanWithMultipleNotSingle
org.apache.lucene.search.spans.TestBasics.testSpanWithMultipleNotSingle
|
1 PASS | |
|
0.7083333
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot5
org.apache.lucene.search.spans.TestSpanExplanations.testSNot5
|
1 PASS | |
|
0.7083333
|
org.apache.lucene.search.spans.TestBasics.testNpeInSpanNearInSpanFirstInSpanNot
org.apache.lucene.search.spans.TestBasics.testNpeInSpanNearInSpanFirstInSpanNot
|
1 PASS | |
|
0.7083333
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot4
org.apache.lucene.search.spans.TestSpanExplanations.testSNot4
|
1 PASS | |
|
0.6666667
|
org.apache.lucene.search.TestComplexExplanations.testSNot6
org.apache.lucene.search.TestComplexExplanations.testSNot6
|
1 PASS | |
|
0.60833335
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot2
org.apache.lucene.search.spans.TestSpanExplanations.testSNot2
|
1 PASS | |
|
0.60833335
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot1
org.apache.lucene.search.spans.TestSpanExplanations.testSNot1
|
1 PASS | |
|
0.56666666
|
org.apache.lucene.search.TestComplexExplanations.testSNot3
org.apache.lucene.search.TestComplexExplanations.testSNot3
|
1 PASS | |
|
0.55
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot10
org.apache.lucene.search.spans.TestSpanExplanations.testSNot10
|
1 PASS | |
|
0.55
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot7
org.apache.lucene.search.spans.TestSpanExplanations.testSNot7
|
1 PASS | |
|
0.55
|
org.apache.lucene.search.TestComplexExplanations.testSNot8
org.apache.lucene.search.TestComplexExplanations.testSNot8
|
1 PASS | |
|
0.55
|
org.apache.lucene.search.TestComplexExplanations.testSNot9
org.apache.lucene.search.TestComplexExplanations.testSNot9
|
1 PASS | |
|
0.11666667
|
org.apache.lucene.search.TestComplexExplanations.testSNot3
org.apache.lucene.search.TestComplexExplanations.testSNot3
|
1 PASS | |
|
0.11666667
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot4
org.apache.lucene.search.spans.TestSpanExplanations.testSNot4
|
1 PASS | |
|
0.11666667
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot2
org.apache.lucene.search.spans.TestSpanExplanations.testSNot2
|
1 PASS | |
|
0.11666667
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot1
org.apache.lucene.search.spans.TestSpanExplanations.testSNot1
|
1 PASS | |
|
0.11666667
|
org.apache.lucene.search.spans.TestSpanExplanations.testSNot5
org.apache.lucene.search.spans.TestSpanExplanations.testSNot5
|
1 PASS | |
|
0.11666667
|
org.apache.lucene.search.TestComplexExplanations.testSNot6
org.apache.lucene.search.TestComplexExplanations.testSNot6
|
1 PASS | |
| 1 | package org.apache.lucene.search.spans; | |
| 2 | ||
| 3 | /** | |
| 4 | * Copyright 2004 The Apache Software Foundation | |
| 5 | * | |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 7 | * you may not use this file except in compliance with the License. | |
| 8 | * You may obtain a copy of the License at | |
| 9 | * | |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 11 | * | |
| 12 | * Unless required by applicable law or agreed to in writing, software | |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 15 | * See the License for the specific language governing permissions and | |
| 16 | * limitations under the License. | |
| 17 | */ | |
| 18 | ||
| 19 | import java.io.IOException; | |
| 20 | ||
| 21 | import java.util.Collection; | |
| 22 | import java.util.Set; | |
| 23 | ||
| 24 | import org.apache.lucene.index.IndexReader; | |
| 25 | import org.apache.lucene.search.Query; | |
| 26 | import org.apache.lucene.util.ToStringUtils; | |
| 27 | ||
| 28 | /** Removes matches which overlap with another SpanQuery. */ | |
| 29 | public class SpanNotQuery extends SpanQuery { | |
| 30 | private SpanQuery include; | |
| 31 | private SpanQuery exclude; | |
| 32 | ||
| 33 | /** Construct a SpanNotQuery matching spans from <code>include</code> which | |
| 34 | * have no overlap with spans from <code>exclude</code>.*/ | |
| 35 | 25 |
public SpanNotQuery(SpanQuery include, SpanQuery exclude) { |
| 36 | 25 | this.include = include; |
| 37 | 25 | this.exclude = exclude; |
| 38 | ||
| 39 | 25 | if (!include.getField().equals(exclude.getField())) |
| 40 | 0 | throw new IllegalArgumentException("Clauses must have same field."); |
| 41 | } | |
| 42 | ||
| 43 | /** Return the SpanQuery whose matches are filtered. */ | |
| 44 | 0 |
public SpanQuery getInclude() { return include; } |
| 45 | ||
| 46 | /** Return the SpanQuery whose matches must not overlap those returned. */ | |
| 47 | 0 |
public SpanQuery getExclude() { return exclude; } |
| 48 | ||
| 49 | 185 |
public String getField() { return include.getField(); } |
| 50 | ||
| 51 | /** Returns a collection of all terms matched by this query. | |
| 52 | * @deprecated use extractTerms instead | |
| 53 | * @see #extractTerms(Set) | |
| 54 | */ | |
| 55 | 0 |
public Collection getTerms() { return include.getTerms(); } |
| 56 | ||
| 57 | 129 |
public void extractTerms(Set terms) { include.extractTerms(terms); } |
| 58 | ||
| 59 | 209 |
public String toString(String field) { |
| 60 | 209 | StringBuffer buffer = new StringBuffer(); |
| 61 | 209 | buffer.append("spanNot("); |
| 62 | 209 | buffer.append(include.toString(field)); |
| 63 | 209 | buffer.append(", "); |
| 64 | 209 | buffer.append(exclude.toString(field)); |
| 65 | 209 | buffer.append(")"); |
| 66 | 209 | buffer.append(ToStringUtils.boost(getBoost())); |
| 67 | 209 | return buffer.toString(); |
| 68 | } | |
| 69 | ||
| 70 | ||
| 71 | 129 |
public Spans getSpans(final IndexReader reader) throws IOException { |
| 72 | 129 | return new Spans() { |
| 73 | private Spans includeSpans = include.getSpans(reader); | |
| 74 | private boolean moreInclude = true; | |
| 75 | ||
| 76 | private Spans excludeSpans = exclude.getSpans(reader); | |
| 77 | private boolean moreExclude = excludeSpans.next(); | |
| 78 | ||
| 79 | ||