First test for a real index
diff --git a/pom.xml b/pom.xml
index 025ecf7..e127b7b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -118,6 +118,36 @@
<target>1.7</target>
</configuration>
</plugin>
+
+ <!--
+ install the indexer
+ $ mvn clean compile assembly:single
+ Then run e.g.
+ $ java -jar target/KorAP-lucene-index-0.20-jar-with-dependencies.jar src/test/resources/wiki/
+
+ -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>de.ids_mannheim.korap.KorapIndexer</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<!--
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
diff --git a/src/main/java/de/ids_mannheim/korap/KorapIndex.java b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
index 62bb1f2..58d90ca 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
@@ -115,7 +115,6 @@
this(FSDirectory.open(new File( index )));
};
-
public KorapIndex (Directory directory) throws IOException {
this.directory = directory;
diff --git a/src/main/java/de/ids_mannheim/korap/KorapIndexer.java b/src/main/java/de/ids_mannheim/korap/KorapIndexer.java
new file mode 100644
index 0000000..d6361fe
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/KorapIndexer.java
@@ -0,0 +1,55 @@
+package de.ids_mannheim.korap;
+import java.util.*;
+import java.io.*;
+import org.apache.lucene.store.MMapDirectory;
+import de.ids_mannheim.korap.KorapIndex;
+
+public class KorapIndexer {
+ KorapIndex index;
+ int count;
+
+ public KorapIndexer () throws IOException {
+ this.index = new KorapIndex(new MMapDirectory(new File("target/test/")));
+ this.count = 0;
+ };
+
+ public void parse (File dir) {
+ for (String file : dir.list()) {
+ if (file.matches("^[^\\.].+?\\.json\\.gz$")) {
+ String found = dir.getPath() + '/' + file;
+ System.out.print(" Index " + found + " ... ");
+ try {
+ this.index.addDocFile(found, true);
+ }
+ catch (IOException e) {
+ System.out.println("fail.");
+ continue;
+ };
+ System.out.println("done.");
+ this.count++;
+ };
+ };
+ };
+
+ public static void main(String[] args) throws IOException {
+
+ KorapIndexer ki = new KorapIndexer();
+
+ System.out.println();
+
+ for (String arg : args) {
+ File f = new File( arg );
+ if (f.isDirectory()) {
+ ki.parse(f);
+ };
+ };
+
+ System.out.println("-----");
+ System.out.print(" Commit ... ");
+ ki.index.commit();
+ System.out.println("done.");
+ System.out.println("-----");
+ System.out.println(" Indexed " + ki.count + " files.");
+ System.out.println();
+ };
+};
\ No newline at end of file