Revision: 17313
          http://sourceforge.net/p/gate/code/17313
Author:   valyt
Date:     2014-02-15 16:00:06 +0000 (Sat, 15 Feb 2014)
Log Message:
-----------
Some scratch test code used to look for a bug...

Modified Paths:
--------------
    
mimir/trunk/mimir-core/src/gate/mimir/index/OriginalMarkupMetadataHelper.java
    mimir/trunk/mimir-test/.project
    mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java

Modified: 
mimir/trunk/mimir-core/src/gate/mimir/index/OriginalMarkupMetadataHelper.java
===================================================================
--- 
mimir/trunk/mimir-core/src/gate/mimir/index/OriginalMarkupMetadataHelper.java   
    2014-02-15 12:59:04 UTC (rev 17312)
+++ 
mimir/trunk/mimir-core/src/gate/mimir/index/OriginalMarkupMetadataHelper.java   
    2014-02-15 16:00:06 UTC (rev 17313)
@@ -47,8 +47,8 @@
  * document at search time.
  * 
  * The metadata saved by this class is stored in the main document metadata 
map 
- * using this class's name as a key. The value save is itself a Map, with 
- * multiple metadata fields. 
+ * using this class's name as a key. The value saved is a {@link DocumentTags}
+ * instance populated with the tags data.
  */
 public class OriginalMarkupMetadataHelper implements DocumentMetadataHelper, 
     DocumentRenderer {
@@ -137,7 +137,7 @@
               currentHit = (hitIter != null && hitIter.hasNext()) ? 
                       hitIter.next() : null;
             }
-          }else if(currentTag != null && currentTag[1] == tokIdx){
+          } else if(currentTag != null && currentTag[1] == tokIdx) {
             //we only have a TAG to use
             String openingTag = docTags.tagDescriptors.get(currentTag[0]);
             output.append(openingTag);
@@ -151,7 +151,7 @@
             //consume the tag
             currentTag = (tagIter != null && tagIter.hasNext()) ? 
                     tagIter.next() : null;
-          }else{
+          } else {
             //we only have a HIT to use
             output.append(HIT_OPENING_TAG);
             int spanEnd = currentHit.getTermPosition() + 
currentHit.getLength() -1;

Modified: mimir/trunk/mimir-test/.project
===================================================================
--- mimir/trunk/mimir-test/.project     2014-02-15 12:59:04 UTC (rev 17312)
+++ mimir/trunk/mimir-test/.project     2014-02-15 16:00:06 UTC (rev 17313)
@@ -20,5 +20,6 @@
                <nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
                
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+               <nature>org.apache.ivyde.eclipse.ivynature</nature>
        </natures>
 </projectDescription>

Modified: mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java
===================================================================
--- mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java     2014-02-15 
12:59:04 UTC (rev 17312)
+++ mimir/trunk/mimir-test/src/gate/mimir/test/Scratch.java     2014-02-15 
16:00:06 UTC (rev 17313)
@@ -27,18 +27,29 @@
 import java.net.URISyntaxException;
 import java.text.NumberFormat;
 import java.util.Arrays;
+import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.concurrent.Callable;
 
 import org.apache.commons.configuration.ConfigurationException;
 
+import gate.Document;
+import gate.Factory;
 import gate.Gate;
+import gate.Utils;
+import gate.mimir.AbstractSemanticAnnotationHelper;
+import gate.mimir.IndexConfig;
+import gate.mimir.index.OriginalMarkupMetadataHelper;
+import gate.mimir.index.mg4j.GATEDocument;
 import gate.mimir.index.mg4j.MimirDirectIndexBuilder;
+import gate.mimir.index.mg4j.zipcollection.DocumentData;
 import gate.mimir.search.IndexReaderPool;
 import gate.mimir.search.QueryEngine;
 import gate.mimir.search.QueryEngine.IndexType;
 import gate.mimir.search.QueryRunner;
 import gate.mimir.search.RankingQueryRunnerImpl;
 import gate.mimir.search.RemoteQueryRunner;
+import gate.mimir.search.query.Binding;
 import gate.mimir.search.query.QueryExecutor;
 import gate.mimir.search.query.QueryNode;
 import gate.mimir.search.query.parser.QueryParser;
@@ -61,7 +72,8 @@
 public class Scratch {
 
   public static void main (String[] args) throws Exception {
-     mainSimple(args);
+    mainOMMH(args);
+//     mainSimple(args);
 //     mainDirectIndexes(args);
 //    mainBuildDirectIndex(args);
 //    mainQueryIndex(args);
@@ -400,4 +412,42 @@
         nf.format(System.currentTimeMillis() - start) + " ms.");
   }
   
+  
+  public static void mainOMMH(String[] args) throws Exception {
+    Gate.setGateHome(new File("gate-home"));
+    Gate.setUserConfigFile(new File("gate-home/user-gate.xml"));
+    Gate.init();
+    // 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());
+    // load the SPARQL plugin
+    Gate.getCreoleRegister().registerDirectories(
+      new File("../plugins/sparql").toURI().toURL());
+
+    IndexConfig indexConfig = TestUtils.getTestIndexConfig(new File("/tmp"), 
+        Class.forName("gate.mimir.db.DBSemanticAnnotationHelper", true, 
+            Gate.getClassLoader()).asSubclass(
+                AbstractSemanticAnnotationHelper.class));
+    
+    OriginalMarkupMetadataHelper ommh = new OriginalMarkupMetadataHelper( new 
HashSet<String>(Arrays.asList(
+        new String[] {
+            "b", "i", "li", "ol", "p", "sup", "sub", "u", "ul", "br"})));
+    
+    Document doc = Factory.newDocument(new File(args[0]).toURI().toURL());
+    GATEDocument gDoc = new GATEDocument(doc, indexConfig);
+    String[] documentTokens = new String[gDoc.getTokenAnnots().length];
+    for(int i = 0; i < documentTokens.length; i++) {
+      documentTokens[i] = Utils.cleanStringFor(doc, gDoc.getTokenAnnots()[i]);
+    }
+    DocumentData docData = new DocumentData("document URI", "documentTitle", 
+        documentTokens, gDoc.getNonTokens()); 
+    
+    ommh.documentStart(gDoc);
+    ommh.documentEnd(gDoc, docData);
+    
+    ommh.render(docData, new LinkedList<Binding>(), System.out);
+  }
 }

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


------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to