Revision: 14466
          http://gate.svn.sourceforge.net/gate/?rev=14466&view=rev
Author:   valyt
Date:     2011-10-31 17:22:03 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
- test data: moved the document metadata to document features;
- default testing index config now uses the new document metadata functioanlity;

Document features seem to work when using the H2 plugin. Next: do the same for 
the Sesame one.

Modified Paths:
--------------
    mimir/trunk/mimir-test/data/gatexml-output.zip
    mimir/trunk/mimir-test/src/gate/mimir/test/QueryTests.java
    mimir/trunk/mimir-test/src/gate/mimir/test/TestUtils.java

Added Paths:
-----------
    mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java

Modified: mimir/trunk/mimir-test/data/gatexml-output.zip
===================================================================
(Binary files differ)

Modified: mimir/trunk/mimir-test/src/gate/mimir/test/QueryTests.java
===================================================================
--- mimir/trunk/mimir-test/src/gate/mimir/test/QueryTests.java  2011-10-31 
17:19:36 UTC (rev 14465)
+++ mimir/trunk/mimir-test/src/gate/mimir/test/QueryTests.java  2011-10-31 
17:22:03 UTC (rev 14466)
@@ -23,6 +23,7 @@
 import static org.junit.Assert.fail;
 import gate.Document;
 import gate.Gate;
+import gate.mimir.AbstractSemanticAnnotationHelper;
 import gate.mimir.IndexConfig;
 import gate.mimir.SemanticAnnotationHelper;
 import gate.mimir.index.IndexException;
@@ -79,6 +80,7 @@
   @BeforeClass
   public static void oneTimeSetUp() 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());
@@ -93,7 +95,7 @@
     // would use: "gate.mimir.ordi.ORDISemanticAnnotationHelper")
     IndexConfig indexConfig = TestUtils.getTestIndexConfig(indexDir, 
             Class.forName("gate.mimir.db.DBSemanticAnnotationHelper", true, 
-                
Gate.getClassLoader()).asSubclass(SemanticAnnotationHelper.class));
+                
Gate.getClassLoader()).asSubclass(AbstractSemanticAnnotationHelper.class));
     // now start indexing the documents
     Indexer indexer = new Indexer(indexConfig);
     String pathToZipFile = "data/gatexml-output.zip";
@@ -125,9 +127,9 @@
       engine.close();
       engine = null;
       // recursively delete index dir
-      if(!TestUtils.deleteDir(indexDir)) {
-        System.err.println("Could not delete index directory " + indexDir);
-      }
+//      if(!TestUtils.deleteDir(indexDir)) {
+//        System.err.println("Could not delete index directory " + indexDir);
+//      }
     }
   }
 

Added: mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java
===================================================================
--- mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java                     
        (rev 0)
+++ mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java     2011-10-31 
17:22:03 UTC (rev 14466)
@@ -0,0 +1,64 @@
+package gate.mimir.test;
+
+import it.unimi.dsi.mg4j.search.score.BM25FScorer;
+import it.unimi.dsi.mg4j.search.score.BM25Scorer;
+import it.unimi.dsi.mg4j.search.score.CountScorer;
+import it.unimi.dsi.mg4j.search.score.DelegatingScorer;
+import it.unimi.dsi.mg4j.search.score.Scorer;
+import it.unimi.dsi.mg4j.search.score.TfIdfScorer;
+
+import java.io.File;
+import java.text.NumberFormat;
+
+import gate.Gate;
+import gate.mimir.search.QueryEngine;
+import gate.mimir.search.query.QueryExecutor;
+import gate.mimir.search.query.QueryNode;
+import gate.mimir.search.query.parser.QueryParser;
+
+public class Scratch {
+
+  public static void main(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());
+    // load the measurements plugin
+    Gate.getCreoleRegister().registerDirectories(
+      new File("../plugins/measurements").toURI().toURL());
+    Gate.getCreoleRegister().registerDirectories(
+      new File("../plugins/sparql").toURI().toURL());
+    
+    QueryEngine qEngine = new QueryEngine(new File(args[0]));
+//    String query = "the";
+    String query = "{Document}";
+    QueryNode qNode = QueryParser.parse(query);
+    long start = System.currentTimeMillis();
+    NumberFormat nf = NumberFormat.getNumberInstance();
+    long startLocal = System.currentTimeMillis();
+    QueryExecutor qExecutor = qNode.getQueryExecutor(qEngine);
+    int latestDoc = qExecutor.nextDocument(-1);
+    int totalHitCount = 0;
+    int docCount = 0;
+    while(latestDoc >= 0) {
+      docCount++;
+      int hitCount = 0;
+      while(qExecutor.nextHit() != null) hitCount++;
+      totalHitCount += hitCount;
+      System.out.println("Doc " + latestDoc + ", hits: " + hitCount);
+      latestDoc = qExecutor.nextDocument(-1);
+    }
+    System.out.println("Found " + nf.format(totalHitCount) + " hits in " +
+      nf.format(docCount) + " documents, in " +
+      nf.format(System.currentTimeMillis() - startLocal) + " ms.");
+    qExecutor.close();
+    System.out.println("Total time " +
+      nf.format(System.currentTimeMillis() - start) + " ms.");
+    qEngine.close();
+  }
+}


Property changes on: mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Modified: mimir/trunk/mimir-test/src/gate/mimir/test/TestUtils.java
===================================================================
--- mimir/trunk/mimir-test/src/gate/mimir/test/TestUtils.java   2011-10-31 
17:19:36 UTC (rev 14465)
+++ mimir/trunk/mimir-test/src/gate/mimir/test/TestUtils.java   2011-10-31 
17:22:03 UTC (rev 14466)
@@ -20,6 +20,7 @@
 import gate.Gate;
 import gate.creole.ANNIEConstants;
 import gate.mimir.index.*;
+import gate.mimir.AbstractSemanticAnnotationHelper;
 import gate.mimir.DocumentMetadataHelper;
 import gate.mimir.IndexConfig;
 import gate.mimir.SemanticAnnotationHelper;
@@ -44,11 +45,11 @@
 public class TestUtils {
   
   public static IndexConfig getTestIndexConfig(File indexDir, 
-                 Class<? extends SemanticAnnotationHelper> helperClass) 
+                 Class<? extends AbstractSemanticAnnotationHelper> 
helperClass) 
   throws IllegalArgumentException, InstantiationException, 
       IllegalAccessException, InvocationTargetException, SecurityException, 
       NoSuchMethodException, ClassNotFoundException {
-       Constructor<? extends SemanticAnnotationHelper> helperMaker = 
+       Constructor<? extends AbstractSemanticAnnotationHelper> helperMaker = 
                helperClass.getConstructor(String.class, String[].class, 
String[].class, 
                    String[].class, String[].class, String[].class);
        Class<? extends SemanticAnnotationHelper> measurementsHelperClass =
@@ -61,8 +62,7 @@
         new HashSet<String>(Arrays.asList(
             new String[] {
               "b", "i", "li", "ol", "p", "sup", "sub", "u", "ul"})));
-    // index configuration based on the original SAM one but without the
-    // sam-specific classes.
+    // index configuration used for testing.
     return new IndexConfig(
             indexDir,
             "mimir",
@@ -101,14 +101,14 @@
                 new SemanticIndexerConfig(
                         new String[]{"Abstract", "Assignee",
                                 "ClassificationIPCR", "InventionTitle",
-                                "Inventor", "PatentDocument", 
"PriorityClaim"}, 
+                                "Inventor", "Document", "PriorityClaim"}, 
                         new SemanticAnnotationHelper[] {
                                 helperMaker.newInstance("Abstract", new 
String[]{"lang"}, null, null, null, null),                                  
                                 helperMaker.newInstance("Assignee", null, 
null, null, null, null),
                                 helperMaker.newInstance("ClassificationIPCR", 
new String[]{"status"}, null, null, null, null),                                
  
                                 helperMaker.newInstance("InventionTitle", new 
String[]{"lang", "status"}, null, null, null, null),
                                 helperMaker.newInstance("Inventor", new 
String[]{"format", "status"}, null, null, null, null),                          
        
-                                helperMaker.newInstance("PatentDocument", 
null, new String[]{"date"}, null, new String[]{"ucid"}, null),
+                                helperMaker.newInstance("Document", null, new 
String[]{"date"}, null, new String[]{"ucid"}, null).asDocumentHelper(),
                                 helperMaker.newInstance("PriorityClaim", null, 
null, null, new String[]{"ucid"}, null)})                                  
             },
             new DocumentMetadataHelper[] {docHelper}, 

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


------------------------------------------------------------------------------
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World&#153; now supports Android&#153; Apps 
for the BlackBerry&reg; PlayBook&#153;. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to