Package gate.util

Examples of gate.util.GateRuntimeException


    if(a != null && b != null) {
      if(a.getClass().equals(b.getClass())) {
        if(a instanceof Comparable) {
          return ((Comparable)a).compareTo((Comparable)b);
        } else {
          throw new GateRuntimeException(
            "less than or equal comparison but not both are comparable: a="
            +a+",b="+b);
        }
      } else {
          throw new GateRuntimeException(
            "less than or equal comparison but not both of the same class: a="
            +a+",b="+b);
      }
    } else {
          throw new GateRuntimeException(
            "less than or equal comparison but not both different from null: a="
            +a+",b="+b);
    }
  }
View Full Code Here


    File outFile = new File(directoryFile,fileName);
    PrintStream outStream;
    try {
      outStream = new PrintStream(outFile);
    } catch (FileNotFoundException ex) {
      throw new GateRuntimeException("Cannot write to file "+outFile.getAbsoluteFile(),ex);
    }

    // if a contained annotation name is specified, get those anns,
    // sort by offset and then loop through them, otherwise just get
    // all annotations
View Full Code Here

    fireStatusChanged("IndirectLanguageAnalyserPR processing: "
            + getDocument().getName());


    if (!(document instanceof DocumentImpl)) {
      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;
    try {
      newDoc = (Document) Factory.createResource(
              "gate.corpora.DocumentImpl",
              theparms,
              thefeats,
              theName+"_virtual");
    } catch (ResourceInstantiationException ex) {
      throw new GateRuntimeException(ex);
    }

    /* no forward annotation mappig yet ...
    if(annotatedDocumentTransformer.getGenerateForwardOffsetMap()) {
      annotatedDocumentTransformer.addForwardMappedAnnotations(
View Full Code Here

     *
     * @return currentSpecNo - the number of the current annotation.
     */
    public int getSpecNo() {
      if(currentContent == null) {
        throw new GateRuntimeException("Method getSpecNo "+ERRMSG);
      }
      return currentSpecNo;
    }
View Full Code Here

      return currentSpecNo;
    }

    public String getContent() {
      if(currentContent == null) {
        throw new GateRuntimeException("Method getContent "+ERRMSG);
      }
      return currentContent;
    }
View Full Code Here

      return currentContent;
    }

    public Long getOffset() {
      if(currentContent == null) {
        throw new GateRuntimeException("Method getOffset "+ERRMSG);
      }
      return currentOffset;
    }
View Full Code Here

      return nextContent != null;
    }

    public String getSpec() {
      if(currentContent == null) {
        throw new GateRuntimeException("Method getSpec "+ERRMSG);
      }
      return currentSpec;
    }
View Full Code Here

      return currentSpec;
    }

    public Annotation getAnnotation() {
      if(currentContent == null) {
        throw new GateRuntimeException("Method getAnnotation "+ERRMSG);
      }
      return currentAnnotation;
    }
View Full Code Here

    fireStatusChanged("FeatureLanguageAnalyserPR processing: "
            + getDocument().getName());


    if (!(document instanceof DocumentImpl)) {
      throw new GateRuntimeException("Can only handle DocumentImpl not " +
          document.getClass());
    }
   
    // Get the annotations in document order
    AnnotationSet anns =
      document.getAnnotations(inputSpecificationSet).get(inputSpecificationType);
    List<Annotation> annlist = gate.Utils.inDocumentOrder(anns);
    List<AnnotationSpec> annspecs = new LinkedList<AnnotationSpec>();
    StringBuilder newText = new StringBuilder();
    long curoffset = 0;
    // System.err.println("Processing original annotations: "+anns.size());
    for(Annotation ann : annlist) {
      String txt;
      if(inputSpecificationFeature == null) {
        txt = gate.Utils.stringFor(document, ann);
        newText.append(txt);
        annspecs.add(new AnnotationSpec(ann,curoffset,curoffset+txt.length(),ann.getId()));
        curoffset += txt.length();
        newText.append(actualSeparatorString);
        curoffset += actualSeparatorString.length();
      } else {
        txt = (String)ann.getFeatures().get(inputSpecificationFeature);
        if(txt != null) {
          newText.append(txt);
          annspecs.add(new AnnotationSpec(ann,curoffset,curoffset+txt.length(),ann.getId()));
          curoffset += txt.length();
          newText.append(actualSeparatorString);
          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: "+
          annspec.fromOffset+"/"+annspec.toOffset+"/"+newDoc.getContent().size(),ex);
      }
    }
   
View Full Code Here

      //getDocument().setContent(new DocumentContentImpl(newText));

      //System.out.println("Before edit size is "+getDocument().getContent().size());
      document.edit(0L, document.getContent().size(), newContent);
    } catch (InvalidOffsetException ex) {
      throw new GateRuntimeException(ex);
    }

    fireStatusChanged("CreateVirutalDocumentPR completed");
   
  }
View Full Code Here

TOP

Related Classes of gate.util.GateRuntimeException

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.