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


Java FSIterator.next方法代码示例

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


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

示例1: 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:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:29,代码来源:HeidelTimeOpenNLP.java

示例2: getPosFromMatchResult

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
/**
 * Identify the part of speech (POS) of a MarchResult.
 * @param tokBegin
 * @param tokEnd
 * @param s
 * @param jcas
 * @return
 */
public String getPosFromMatchResult(int tokBegin, int tokEnd, Sentence s, JCas jcas) {
	// get all tokens in sentence
	HashMap<Integer, Token> hmTokens = new HashMap<Integer, Token>();
	FSIterator iterTok = jcas.getAnnotationIndex(Token.type).subiterator(s);
	while (iterTok.hasNext()) {
		Token token = (Token) iterTok.next();
		hmTokens.put(token.getBegin(), token);
	}
	// get correct token
	String pos = "";
	if (hmTokens.containsKey(tokBegin)) {
		Token tokenToCheck = hmTokens.get(tokBegin);
		pos = tokenToCheck.getPos();
	}
	return pos;
}
 
开发者ID:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:25,代码来源:HeidelTimeOpenNLP.java

示例3: isValidDCT

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
/**
 * Check whether or not a jcas object has a correct DCT value.
 * If there is no DCT present, we canonically return true since
 * fallback calculation takes care of that scenario.
 * @param jcas
 * @return Whether or not the given jcas contains a valid DCT
 */
private Boolean isValidDCT(JCas jcas) {
	FSIterator dctIter = jcas.getAnnotationIndex(Dct.type).iterator();
	
	if(!dctIter.hasNext()) {
		return true;
	} else {
		Dct dct = (Dct) dctIter.next();
		String dctVal = dct.getValue();
		
		if(dctVal == null)
			return false;
		
		if(dctVal.matches("\\d{8}") // Something like 20041224
				|| dctVal.matches("\\d{4}.\\d{2}.\\d{2}.*")) { // Something like 2004-12-24
			return true;
		} else {
			return false;
		}
	}
}
 
开发者ID:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:28,代码来源:HeidelTimeOpenNLP.java

示例4: 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

示例5: printEntityAnnotations

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
/**
 * outputs the Tx lines from BioNLP. Where in BioNLP '09, they were just labelled
    * "Protein", these may be other classes of things. The ID is mapped to such
    * classes by the function mapUimaToBionlp().
 * 
 * Ex. T1<tab>entity-class-name 21 29<tab>covered text
 *
 * Ex. T1	Protein 21 29	P41
    */
private void printEntityAnnotations(JCas jcas) throws IOException {
	FSIterator taIterator = jcas.getAnnotationIndex(CCPTextAnnotation.type).iterator();
	while (taIterator.hasNext()) {
		CCPTextAnnotation ta = (CCPTextAnnotation) taIterator.next();
		entityCount++;
		String mentionName = ta.getClassMention().getMentionName();
		String entityClassName = mapUimaToBionlp(mentionName);
		if (entityClassName != null) {
			// T1<tab>class-name 21 29<tab>covered text
			String entityStr = "T" + entityCount + "\t" + entityClassName + " " + ta.getBegin() + " " + ta.getEnd()
					+ "\t" + ta.getCoveredText().replaceAll("\\n"," ").trim();
			logger.debug("[" + ta.getBegin() + ".." + ta.getEnd() + "] " + entityClassName + " " + entityCount + " from mentioname: " + mentionName);
			FileWriterUtil.printLines(CollectionsUtil.createList(entityStr), entityWriter);
		}
		else {
			logger.warn("No mapping for class mention name: " + mentionName);
		}
	}

}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:30,代码来源:BionlpFormatPrinter_AE.java

示例6: 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("CD")) //ou TermSuiteConstants.CARD_MATE
			word.setLemma(word.getCoveredText().toLowerCase(language.getLocale()));
		else  {
			word.setLemma(word.getLemma().toLowerCase());
			if (word.getLemma().equals((word.getStem()+"s"))){
			word.setLemma(word.getCoveredText().toLowerCase(language.getLocale()).replaceAll("s$", ""));
			}
		}
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:19,代码来源:MateLemmaFixer.java

示例7: process

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
@Override
public void process(JCas cas) throws AnalysisEngineProcessException {
	
	try {
		AnnotationIndex<Annotation> index = cas.getAnnotationIndex(WordAnnotation.type);
		FSIterator<Annotation> iterator = index.iterator();
		while (iterator.hasNext()) {
			WordAnnotation annotation = (WordAnnotation) iterator.next();
			String norm = annotation.getCoveredText();
			annotation.setLemma(norm);
			annotation.setStem(norm);
		}
	} catch (Exception e) {
		throw new AnalysisEngineProcessException(e);
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:17,代码来源:ChineseNormalizer.java

示例8: 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

示例9: getExportFilePath

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
protected String getExportFilePath(JCas cas, String extension) {
	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 + "." + extension;
		} else {
			return name.substring(0, i) + "." + extension;
		}
	} else {
		return null;
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:18,代码来源:CasExporter.java

示例10: 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

示例11: writeWordAnnotations

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
private static void writeWordAnnotations(JsonGenerator jg, JCas jCas) throws IOException {
    jg.writeStartArray();
    FSIterator<Annotation> it = jCas.getAnnotationIndex(WordAnnotation.type).iterator();
    while(it.hasNext()) {
        WordAnnotation wa = (WordAnnotation) it.next();
        jg.writeStartObject();
        writeStringField(jg,F_CATEGORY, wa.getCategory());
        writeStringField(jg,F_LEMMA, wa.getLemma());
        writeStringField(jg,F_STEM, wa.getStem());
        writeStringField(jg,F_TAG, wa.getTag());
        writeStringField(jg,F_SUB_CATEGORY, wa.getSubCategory());
        writeStringField(jg,F_REGEX_LABEL, wa.getRegexLabel());
        writeStringField(jg,F_NUMBER, wa.getNumber());
        writeStringField(jg,F_GENDER, wa.getGender());
        writeStringField(jg,F_CASE, wa.getCase());
        writeStringField(jg,F_MOOD, wa.getMood());
        writeStringField(jg,F_TENSE, wa.getTense());
        writeStringField(jg,F_PERSON, wa.getPerson());
        writeStringField(jg,F_DEGREE, wa.getDegree());
        writeStringField(jg,F_FORMATION, wa.getFormation());
        writeStringField(jg,F_LABELS, wa.getLabels());
        writeOffsets(jg, wa);
        jg.writeEndObject();
    }
    jg.writeEndArray();
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:27,代码来源:JsonCasSerializer.java

示例12: 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

示例13: process

import org.apache.uima.cas.FSIterator; //导入方法依赖的package包/类
/**
	 * @see org.apache.uima.analysis_component.JCasAnnotator_ImplBase#process(org.apache.uima.jcas.JCas)
	 */
	@Override
	public void process(JCas cas) throws AnalysisEngineProcessException {
		// we need the nouns and their word stem annotations here.
		FSIterator nounAnnotIter = cas.getAnnotationIndex(Noun.type).iterator();
		while(nounAnnotIter.hasNext()) {
			Noun noun = (Noun)nounAnnotIter.next();
			List<String> matchingConceptURIs = ontologyIndex.getExactMatches(noun.getWordStem());
			int length = matchingConceptURIs.size();
			if (length != 0) {
//				OntologyConcept concept = new OntologyConcept(cas);
//				concept.setBegin(noun.getBegin());
//				concept.setEnd(noun.getEnd());
				StringArray conceptURIs = new StringArray(cas, length);
				conceptURIs.copyFromArray(matchingConceptURIs.toArray(new String[length]), 0, 0, length);
				noun.setConceptURIs(conceptURIs);
				conceptURIs.addToIndexes();
//				concept.setConceptURIs(conceptURIs);
//				concept.addToIndexes();
			}
		}
	}
 
开发者ID:ag-csw,项目名称:ExpertFinder,代码行数:25,代码来源:ConceptMatcher.java

示例14: 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

示例15: 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


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