Package org.apache.uima.collection

Examples of org.apache.uima.collection.CollectionException


            }

            return hasAnotherRow;
        } catch (Exception e)
        {
            throw new CollectionException(e);
        }
    }
View Full Code Here


    File currentFile = (File) mFiles.get(mCurrentIndex++);
    FileInputStream inputStream = new FileInputStream(currentFile);
    try {
      XmiCasDeserializer.deserialize(inputStream, aCAS, ! mFailOnUnknownType);
    } catch (SAXException e) {
      throw new CollectionException(e);
    } finally {
      inputStream.close();
    }
  }
View Full Code Here

    }
    generator.setContentHandler(xcasDeser.getXCASHandler(aContainer, ootsd));
    try {
      generator.generateXCas(aData);
    } catch (Exception e) {
      throw new CollectionException(e);
    }
  }
View Full Code Here

public void getNext(CAS aCAS) throws IOException, CollectionException {
  JCas jCas;
  try {
    jCas = aCAS.getJCas();
  } catch(CASException e){
    throw new CollectionException(e);
  }
 
  NegExAnnotation a = list.get(i);
  i++;
View Full Code Here

public boolean hasNext() throws IOException, CollectionException {

  try {
    return i < list.size();
  } catch (Exception e) { // list == null for example
    throw new CollectionException(e);
  }
     
}
View Full Code Here

    File currentFile = (File) mFiles.get(mCurrentIndex++);
    FileInputStream inputStream = new FileInputStream(currentFile);
    try {
      XmiCasDeserializer.deserialize(inputStream, aCAS, ! mFailOnUnknownType);
    } catch (SAXException e) {
      throw new CollectionException(e);
    } finally {
      inputStream.close();
    }
  }
View Full Code Here

  public void getNext(CAS aCAS) throws IOException, CollectionException {
    JCas jcas;
    try {
      jcas = aCAS.getJCas();
    } catch (CASException e) {
      throw new CollectionException(e);
    }

    // open input stream to file
    File file = (File) mFiles.get(mCurrentIndex++);
    String text = FileUtils.file2String(file, mEncoding);
View Full Code Here

    Scanner scanner = null;
    JCas jcas;
    try{
      jcas = aCAS.getJCas();
    }catch(CASException e){
      throw new CollectionException(e);
    }
    HashMap<Point,Integer> word2char = new HashMap<Point, Integer>();
//    HashSet<String> negSet = new HashSet<String>();
//    HashSet<String> hypothSet = new HashSet<String>();
//    HashSet<String> possSet = new HashSet<String>();
View Full Code Here

          }
        }
       
        int delimeterLoc = line.indexOf(iv_delimeter);
        if(delimeterLoc <= 0)
          throw new CollectionException(new Exception("Line in file number "+lineNumber+" is not well formatted.  " +
              "\nIt should have the format:" +
              "\n<doc_id>"+iv_delimeter+"<doc_text>"));
        id = line.substring(0,delimeterLoc);
        if (foundLine) {
          if (numberOfColumns.intValue() > 0 && iv_delimeter != null
              && iv_delimeter != "") {

            text = delimitedColumns[numberOfColumns.intValue() - 1];
          } else
            text = line.substring(delimeterLoc
                + iv_delimeter.length());
        } else {
            id = line.substring(0,delimeterLoc);
            text = "";
        }
      }
        else
        {
          id = Integer.toString(lineNumber); //id will one more than its index into iv_linesFromFile (iv_currentIndex has already been incremented)
          text = line;
        }
       

        iv_logger.debug("id="+id);
        iv_logger.debug("text="+text);
       
      //if there's a CAS Initializer, call it 
      if (getCasInitializer() != null)
      {
        Reader reader = new StringReader(text);
        getCasInitializer().initializeCas(reader, cas);
        reader.close();
      }
      else  //No CAS Initiliazer, so read file and set document text ourselves
      {       
        jcas.setDocumentText(text);
      }
      
        //set language if it was explicitly specified as a configuration parameter
        if (iv_language != null)
        {
          ((DocumentAnnotation)jcas.getDocumentAnnotationFs()).setLanguage(iv_language);
        }
       
       
        DocumentID documentIDAnnotation = new DocumentID(jcas);
        documentIDAnnotation.setDocumentID(id);
        documentIDAnnotation.addToIndexes();

      }
      catch (ArrayIndexOutOfBoundsException aioobe) {
        iv_logger.log(Level.ERROR, "Radiology input file corrupt or some record row contents are not valid.");
        throw new CollectionException(aioobe);
      }
      catch (CASException e)
      {
        throw new CollectionException(e);
      }
      finally
      {
        iv_currentIndex++;
      }
View Full Code Here

          if(split == token.length()-1) {
            split = token.substring(0, token.length()-1).lastIndexOf("_");
          }
          if (split == -1) {
            line = null;
            throw new CollectionException("There is a problem in your training data: " + token
                + " does not conform to the format WORD_TAG.", null);
          }
          String word = token.substring(0, split);
          wordEnd = wordStart + word.length();
          // Consider creating a token similar to the way
          // TokenConverter.convert method creates BaseToken's
          BaseToken baseToken = new BaseToken(jCas, wordStart, wordEnd);
          if (!loadWordsOnly) {
            String tag = token.substring(split + 1);
            baseToken.setPartOfSpeech(tag);
          }
          baseToken.setTokenNumber(wordNumber++);
          baseToken.addToIndexes();

          documentText.append(word + " ");
          wordStart = wordEnd + 1;
        }
        Sentence sentence = new Sentence(jCas, 0, wordEnd);
        sentence.setSentenceNumber(0);
        sentence.addToIndexes();
        jCas.setDocumentText(documentText.toString());
      }
    } catch (CASException ce) {
      throw new CollectionException(ce);
    }
    line = null;
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.collection.CollectionException

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.