Package gate

Examples of gate.FeatureMap


            // System.out.println("No feature found, ignoring");
            continue;
          }
          // Make a feature map that contains the feature=value constraint
          // which is needed to check the other elements of the chain.
          FeatureMap constraint = Factory.newFeatureMap();
          constraint.put(feature, val);
          List<Annotation> chain = new ArrayList<Annotation>();
          // add the candidate head to this chain candidate
          chain.add(ann);
          int chainlength = 0;
          // curann is the annotation we process in a loop to find
View Full Code Here


   * @param name
   * @return
   */
  public static Object getParmValue(ActionContext ctx, String name) {
    if(ctx instanceof ExtendedActionContext) {
      FeatureMap fm = ((ExtendedActionContext)ctx).getParameters();
      if(fm != null) {
        return fm.get(name);
      } else {
        return null;
      }
    } else {
      throw new GateRuntimeException("ActionContext is not an ExtendedActionContext");
View Full Code Here

        continue;
      }
      logger.debug("Got annotation: "+ann);
      int specNo = it.getSpecNo();
      String spec = sourceSpecificationsVector.get(it.getSpecNo());
      FeatureMap fm = Factory.newFeatureMap();
      fm.putAll(ann.getFeatures());
      fm.put("annID",ann.getId());
      fm.put("annSet", inputAnnotationSetName);
      String content = it.getContent();
      fm.put("content", content);
      fm.put("specNo",specNo+"");
      fm.put("spec", spec);
      os.add(ann.getStartNode(),ann.getEndNode(),outputAnnotationTypeName,fm);
    }
    fireStatusChanged("AnnotatedBySpecPR completed");

  }
View Full Code Here

      throw new GateRuntimeException("Can only handle DocumentImpl not " +
          document.getClass());
    }
    String newText = annotatedDocumentTransformer.getStringForDocument(
            getDocument(), inputAnnotationSetName);
    FeatureMap theparms = Factory.newFeatureMap();
    theparms.put("collectRepositioningInfo", document.getCollectRepositioningInfo());
    theparms.put("encoding", ((DocumentImpl) document).getEncoding());
    theparms.put("markupAware", document.getMarkupAware());
    theparms.put("mimeType", ((DocumentImpl) document).getMimeType());
    theparms.put("preserveOriginalContent", document.getPreserveOriginalContent());
    theparms.put("stringContent", newText);
    FeatureMap thefeats = Factory.newFeatureMap();
    FeatureMap docfeats = document.getFeatures();
    thefeats.putAll(docfeats);

    String theName = document.getName();
    // create a copy of the current document
    Document newDoc;
View Full Code Here

          curoffset += actualSeparatorString.length();
        }
      }
    }
   
    FeatureMap theparms = Factory.newFeatureMap();
    theparms.put("collectRepositioningInfo", document.getCollectRepositioningInfo());
    theparms.put("encoding", ((DocumentImpl) document).getEncoding());
    theparms.put("markupAware", document.getMarkupAware());
    theparms.put("mimeType", ((DocumentImpl) document).getMimeType());
    theparms.put("preserveOriginalContent", document.getPreserveOriginalContent());
    theparms.put("stringContent", newText.toString());
    FeatureMap thefeats = Factory.newFeatureMap();
    FeatureMap docfeats = document.getFeatures();
    thefeats.putAll(docfeats);

    String theName = document.getName();
    // create a copy of the current document
    Document newDoc;
    try {
      newDoc = (Document) Factory.createResource(
              "gate.corpora.DocumentImpl",
              theparms,
              thefeats,
              theName+"_virtual");
    } catch (ResourceInstantiationException ex) {
      throw new GateRuntimeException(ex);
    }

    // set the initial annotations in the virtual document
    AnnotationSet newSet = newDoc.getAnnotations(virtualSpecificationSet);
    for(AnnotationSpec annspec : annspecs) {
      FeatureMap fm = Factory.newFeatureMap();
      fm.putAll(annspec.annotation.getFeatures());
      fm.put("orig_id",annspec.origId);     
      try {
        newSet.add(annspec.fromOffset, annspec.toOffset, virtualSpecificationType, fm);
      } catch(InvalidOffsetException ex) {
        throw new GateRuntimeException(
          "Invalid offset when creating annotation for virtual document: from/to/doclength: "+
View Full Code Here

      if (!(document instanceof DocumentImpl)) {
        throw new GateRuntimeException("Can only handle DocumentImpl not " + document.getClass());
      }
      String theclass = document.getClass().toString();
      FeatureMap theparms = Factory.newFeatureMap();
      theparms.put("collectRepositioningInfo", document.getCollectRepositioningInfo());
      theparms.put("encoding", ((DocumentImpl) document).getEncoding());
      theparms.put("markupAware", document.getMarkupAware());
      theparms.put("mimeType", ((DocumentImpl)document).getMimeType());
      theparms.put("preserveOriginalContent", document.getPreserveOriginalContent());
      theparms.put("stringContent", newText);
      FeatureMap thefeats = Factory.newFeatureMap();
      FeatureMap docfeats = document.getFeatures();
      for(Object k : docfeats.keySet()) {
        thefeats.put(k, docfeats.get(k));
      }

      String theName = document.getName();
      // create a copy of the current document
      Document newDoc;
View Full Code Here

        jTextFieldAuthor.addFocusListener(this);
        jTextFieldVersion.setName("version");
        jTextFieldVersion.addFocusListener(this);
        jTextAreaComment.setName("comment");
        jTextAreaComment.addFocusListener(this);
        FeatureMap fm = owner.theTarget.getFeatures();
        //System.out.println("Feature map is "+fm);
        String comment = getFMValue("@comment");
        if(comment == null) {
          comment = "";
        }
View Full Code Here

        System.err.println("Could not register plugin") ;
        ex.printStackTrace(System.err);
        System.exit(1);
      }
     
      FeatureMap parms = Factory.newFeatureMap();
      parms.put("configFileURL", url);
      parms.put("caseSensitive", caseSensitive);
      parms.put("caseConversionLanguage", locale);
      parms.put("gazetteerFeatureSeparator","\\t");
      try {
        gate.ProcessingResource pr =
          (gate.ProcessingResource) Factory.createResource(
                "com.jpetrak.gate.stringannotation.extendedgazetteer2.ExtendedGazetteer2",
                parms);
View Full Code Here

 
  @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

    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);
    int idx = addLookupToStore(si1,23,keyvals2);
    System.out.println("Index for keyvals2: "+idx);
    idx = addLookupToStore(si1,23,keyvals2);
View Full Code Here

TOP

Related Classes of gate.FeatureMap

Copyright © 2018 www.massapicom. 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.