Adding helper methods for fuzzing
Change-Id: I0be2a884735f4b4802b35ab44888bca153a7c0bc
diff --git a/src/test/java/de/ids_mannheim/korap/TestSimple.java b/src/test/java/de/ids_mannheim/korap/TestSimple.java
index e83891d..1d7cb99 100644
--- a/src/test/java/de/ids_mannheim/korap/TestSimple.java
+++ b/src/test/java/de/ids_mannheim/korap/TestSimple.java
@@ -60,6 +60,36 @@
w.addDocument(doc);
};
+ // Add document
+ public static FieldDocument simpleFieldDoc (String s) {
+ String[] characters = s.split("");
+
+ FieldDocument fd = new FieldDocument();
+ String surface = "";
+ String annotation = "";
+
+ for (int i = 0; i < characters.length; i++) {
+ String fixChar = characters[i];
+ surface += fixChar;
+ annotation +=
+ "[("+i+"-"+(i+1)+")s:"+fixChar+
+ "|_"+i+"$<i>"+i+"<i>"+(i+1)+"]";
+ };
+
+ fd.addTV("base",surface, annotation);
+ return fd;
+ };
+
+ public static FieldDocument simpleFuzzyFieldDoc (List<String> chars, int minLength, int maxLength) {
+ String surface = "";
+
+ for (int i = 0; i < (int)(Math.random() * (maxLength - minLength)) + minLength; i++) {
+ String randomChar = chars.get((int)(Math.random() * 6));
+ surface += randomChar;
+ };
+ return simpleFieldDoc(surface);
+
+ };
// Get Term Vector
public static MultiTermTokenStream getTermVector (String stream) {