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


Java FSIterator.hasNext方法代码示例

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


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

示例1: CasViewProcessor

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
@Inject
CasViewProcessor(Client client,
                 FeatureStructureProcessorFactory featureStructureProcessorFactory,
                 @Assisted CasProcessorSettings casProcessorSettings,
                 @Assisted SofaData sofaData) throws InterruptedException {
    this.client = client;
    this.featureStructureProcessorFactory = featureStructureProcessorFactory;

    this.casProcessorSettings = casProcessorSettings;
    typeSystemInfo = casProcessorSettings.getTypeSystemInfo();
    casProcessingDelegate = casProcessorSettings.getCasProcessingDelegate();


    this.sofaData = sofaData;
    this.fsRefQueue = sofaData.getFsRefQueue();

    CAS cas = sofaData.getCas();

    lowLevelCAS = cas.getLowLevelCAS();
    Type topType = cas.getTypeSystem().getTopType();
    FSIterator<FeatureStructure> allIndexedFS = cas.getIndexRepository().getAllIndexedFS(topType);
    while (allIndexedFS.hasNext()) {
        sofaData.getIdentifierForFs(allIndexedFS.next());
    }
}
 
开发者ID:nlpie,项目名称:nlptab,代码行数:26,代码来源:CasViewProcessor.java

示例2: process

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
@Override	
public void process(JCas jcas)
throws AnalysisEngineProcessException {
	try {
		FSIterator ccptaIterator = jcas.getAnnotationIndex(CCPTextAnnotation.type).iterator();
		while (ccptaIterator.hasNext()) {
				CCPTextAnnotation ccpta = (CCPTextAnnotation) ccptaIterator.next();
			String ccptaMentionName = ccpta.getClassMention().getMentionName();
			if (ccptaMentionName != null) {
				Matcher m = mentionTypeInPattern.matcher(ccptaMentionName);
				if ( m.matches() ) {
					CCPClassMention ccpcm = ccpta.getClassMention();
					ccpcm.setMentionName(mentionTypeOut);
					UIMA_Util.addSlotValue(ccpcm, "ID", ccptaMentionName);
				}
			}
		}
	} catch (CASException e) {
		e.printStackTrace();
		throw new AnalysisEngineProcessException();
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:23,代码来源:MapNameToIDSlot_AE.java

示例3: showSdiWithCategory

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
public static void showSdiWithCategory(JCas jcas) {
	FSIterator<Annotation> it = jcas.getAnnotationIndex(WordAnnotation.type).iterator();
	int wordCnt = 0;
	while(it.hasNext()) {
		wordCnt++;
		WordAnnotation a = (WordAnnotation) it.next();
		System.out.print(a.getCoveredText() + "_" + a.getTag());
		if(wordCnt < 12) {
			System.out.print(" ");
		} else {
			System.out.println();
			wordCnt = 0;
		}
			
	}
	System.out.println(Joiner.on(" ").join(it));
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:18,代码来源:JCasUtils.java

示例4: process

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
	FSIterator<Annotation> it = jCas.getAnnotationIndex(WordAnnotation.type).iterator();
	WordAnnotation word;
	while(it.hasNext()) {
		word = (WordAnnotation) it.next();
		if (word.getLemma() == null)
			word.setLemma(word.getCoveredText().toLowerCase(language.getLocale()));
		else if (word.getLemma().equals(TermSuiteConstants.CARD_TAG)) 
			word.setLemma(word.getCoveredText().toLowerCase(language.getLocale()));
		else  
			word.setLemma(word.getLemma().toLowerCase());
		
		fixPlural();
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:17,代码来源:TreeTaggerLemmaFixer.java

示例5: removeInvalids

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
/**
 * Postprocessing: Remove invalid timex expressions. These are already
 * marked as invalid: timexValue().equals("REMOVE")
 * 
 * @param jcas
 */
public void removeInvalids(JCas jcas) {

	/*
	 * Iterate over timexes and add invalids to HashSet 
	 * (invalids cannot be removed directly since iterator is used)
	 */
	FSIterator iterTimex = jcas.getAnnotationIndex(Timex3.type).iterator();
	HashSet<Timex3> hsTimexToRemove = new HashSet<Timex3>();
	while (iterTimex.hasNext()) {
		Timex3 timex = (Timex3) iterTimex.next();
		if (timex.getTimexValue().equals("REMOVE")) {
			hsTimexToRemove.add(timex);
		}
	}

	// remove invalids, finally
	for (Timex3 timex3 : hsTimexToRemove) {
		timex3.removeFromIndexes();
		this.timex_counter--;
		Logger.printDetail(timex3.getTimexId()+" REMOVING PHASE: "+"found by:"+timex3.getFoundByRule()+" text:"+timex3.getCoveredText()+" value:"+timex3.getTimexValue());
	}
}
 
开发者ID:HeidelTime,项目名称:heideltime,代码行数:29,代码来源:HeidelTime.java

示例6: process

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
@Override
public void process(JCas cas) throws AnalysisEngineProcessException {
	List<WordAnnotation> rem = Lists.newArrayList();
	FSIterator<Annotation> it = cas.getAnnotationIndex(WordAnnotation.type).iterator();
	WordAnnotation word;
	while(it.hasNext()) {
		word = (WordAnnotation) it.next();
		for(Pattern p:PATTERNS) 
			if(p.matcher(word.getCoveredText()).matches())
				rem.add(word);
	}
	
	this.totalFiltered += rem.size();
	
	for(WordAnnotation wa:rem)
		wa.removeFromIndexes(cas);
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:18,代码来源:StringRegexFilter.java

示例7: getExportFilePath

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
protected String getExportFilePath(JCas cas) {
	AnnotationIndex<Annotation> index = cas.getAnnotationIndex(SourceDocumentInformation.type);
	FSIterator<Annotation> iterator = index.iterator();
	if (iterator.hasNext()) {
		SourceDocumentInformation annotation = (SourceDocumentInformation) iterator.next();
		File file = new File(annotation.getUri());
		String name = file.getName();
		int i = name.lastIndexOf('.');
		if (i == -1) {
			return name + ".xmi";
		} else {
			return name.substring(0, i) + ".xmi";
		}
	} else {
		return null;
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:18,代码来源:XmiCasExporter.java

示例8: getAnnotations

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
protected List<AnnotationFS> getAnnotations(JCas jCas) {
  int makeInstanceOffset = jCas.getDocumentText().length();
  List<AnnotationFS> annotations = new ArrayList<AnnotationFS>();
  FSIterator<Annotation> iterator = jCas.getAnnotationIndex().iterator();
  while (iterator.isValid() && iterator.hasNext()) {
    Annotation annotation = iterator.next();
    if (annotation instanceof DocumentAnnotation || annotation instanceof org.cleartk.timeml.type.Text || annotation instanceof Event || annotation instanceof Time  || annotation instanceof TemporalLink) {
      annotations.add(annotation);
      if (annotation instanceof DocumentCreationTime) {
        annotations.add(new DCT((DocumentCreationTime) annotation));
      }
      if (annotation instanceof Event) {
        annotations.add(new MakeInstance((Event) annotation, makeInstanceOffset));
      }
    }
  }
  return annotations;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:19,代码来源:TempEval2013Writer.java

示例9: get

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
/**
 * Get the {@link de.tudarmstadt.ukp.dkpro.argumentation.types.WebArgumentMetadata} from the JCas.
 *
 * @throws IllegalArgumentException if no {@link DocumentMetaData} exists in the jCas
 */
public static WebArgumentMetadata get(final JCas jCas)
{
    FSIterator<FeatureStructure> iterator = jCas.getCas().getIndexRepository().getAllIndexedFS(
            CasUtil.getType(jCas.getCas(), WebArgumentMetadata.class));

    if (!iterator.hasNext()) {
        throw new IllegalArgumentException(new Throwable("CAS does not contain any "
                + WebArgumentMetadata.class.getName()));
    }

    WebArgumentMetadata result = (WebArgumentMetadata) iterator.next();

    if (iterator.hasNext()) {
        throw new IllegalArgumentException(new Throwable("CAS contains more than one "
                + WebArgumentMetadata.class.getName()));
    }

    return result;
}
 
开发者ID:habernal,项目名称:dkpro-argumentation-minimal,代码行数:25,代码来源:WebArgumentMetadataHelper.java

示例10: getArtifactViewName

import org.apache.uima.cas.FSIterator; //导入方法依赖的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

示例11: retrieveSourceDocumentFile

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
/**
 *  Return the input file from the CAS 
 *  Assumes that it has the sourceDocumentInformation 
 *  (set by FileSystemCollectionReader or documentAnalyzer.sh)
 *  null otherwise
 */
public static File retrieveSourceDocumentFile(JCas aJCas)
throws AnalysisEngineProcessException {
	FSIterator<Annotation> sourceDocumentInformationFSIterator = aJCas.getAnnotationIndex(JCasSofaViewUtils.getJCasType(aJCas,
			DEFAULT_SOURCE_DOCUMENT_INFORMATION_ANNOTATION)).iterator();
	File inFile = null;
	if (sourceDocumentInformationFSIterator.hasNext()) {
		SourceDocumentInformation theSourceDocumentInformation = (SourceDocumentInformation) sourceDocumentInformationFSIterator.next();

		try {
			inFile = new File(new URL(theSourceDocumentInformation.getUri()).getPath());
			// System.out.println("Debug: SourceDocumentInformation File Name "+ inFileName);  	

		} catch (MalformedURLException e) {
			// invalid URL, use default processing below
			String errmsg = "Error: MalformedURLException !";
			throw new AnalysisEngineProcessException(errmsg,
					new Object[] { },e);	
			//e.printStackTrace();
		}

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

示例12: removeDuplicateAnnotations

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
/**
 * Remove duplicate annotations at the same offsets
 * from the index
 *
 * Only based on testing the offset, may have distinct features values !
 * In case of duplicate, no guarantee about which one will be removed  
 * 
 * @param aJCas  the CAS which contains the FSindex       

 * @author hernandez
 * @throws AnalysisEngineProcessException 
 * 
 */
public static void removeDuplicateAnnotations(JCas aJCas) {
	AnnotationIndex<Annotation> anAnnotationIndex = aJCas.getAnnotationIndex();
	FSIterator<Annotation> anAnnotationIterator = anAnnotationIndex.iterator();

	while (anAnnotationIterator.hasNext()) {
		Annotation anAnnotation = anAnnotationIterator.next();
		removeSubsumedAnnotation(aJCas,anAnnotation.getClass().getName(),anAnnotation.getClass().getName(),true);
	}
	//HashMap<String, String> alreadySeenFS = new HashMap<String, String>();
	//
	// parse the FSIndex
	// compute an hash of the current Annotation from Class.name alphabetcally ordered list of features with their value.toString()
	// if alreadySeenFS this hash them remove from FS
	// else add to alreadSeenFS
	//
	//byte[] hash      = null;
	//try {
	//	hash= MessageDigest.getInstance("MD5").digest(aJCas.getSofaDataString().getBytes());
	//} catch (NoSuchAlgorithmException e) {
	//	// TODO Auto-generated catch block
	//	e.printStackTrace();
	//}

}
 
开发者ID:EUMSSI,项目名称:EUMSSI-tools,代码行数:38,代码来源:AnnotationCollectionUtils.java

示例13: countAnnotation

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
private static int countAnnotation(JCas aJCas, Type aAnnotType)
{
	int count = 0; 
	
    // get iterator over annotations
	FSIterator<Annotation> iter = aJCas.getAnnotationIndex(aAnnotType).iterator(); 

    // iterate
	while(iter.hasNext())
	{
		count++; 
		iter.next(); 
	}
	
	return count; 
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:17,代码来源:PlatformCASProber.java

示例14: process

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {

    String pmId = getHeaderDocId(jCas);
    System.out.println(pmId + " -----------------------------");
    FSIterator<Annotation> it = jCas.getAnnotationIndex().iterator();
    StringBuffer sb = new StringBuffer();
    while (it.hasNext()) {
        Annotation a = it.next();
        sb.append(a.getCoveredText() + '\n');
        a.prettyPrint(2, 2, sb, false);
        sb.append('\n');

    }
    System.out.println(sb);
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:17,代码来源:Dumper.java

示例15: process

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
public List<AnnotationWrapper> process(String text)
		throws ResourceInitializationException,
		AnalysisEngineProcessException, CASException {

	// process text with Ruta
	final CAS cas = engine.newCAS();
	cas.setDocumentText(text);
	engine.process(cas);

	// add annotations to response, skip some
	ArrayList<AnnotationWrapper> annotations = new ArrayList<AnnotationWrapper>();
	FSIterator<AnnotationFS> it = cas.getAnnotationIndex().iterator();
	while (it.hasNext()) {
		AnnotationFS a = it.next();
		String aName = a.getType().getShortName();
		if (types.contains(aName)) {
			annotations.add(new AnnotationWrapper(aName, a.getBegin(), a
					.getEnd(), a.getCoveredText()));
		}
	}
	return annotations;
}
 
开发者ID:renaud,项目名称:ruta_server,代码行数:23,代码来源:RutaEngine.java


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