Examples of FeatureMap


Examples of gate.FeatureMap

  }
 
  @Test
  public void testTrie2() {
    GazStore gs = new GazStoreTrie2();
    FeatureMap fm = Factory.newFeatureMap();
    fm.put("listFeature1","value1");
    fm.put("listFeature2","value2");
    int info1 = gs.addListInfo("Type1", "URL1", fm);
    String[] keyvals1 = new String[]{"key1","val1","key2","","k3","valuenumberthree"};
    /*
    State st1 = gs.addLookupOld("asdf", info1, keyvals1);
    Iterator<Lookup> it1 = gs.getLookups(st1);
View Full Code Here

Examples of gate.FeatureMap

    List<FeatureMap> fms = new ArrayList<FeatureMap>();
    if(lookups == null) {
      return fms;
    }
    while(lookups.hasNext()) {
      FeatureMap fm = Factory.newFeatureMap();
      Lookup currentLookup = lookups.next();
      gazStore.addLookupListFeatures(fm, currentLookup);
      fm.put("_listnr",gazStore.getListInfoIndex(currentLookup));
      gazStore.addLookupEntryFeatures(fm, currentLookup);
      fms.add(fm);
    }
    return fms;
  }
View Full Code Here

Examples of gate.FeatureMap

    */
  }
  @Test
  public void testTrie3() {
    GazStoreTrie3 gs = new GazStoreTrie3();
    FeatureMap fm = Factory.newFeatureMap();
    fm.put("listFeature1","value1");
    fm.put("listFeature2","value2");
    int info1 = gs.addListInfo("Type1", "URL1", fm);
    String[] keyvals1 = new String[]{"key1","val1","key2","","k3","valuenumberthree"};
   
    gs.addLookup("asdf", info1, keyvals1);
    gs.addLookup("asdf", info1, keyvals1);
View Full Code Here

Examples of gate.FeatureMap

      throws MalformedURLException, ResourceInstantiationException, ExecutionException {
    do_testGazetteerApplication1(3);
  }
  public void do_testGazetteerApplication1(int backendNr) throws MalformedURLException, ResourceInstantiationException, ExecutionException {
    System.out.println("Running gazetteer application test 1 for backend "+backendNr);
    FeatureMap parms = Factory.newFeatureMap();
    File defFile = new File(testingDir,"extgaz2.def");
    URL gazURL = defFile.toURI().toURL();
    parms.put("configFileURL", gazURL);
    parms.put("backendNr",backendNr);
    ExtendedGazetteer2 eg = (ExtendedGazetteer2)Factory.createResource(
            "com.jpetrak.gate.stringannotation.extendedgazetteer2.ExtendedGazetteer2", parms);
    // load the document
    parms = Factory.newFeatureMap();
    File docFile = new File(testingDir,"extgaz2docprep.xml");
    parms.put("sourceUrl",docFile.toURI().toURL());
    Document doc = (Document)
         Factory.createResource("gate.corpora.DocumentImpl", parms);
    AnnotationSet lookups = doc.getAnnotations().get("OutType");
    assertEquals(0,lookups.size());
    // run the gazetteer on the document
    eg.setDocument(doc);
    eg.execute();
    // check if we got the correct annotations
    AnnotationSet tokens = doc.getAnnotations().get("Token");
    assertEquals(46,tokens.size());
    AnnotationSet sentences = doc.getAnnotations().get("Sentence");
    assertEquals(4,sentences.size());
    lookups = doc.getAnnotations().get("OutType");
    if(backendNr == 3) {
      assertEquals(12,lookups.size());
    } else {
      assertEquals(14,lookups.size());
    }
    int i = 1;
    FeatureMap fm;
    long from;
    long to;
    for(Annotation ann : gate.Utils.inDocumentOrder(lookups)) {
      //System.out.println("Annotation: "+ann);
      fm = ann.getFeatures();
      String inst = (String)fm.get("inst");
      String string = (String)fm.get("_string");
      from = ann.getStartNode().getOffset();
      to = ann.getEndNode().getOffset();
      if(i == 1) {
        assertEquals(8,from);
        assertEquals(12,to);
View Full Code Here

Examples of gate.FeatureMap

  }
 
  public void do_testGazetteerApplication2(int backendNr)
      throws ResourceInstantiationException, ExecutionException, IOException {
    System.out.println("Running gazetteer application test 2 for news1pre for backend "+backendNr);
    FeatureMap parms = Factory.newFeatureMap();
    File defFile = new File(testingDir,"annie/lists.def");
    URL gazURL = defFile.toURI().toURL();
    parms.put("configFileURL", gazURL);
    parms.put("backendNr",backendNr);
    ExtendedGazetteer2 eg = (ExtendedGazetteer2)Factory.createResource(
            "com.jpetrak.gate.stringannotation.extendedgazetteer2.ExtendedGazetteer2", parms);
    // load the document
    eg.setOutputAnnotationSet("EXT");
    parms = Factory.newFeatureMap();
    File docFile = new File(testingDir,"news1pre.xml");
    parms.put("sourceUrl",docFile.toURI().toURL());
    Document doc = (Document)
         Factory.createResource("gate.corpora.DocumentImpl", parms);
    AnnotationSet lookups = doc.getAnnotations("EXT").get("Lookup");
    assertEquals(0,lookups.size());
    // run the gazetteer on the document
View Full Code Here

Examples of gate.FeatureMap

  @Test
  public void testFeatureGazetteer1() throws MalformedURLException, ResourceInstantiationException, ExecutionException {
    int backendNr = 3;
    System.out.println("Running FEATURE GAZETTEER application test for backend "+backendNr);
    FeatureMap parms = Factory.newFeatureMap();
    File defFile = new File(testingDir,"extgaz2.def");
    URL gazURL = defFile.toURI().toURL();
    parms.put("configFileURL", gazURL);
    parms.put("backendNr",backendNr);
    FeatureGazetteer eg = (FeatureGazetteer)Factory.createResource(
            "com.jpetrak.gate.stringannotation.extendedgazetteer2.FeatureGazetteer", parms);
    // test matching directly
    Iterator<Lookup> ret = null;
    ret = eg.doMatch("some", true,true);
    System.out.println("Matching same: "+ret);
    // check that it works with a gazetteer list that does not have any features
    defFile = new File(testingDir,"extgaz3.def");
    gazURL = defFile.toURI().toURL();
    parms.put("configFileURL", gazURL);
    eg = (FeatureGazetteer)Factory.createResource(
        "com.jpetrak.gate.stringannotation.extendedgazetteer2.FeatureGazetteer", parms);
    ret = eg.doMatch("word", true,true);
    System.out.println("Matching extgaz3 'word': "+eg.lookups2FeatureMaps(ret));
    ret = eg.doMatch("word", false,false);
View Full Code Here

Examples of gate.FeatureMap

  @Test
  public void testGazStoreTrie3() throws IOException {
    System.out.println("GazStoreTrie3: *******************************");
    GazStoreTrie3 gs = new GazStoreTrie3();
    FeatureMap fm1 = Factory.newFeatureMap();
    fm1.put("feature1","value1");
    int info1 = gs.addListInfo("Type1", "TheFile", fm1);
    String[] kv1 = new String[2];
    kv1[0] = "key1of1";
    kv1[1] = "value1of1";
    gs.addLookup("entry", info1, kv1);
View Full Code Here

Examples of gate.FeatureMap

 
  @Override
  public void addLookupListFeatures(FeatureMap fm, Lookup lookup) {
    OurLookup l = (OurLookup)lookup;
    int lookupIndex = getListInfoFromChunk(l.chunk);
    FeatureMap lfm = listInfos.get(lookupIndex).getFeatures();
    fm.putAll(lfm);
  }
View Full Code Here

Examples of gate.FeatureMap

    System.out.println("key2 added, index is "+i2);
   
    String[] keyvals1 = new String[]{"k1","v1","k2", "value2", "keynumber3", "v3", "k4", ""};
    char[] chunk1 = lookup2chunk(0,keyvals1);
   
    FeatureMap fm = gate.Factory.newFeatureMap();
    addToFmFromChunk(fm,chunk1);
    System.out.println("FeatureMap is "+fm);
    assertEquals("v1",(String)fm.get("k1"));
    assertEquals("value2",(String)fm.get("k2"));
    assertEquals("",(String)fm.get("k4"));
   
    String[] keyvals2 = new String[]{"k1","nother","k2","asasassa","k3","xxxxx"};
    char[] chunk2 = lookup2chunk(0,keyvals2);
    FeatureMap fm2 = gate.Factory.newFeatureMap();
    addToFmFromChunk(fm2,chunk2);
    assertEquals("nother",(String)fm2.get("k1"));
    assertEquals("asasassa",(String)fm2.get("k2"));
    assertEquals(null,fm2.get("k4"));
    assertEquals("xxxxx",(String)fm2.get("k3"));
   
    int si1 = addLookupToStore(-1,12,keyvals1);
    addLookupToStore(si1,23,keyvals2);
   
    int si2 = addLookupToStore(-1,12,keyvals1);
View Full Code Here

Examples of gate.FeatureMap

        }

        Long sPos = offset;
        Long ePos = offset + line.length();
        if (line.length() > 0 && line.trim().length() > 0) {
          FeatureMap features = Factory.newFeatureMap();
           document.getAnnotations(getInputAS()).add(sPos, ePos, getInputAnnotationType(), features);
          if (debugging) {
            System.out.println("Adding sentence:\n\t at (" + sPos
                + ", " + ePos + ")");
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.