Package org.apache.uima.ducc

Examples of org.apache.uima.ducc.Workitem


   */
  public void getNext(CAS aCAS) throws IOException, CollectionException {
    JCas jcas;
    try {
      jcas = aCAS.getJCas();
      Workitem wi = new Workitem(jcas);
      wi.setInputspec(mWorkList.get(mCurrentIndex).filename);
      wi.setOutputspec(mWorkList.get(mCurrentIndex).outname);
      wi.setBlockindex(mWorkList.get(mCurrentIndex).index);
      wi.setBlocksize(mBlocksize);
      wi.setBytelength(mWorkList.get(mCurrentIndex).length);
      if (null != mEncoding) {
        wi.setEncoding(mEncoding);
      }
      if (null != mLanguage) {
        wi.setLanguage(mLanguage);
      }
      wi.setSendToLast(mSendToLast);
      wi.setSendToAll(mSendToAll);
      wi.addToIndexes();
      wi.setLastBlock(mWorkList.get(mCurrentIndex).last);
      logger.log(Level.INFO, "Sending "+wi.getInputspec()+" index="+wi.getBlockindex()+" last="+wi.getLastBlock()+" length="+wi.getBytelength());
      mCurrentIndex++;
      jcas.setDocumentText(wi.getInputspec()+" index="+wi.getBlockindex()+" length="+wi.getBytelength());
    } catch (CASException e) {
      throw new CollectionException(e);
    }

    //create WorkItem info structure
View Full Code Here


        Iterator<TOP> fsIter = null;
        if (this.getJCas().getTypeSystem().getType(Workitem.class.getName()) != null) {
          fsIter = this.getJCas().getJFSIndexRepository().getAllIndexedFS(Workitem.type);
        }
        if (fsIter != null && fsIter.hasNext()) {
          Workitem wi = (Workitem) fsIter.next();
          if (fsIter.hasNext()) {
            throw new IllegalStateException("More than one instance of Workitem type");
          }
          if (wi.getSendToAll()) {
          // send WI-CAS to all delegates
          }
          else if (wi.getSendToLast()) {
          // send to last delegate only
          currentStep = mSequence.size() - 1;
          }
        }
        // No Workitem FS in CAS, WI-CAS is at end of flow
View Full Code Here

   */
  public void getNext(CAS aCAS) throws IOException, CollectionException {
    JCas jcas;
    try {
      jcas = aCAS.getJCas();
      Workitem wi = new Workitem(jcas);
      wi.setInputspec(mWorkList.get(mCurrentIndex).filename);
      wi.setOutputspec(mWorkList.get(mCurrentIndex).outname);
      wi.setSendToLast(mSendToLast);
      wi.setSendToAll(mSendToAll);
      wi.addToIndexes();
      logger.log(Level.INFO, "Sending "+wi.getInputspec());
      mCurrentIndex++;
      jcas.setDocumentText(wi.getInputspec());
    } catch (CASException e) {
      throw new CollectionException(e);
    }

    //create WorkItem info structure
View Full Code Here

  }

  public void process(JCas jcas) throws AnalysisEngineProcessException {
    Iterator<FeatureStructure> fsit = jcas.getIndexRepository().getAllIndexedFS(jcas.getCasType(Workitem.type));
    if (fsit.hasNext()) {
      Workitem wi = (Workitem) fsit.next();
      if (outputFilename == null || !outputFilename.equals(wi.getOutputspec())) {
        // this Work Item contained no documents. Create empty output file.
        try {
        outFile = new File(wi.getOutputspec());
            File outDir = outFile.getParentFile();
            if (outDir != null && !outDir.exists()) {
              outDir.mkdirs();
            }
            zos = new ZipOutputStream(new FileOutputStream(outFile));
        zos.close();
        logger.log(Level.INFO, "DuccCasCC: Flushed empty "+wi.getOutputspec());
        return;
    } catch (Exception e) {
          throw new AnalysisEngineProcessException(e);
    }
      }
      try {
    zos.close();
    fos.close();
    if (!outFile.renameTo(new File(outputFilename))) {
      throw new IOException("Rename failed for "+outputFilename);
    }
  } catch (IOException e) {
    throw new AnalysisEngineProcessException(e);
  }
      logger.log(Level.INFO, "DuccCasCC: Flushed "+wi.getOutputspec());
      return;
    }

    fsit = jcas.getIndexRepository().getAllIndexedFS(jcas.getCasType(DuccDocumentInfo.type));
    if (!fsit.hasNext()) {
View Full Code Here

TOP

Related Classes of org.apache.uima.ducc.Workitem

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.