Improve fuzzing by supporting different metadata for VC tests
Change-Id: I61fd7d272095dda1b19f24f92cc18f83f7b14cdc
diff --git a/src/test/java/de/ids_mannheim/korap/TestSimple.java b/src/test/java/de/ids_mannheim/korap/TestSimple.java
index 0a0bf98..3727e95 100644
--- a/src/test/java/de/ids_mannheim/korap/TestSimple.java
+++ b/src/test/java/de/ids_mannheim/korap/TestSimple.java
@@ -111,8 +111,10 @@
surface += randomChar;
};
FieldDocument fd = simpleFieldDoc(surface);
- fd.addStored("copy", surface);
- fd.addStored("plain", surface);
+ String docGroup = chars.get((int)(Math.random() * 3));
+ fd.addString("docGroup", docGroup);
+ fd.addStored("test", docGroup + ":" + surface);
+ fd.addStored("plain", docGroup + ":" + surface);
return fd;
};
@@ -139,14 +141,18 @@
annotation += "|_"+i+"$<i>"+i+"<i>"+(i+1)+"]";
};
-
+ String docGroup = chars.get((int)(Math.random() * 3));
+ fd.addString("docGroup", docGroup);
fd.addTV("base",surface, annotation);
- fd.addStored("copy", surface);
- fd.addStored("plain", annotation);
+ fd.addStored("test", docGroup + ":" + surface);
+ fd.addStored("plain", docGroup + ":" + annotation);
return fd;
};
- // Create a new FieldDocument with random data
+ // Create a new FieldDocument with random data.
+ // Sentences will be indicated by a '~' symbol (and are continuous).
+ // docGroups (i.e. metadata fields called 'docGroup' with one character from the 3 characters listed)
+ // will be at the beginning of the doc and splitted by a ':' symbol.
public static FieldDocument annotatedFuzzyWithSentencesFieldDoc (List<String> chars, int minLength, int maxLength) {
FieldDocument fd = new FieldDocument();
String annotation = "";
@@ -199,10 +205,12 @@
annotation += "|_"+i+"$<i>"+i+"<i>"+(i+1)+"]";
};
-
- fd.addTV("base",surface, annotation);
- fd.addStored("copy", surface2);
- fd.addStored("plain", annotation);
+
+ String docGroup = chars.get((int)(Math.random() * 3));
+ fd.addString("docGroup", docGroup);
+ fd.addTV("base", surface, annotation);
+ fd.addStored("test", docGroup + ":" + surface2);
+ fd.addStored("plain", docGroup + ":" + annotation);
return fd;
};
@@ -306,13 +314,18 @@
return spanArray;
};
-
- // Simple fuzzing test
+ // Simple fuzzing test
public static void fuzzingTest (List<String> chars, Pattern resultPattern,
SpanQuery sq, int minTextLength, int maxTextLength, int maxDocs, int docType)
throws IOException, QueryException {
+ fuzzingTest(chars, resultPattern, new Krill(sq), minTextLength, maxTextLength, maxDocs, docType);
+ };
- Krill ks = new Krill(sq);
+ // Simple fuzzing test
+ public static void fuzzingTest (List<String> chars, Pattern resultPattern,
+ Krill ks, int minTextLength, int maxTextLength, int maxDocs, int docType)
+ throws IOException, QueryException {
+
String lastFailureConf = "";
ArrayList<String> list = new ArrayList<String>();
@@ -346,7 +359,7 @@
chars,
minTextLength, maxTextLength);
};
- String testString = testDoc.getFieldValue("copy");
+ String testString = testDoc.getFieldValue("test");
String annoString = testDoc.getFieldValue("plain");
Matcher m = resultPattern.matcher(testString);
list.add(testString);
@@ -384,8 +397,7 @@
return;
};
};
- */
-
+ */
Result kr = ks.apply(ki);