本文整理汇总了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());
}
}
示例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();
}
}
示例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));
}
示例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();
}
}
示例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());
}
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
//}
}
示例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;
}
示例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);
}
示例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;
}