Skip to content

Commit ba307f2

Browse files
committed
Make match expansion configurable (#150)
Change-Id: Ie4eb9098f6e7352918e1fd0d3bf74615d3508e7e
1 parent 264e10f commit ba307f2

File tree

6 files changed

+22
-5
lines changed

6 files changed

+22
-5
lines changed

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
0.62.6 2024-06-13
2+
- [feature] Make match expansion configurable (close #150, margaretha)
3+
14
0.62.5 2024-06-11
25
- [bugfix] cut primary data according to max values (margaretha, #143)
36
- [enhancement] restrict match expansion by max token and context

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
<groupId>de.ids-mannheim.korap.krill</groupId>
3737
<artifactId>Krill</artifactId>
38-
<version>0.62.5</version>
38+
<version>0.62.6</version>
3939
<packaging>jar</packaging>
4040

4141
<name>Krill</name>

src/main/java/de/ids_mannheim/korap/response/Match.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,11 @@ public void expandContextToSpan (String element) {
11171117

11181118
if (spanContext[0] >= 0
11191119
&& spanContext[0] < spanContext[1]) {
1120-
1121-
int maxExpansionSize = KrillProperties.maxTokenMatchSize
1122-
+ KrillProperties.maxTokenContextSize;
1120+
1121+
int maxExpansionSize = KrillProperties.maxTokenMatchSize;
1122+
if (KrillProperties.matchExpansionIncludeContextSize) {
1123+
maxExpansionSize += KrillProperties.maxTokenContextSize;
1124+
}
11231125

11241126
// Match needs to be cutted!
11251127
boolean cutExpansion = false;

src/main/java/de/ids_mannheim/korap/util/KrillProperties.java

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class KrillProperties {
2323
public static int maxTokenContextSize = 60;
2424
public static int maxCharContextSize = 500;
2525

26+
public static boolean matchExpansionIncludeContextSize = false;
27+
2628
public static String namedVCPath = "";
2729
public static boolean isTest = false;
2830

@@ -100,6 +102,10 @@ public static void updateConfigurations (Properties prop) {
100102
isTest = Boolean.parseBoolean(p);
101103

102104
namedVCPath = prop.getProperty("krill.namedVC", "");
105+
106+
String matchExpansion = prop.getProperty(
107+
"krill.match." + "expansion.includeContextSize", "false");
108+
matchExpansionIncludeContextSize = Boolean.parseBoolean(matchExpansion);
103109
}
104110

105111

src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import de.ids_mannheim.korap.response.Result;
3131
import de.ids_mannheim.korap.response.match.MatchIdentifier;
3232
import de.ids_mannheim.korap.response.match.PosIdentifier;
33+
import de.ids_mannheim.korap.util.KrillProperties;
3334
import de.ids_mannheim.korap.util.QueryException;
3435

3536
@RunWith(JUnit4.class)
@@ -1219,6 +1220,8 @@ public void indexWithFieldInfo () throws IOException, QueryException {
12191220

12201221
@Test
12211222
public void indexCorolaTokensBugReplicated () throws IOException, QueryException {
1223+
KrillProperties.matchExpansionIncludeContextSize=false;
1224+
12221225
KrillIndex ki = new KrillIndex();
12231226

12241227
ki.addDoc(getClass().getResourceAsStream("/others/corola-bug.json"), false);
@@ -1239,14 +1242,16 @@ public void indexCorolaTokensBugReplicated () throws IOException, QueryException
12391242

12401243
String str = km.getSnippetBrackets();
12411244
assertTrue(str.contains("[<!>{drukola/l:au:a}"));
1242-
assertFalse(str.contains("<!>]"));
1245+
assertTrue(str.contains("<!>]"));
12431246

12441247
km = ki.getMatchInfo("match-Corola-blog/BlogPost/370281_a_371610-p50-51", "tokens", null, null,false, false, true);
12451248

12461249
// The match needs to be cutted on both sides!
12471250
str = km.getSnippetBrackets();
12481251
assertTrue(str.contains("[<!>{d"));
12491252
assertTrue(str.contains("a}<!>]"));
1253+
1254+
KrillProperties.matchExpansionIncludeContextSize=true;
12501255
};
12511256

12521257

src/test/resources/krill.properties

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ krill.index.commit.count = 15
66
krill.namedVC = queries/collections/named-vcs/
77
krill.test = true
88

9+
krill.match.expansion.includeContextSize = true
910
krill.match.max.token=50
1011
krill.context.max.token=25

0 commit comments

Comments
 (0)