当前位置: 首页>>代码示例>>Java>>正文


Java CASRuntimeException类代码示例

本文整理汇总了Java中org.apache.uima.cas.CASRuntimeException的典型用法代码示例。如果您正苦于以下问题:Java CASRuntimeException类的具体用法?Java CASRuntimeException怎么用?Java CASRuntimeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CASRuntimeException类属于org.apache.uima.cas包,在下文中一共展示了CASRuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
@Test
public void test() throws CASRuntimeException, UIMAException, IOException {
    SimplePipeline.runPipeline(reader, tokenizerSentenceSplitter,
            unitAnnotator, unitClassifier, unitsDAOWriter);
    Set<String> searchedStrings = Sets.newHashSet(
            "65801.txt\t545\t549\t1\tru.kfu.itis.issst.evex.Organization",
            "62007.txt\t1044\t1048\t1\tru.kfu.itis.issst.evex.Person",
            "62007.txt\t1044\t1048\t5\tru.kfu.itis.issst.evex.Person",
            "65801.txt\t0\t3\t1\tnull");
    int founded = 0;
    BufferedReader inputStream = null;
    try {
        inputStream = new BufferedReader(new FileReader(unitsTSV));
        String l;
        while ((l = inputStream.readLine()) != null) {
            if (searchedStrings.contains(l)) {
                ++founded;
            }
        }
    } finally {
        closeQuietly(inputStream);
    }
    assertEquals(searchedStrings.size(), founded);

}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:26,代码来源:UnitsDAOWriterTest.java

示例2: writeTypeSystem

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException
{
    @SuppressWarnings("resource")
    OutputStream typeOS = null;

    try {
        if (typeSystemFile != null) {
            typeOS = CompressionUtils.getOutputStream(typeSystemFile);
        }
        else {
            typeOS = getOutputStream("TypeSystem", ".xml");
        }

        TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS);
    }
    finally {
        closeQuietly(typeOS);
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:JsonWriter.java

示例3: writeTypeSystem

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
private void writeTypeSystem(JCas aJCas)
    throws IOException, CASRuntimeException, SAXException
{
    @SuppressWarnings("resource")
    OutputStream typeOS = null;

    try {
        if (typeSystemFile != null) {
            typeOS = CompressionUtils.getOutputStream(typeSystemFile);
        }
        else {
            typeOS = getOutputStream("typesystem", ".xml");
        }

        TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS);
    }
    finally {
        closeQuietly(typeOS);
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:21,代码来源:XmiWriter.java

示例4: getArtifactViewName

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
/**
 * Get the name part of the uri stored in the source documentation of the annotation index of the current view
 * @param aJCas
 * @return
 * @throws CASRuntimeException
 * @throws AnalysisEngineProcessException
 */
public static String getArtifactViewName(JCas aJCas) throws CASRuntimeException, AnalysisEngineProcessException  {
	FSIterator<Annotation> sourceDocumentInformationFSIterator = aJCas.getAnnotationIndex(JCasSofaViewUtils.getJCasType(aJCas,
			DEFAULT_SOURCE_DOCUMENT_INFORMATION_ANNOTATION)).iterator();
	String outFileName = "";
	File inFile = null;
	if (sourceDocumentInformationFSIterator.hasNext()) {
		SourceDocumentInformation theSourceDocumentInformation = (SourceDocumentInformation) sourceDocumentInformationFSIterator.next();

		try {
			inFile = new File(new URL(theSourceDocumentInformation.getUri()).getPath());
			outFileName = inFile.getName();
			if (theSourceDocumentInformation.getOffsetInSource() > 0) {
				outFileName += ("-" + theSourceDocumentInformation.getOffsetInSource());
			}
			//outFile = new File(outputDirForCSV, outFileName);
			//System.out.println("Debug: outputDirForCSV "+ outputDirForCSVString+ " outFileName "+outFileName);  	

		} catch (MalformedURLException e) {
			// invalid URL, use default processing below
			e.printStackTrace();
		}
	}
	return outFileName;
}
 
开发者ID:EUMSSI,项目名称:EUMSSI-tools,代码行数:32,代码来源:JCasSofaViewUtils.java

示例5: getTheArtifactName

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
/**
 * Get the name of the artifact whatever it appears in any annotation index of associated view
 * @param aJCas
 * @return
 * @throws AnalysisEngineProcessException 
 * @throws CASRuntimeException 
 */
public static String getTheArtifactName(JCas aJCas) throws CASRuntimeException, AnalysisEngineProcessException {
	String artifactName = "";
	try {
		Iterator<JCas>	jCasViewIter =  aJCas.getViewIterator();

		while (jCasViewIter.hasNext()) {
			JCas aJCasView = jCasViewIter.next();
			String currentArtifactViewName = getArtifactViewName(aJCasView);
			//System.out.println("Debug: one view of the current JCas >"+aJCasView.getViewName()+"< and the artifact name is >"+currentArtifactViewName+"<");

			if (currentArtifactViewName != null) 
				if (!currentArtifactViewName.equalsIgnoreCase("")) artifactName = currentArtifactViewName;

		}
	} catch (CASException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	} 

	return artifactName;
}
 
开发者ID:EUMSSI,项目名称:EUMSSI-tools,代码行数:29,代码来源:JCasSofaViewUtils.java

示例6: getTheArtifactName

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
/**
	 * Get the name of the artifact whatever it appears in any annotation index of associated view
	 * @param aJCas
	 * @return
	 * @throws AnalysisEngineProcessException 
	 * @throws CASRuntimeException 
	 */
  public static String getTheArtifactName(JCas aJCas)
    throws CASRuntimeException, AnalysisEngineProcessException
  {
/* 217 */     String artifactName = "";
    try {
/* 219 */       Iterator<JCas> jCasViewIter = aJCas.getViewIterator();
      
/* 221 */       while (jCasViewIter.hasNext()) {
/* 222 */         JCas aJCasView = (JCas)jCasViewIter.next();
/* 223 */         String currentArtifactViewName = getArtifactViewName(aJCasView);
        

/* 226 */         if ((currentArtifactViewName != null) && 
/* 227 */           (!currentArtifactViewName.equalsIgnoreCase(""))) artifactName = currentArtifactViewName;
      }
    }
    catch (CASException e1)
    {
/* 232 */       e1.printStackTrace();
    }
    
/* 235 */     return artifactName;
  }
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:31,代码来源:JCasUtils.java

示例7: getAnArtifactName

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
/**
	 * Get the name of the artifact whatever it appears in any annotation index of associated view
	 * or create one specifying prefix and suffix elements
	 * @param aJCas
	 * @return
	 * @throws AnalysisEngineProcessException 
	 * @throws CASRuntimeException 
	 */
	public static String getAnArtifactName(JCas aJCas, Boolean removeExtension, String prefix, String suffix) throws CASRuntimeException, AnalysisEngineProcessException {

		String artifactName = getTheArtifactName(aJCas) ;
		
		if (artifactName != null) {
			//System.out.println("Debug: SourceDocumentInformation is present in this view");
			if (!artifactName.equalsIgnoreCase("")) {
				int lastIndex = artifactName.lastIndexOf(".");
				artifactName = artifactName.substring(0, lastIndex);
			}
			else {System.err.println("Error: an artifact name not null but empty ; in that case should create A name");}
		}

		//if (artefactName == null) 
		else {
			//System.out.println("Debug: SourceDocumentInformation is not present in this view");

			byte[] hash      = null;
			try {
				hash= MessageDigest.getInstance("MD5").digest(aJCas.getSofaDataString().getBytes());
			} catch (NoSuchAlgorithmException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			//outFileName = defaultDocumentPrefix + hash;

			//cal = new GregorianCalendar(); // donne l'heure a l'instant t + x, l'heure systeme ayant change 
			//int milliseconde = cal.get(Calendar.MILLISECOND); // de 0 a 999 
//System.nanoTime() + '-' +
			artifactName = "" + System.nanoTime() + '-' + hash ;
			//artefactName = defaultDocumentPrefix + System.nanoTime() + '_' + hash;
			//inFile = new File(outputDirForCSV, DEFAULT_DOCUMENT_PREFIX + hash );   
			//System.out.println("Debug: outputDirForCSV "+ outputDirForCSVString+ " outFileName "+DEFAULT_DOCUMENT_PREFIX + hash + DEFAULT_CSV_EXTENSION);  	
		}
		
		artifactName = prefix + artifactName + suffix;

		return artifactName;
	}
 
开发者ID:EUMSSI,项目名称:EUMSSI-tools,代码行数:48,代码来源:JCasSofaViewUtils.java

示例8: serialize

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
public static void serialize(JCas jCas, File file)
        throws FileNotFoundException, IOException, CASRuntimeException,
        ResourceInitializationException {
    OutputStream os = new GZIPOutputStream(new FileOutputStream(file));
    writeTypeSystem(jCas, os);
    serializeWithCompression(jCas.getCas(), os, jCas.getTypeSystem());
    os.close();
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:9,代码来源:BinaryCasWriter.java

示例9: getArtifactViewName

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
/**
	 * Get the name part of the uri stored in the source documentation of the annotation index of the current view
	 * @param aJCas
	 * @return
	 * @throws CASRuntimeException
	 * @throws AnalysisEngineProcessException
	 */
  public static String getArtifactViewName(JCas aJCas)
    throws CASRuntimeException, AnalysisEngineProcessException
  {
/* 174 */     FSIterator<Annotation> sourceDocumentInformationFSIterator = aJCas.getAnnotationIndex(getJCasType(aJCas, 
/* 175 */       DEFAULT_SOURCE_DOCUMENT_INFORMATION_ANNOTATION)).iterator();
/* 176 */     String outFileName = "";
/* 177 */     File inFile = null;
/* 178 */     if (sourceDocumentInformationFSIterator.hasNext()) {
/* 179 */       SourceDocumentInformation theSourceDocumentInformation = (SourceDocumentInformation)sourceDocumentInformationFSIterator.next();
      try
      {
/* 182 */         inFile = new File(new URL(theSourceDocumentInformation.getUri()).getPath());
/* 183 */         outFileName = inFile.getName();
/* 184 */         if (theSourceDocumentInformation.getOffsetInSource() > 0) {
/* 185 */           outFileName = outFileName + "-" + theSourceDocumentInformation.getOffsetInSource();
        }
        

      }
      catch (MalformedURLException e)
      {
/* 192 */         e.printStackTrace();
      }
    }
/* 195 */     return outFileName;
  }
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:34,代码来源:JCasUtils.java

示例10: getOrCreateView

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
/**
 * Gets the named view; if the view doesn't exist it will be created.
 */
private static CAS getOrCreateView(CAS aCas, String aViewName) {
	// TODO: there should be some way to do this without the try...catch
	try {
		return aCas.getView(aViewName);
	} catch (CASRuntimeException e) {
		// create the view
		return aCas.createView(aViewName);
	}
}
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:13,代码来源:ViewMapperAE.java

示例11: getOrCreateView

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
/**
 * Gets the named view; if the view doesn't exist it will be created.
 */
private static CAS getOrCreateView(CAS aCas, String aViewName) {
	//TODO: there should be some way to do this without the try...catch
	try {
		return aCas.getView(aViewName); 
	}
	catch(CASRuntimeException e) {
		//create the view
		return aCas.createView(aViewName); 
	}
}
 
开发者ID:nicolashernandez,项目名称:dev-star,代码行数:14,代码来源:BrancheViewRenamerAE.java

示例12: consumeTypeIdHits

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void consumeTypeIdHits( final JCas jcas, final String codingScheme, final int cTakesSemantic,
                               final CollectionMap<TextSpan, Long, ? extends Collection<Long>> textSpanCuis,
                               final CollectionMap<Long, Concept, ? extends Collection<Concept>> cuiConcepts )
      throws AnalysisEngineProcessException {
  List<IdentifiedAnnotation> toRemove = new ArrayList<>();

  // Find the spans associated with de-id strings:
  String docText = jcas.getDocumentText();
  for(String phiString : phiArray){
      int searchInd=0;
      int startInd=0;
      int endInd;
      while((startInd = docText.indexOf(phiString, searchInd)) >= 0){
          endInd = startInd + phiString.length();
          for(IdentifiedAnnotation covered : JCasUtil.selectCovered(jcas, IdentifiedAnnotation.class, startInd, endInd)){
              toRemove.add(covered);
          }
          searchInd = startInd+1;
          //System.err.println("Found phi string " + phiString + " at index: " + startInd + " to: " + endInd);
      }
  }

  // Remove all those identified annotations that fall within de-id strings.
  for(IdentifiedAnnotation annot : toRemove){
      annot.removeFromIndexes();
  }
   // Collection of UmlsConcept objects
   final Collection<UmlsConcept> umlsConceptList = new ArrayList<>();
   try {
      for ( Map.Entry<TextSpan, ? extends Collection<Long>> spanCuis : textSpanCuis ) {
         umlsConceptList.clear();
         for ( Long cuiCode : spanCuis.getValue() ) {
            umlsConceptList.addAll(
                  createUmlsConcepts( jcas, codingScheme, cTakesSemantic, cuiCode, cuiConcepts ) );
         }
         final FSArray conceptArr = new FSArray( jcas, umlsConceptList.size() );
         int arrIdx = 0;
         for ( UmlsConcept umlsConcept : umlsConceptList ) {
            conceptArr.set( arrIdx, umlsConcept );
            arrIdx++;
         }
         final IdentifiedAnnotation annotation = createSemanticAnnotation( jcas, cTakesSemantic );
         annotation.setTypeID( cTakesSemantic );
         annotation.setBegin( spanCuis.getKey().getStart() );
         annotation.setEnd( spanCuis.getKey().getEnd() );
         annotation.setDiscoveryTechnique( CONST.NE_DISCOVERY_TECH_DICT_LOOKUP );
         annotation.setOntologyConceptArr( conceptArr );
         annotation.addToIndexes();
      }
   } catch ( CASRuntimeException crtE ) {
      // What is really thrown?  The jcas "throwFeatMissing" is not a great help
      throw new AnalysisEngineProcessException( crtE );
   }
}
 
开发者ID:tmills,项目名称:ctakes-docker,代码行数:59,代码来源:DeidAwareTermConsumer.java

示例13: setFeatureValue

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
@Override
public void setFeatureValue(Feature feat, FeatureStructure fs) throws CASRuntimeException {
  throw new UnsupportedOperationException();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:5,代码来源:TempEval2013Writer.java

示例14: getFeatureValue

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
@Override
public FeatureStructure getFeatureValue(Feature feat) throws CASRuntimeException {
  throw new UnsupportedOperationException();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:5,代码来源:TempEval2013Writer.java

示例15: setStringValue

import org.apache.uima.cas.CASRuntimeException; //导入依赖的package包/类
@Override
public void setStringValue(Feature feat, String s) throws CASRuntimeException {
  throw new UnsupportedOperationException();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:5,代码来源:TempEval2013Writer.java


注:本文中的org.apache.uima.cas.CASRuntimeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。