Revision: 14819
          http://gate.svn.sourceforge.net/gate/?rev=14819&view=rev
Author:   valyt
Date:     2011-12-21 10:08:59 +0000 (Wed, 21 Dec 2011)
Log Message:
-----------
Produced some code that shows the empty index problem (exception on search 
instead of no results). This will be useful to test the fix when we get a new 
MG4J version.

Modified Paths:
--------------
    mimir/branches/3.4/mimir-test/src/gate/mimir/test/Scratch.java

Modified: mimir/branches/3.4/mimir-test/src/gate/mimir/test/Scratch.java
===================================================================
--- mimir/branches/3.4/mimir-test/src/gate/mimir/test/Scratch.java      
2011-12-21 10:07:37 UTC (rev 14818)
+++ mimir/branches/3.4/mimir-test/src/gate/mimir/test/Scratch.java      
2011-12-21 10:08:59 UTC (rev 14819)
@@ -11,7 +11,11 @@
 import java.text.NumberFormat;
 
 import gate.Gate;
+import gate.mimir.AbstractSemanticAnnotationHelper;
+import gate.mimir.IndexConfig;
+import gate.mimir.index.Indexer;
 import gate.mimir.search.QueryEngine;
+import gate.mimir.search.QueryRunner;
 import gate.mimir.search.query.QueryExecutor;
 import gate.mimir.search.query.QueryNode;
 import gate.mimir.search.query.parser.QueryParser;
@@ -63,4 +67,43 @@
       nf.format(System.currentTimeMillis() - start) + " ms.");
     qEngine.close();
   }
+  
+  public static void mainEmptyIndex(String[] args) throws Exception {
+    Gate.setGateHome(new File("gate-home"));
+    Gate.setUserConfigFile(new File("gate-home/user-gate.xml"));
+    Gate.init();
+    // load the tokeniser plugin
+    Gate.getCreoleRegister().registerDirectories(
+      new File("gate-home/plugins/ANNIE-tokeniser").toURI().toURL());
+    // load the DB plugin
+    Gate.getCreoleRegister().registerDirectories(
+      new File("../plugins/db-h2").toURI().toURL());
+    Gate.getCreoleRegister().registerDirectories(
+      new File("../plugins/sesame").toURI().toURL());    
+    // load the measurements plugin
+    Gate.getCreoleRegister().registerDirectories(
+      new File("../plugins/measurements").toURI().toURL());
+    Gate.getCreoleRegister().registerDirectories(
+      new File("../plugins/sparql").toURI().toURL());
+    
+    File indexDir = new File("index-empty");
+    IndexConfig indexConfig = TestUtils.getTestIndexConfig(indexDir, 
+      Class.forName("gate.mimir.db.DBSemanticAnnotationHelper", true, 
+        
Gate.getClassLoader()).asSubclass(AbstractSemanticAnnotationHelper.class));
+    // now start indexing the documents
+    Indexer indexer = new Indexer(indexConfig);    
+    // add no documents
+    // clsoe
+    indexer.close();
+    // now open the index
+    QueryEngine qEngine = new QueryEngine(indexDir);
+    String query = "the";
+    QueryRunner qRunner = qEngine.getQueryRunner(query);
+    int docCount = qRunner.getDocumentsCount();
+    while(docCount < 0) {
+      Thread.sleep(200);
+      docCount = qRunner.getDocumentsCount();
+    }
+    System.out.println("Found " + docCount + " documents.");
+  }
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to