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


Java FSArray.get方法代码示例

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


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

示例1: createTreeFromTokens

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
 * Creates the ClearNLP Deptree from word tokens for a sentence.
 *
 * @param tokens
 *            the tokens
 * @return the DEP tree
 */
private static DEPTree createTreeFromTokens(final List<WordToken> tokens) {
	// Generate DEPTree from WordTokens
	final DEPTree tree = new DEPTree(tokens.size());
	int tokenIndex = 0;
	for (final WordToken wt : tokens) {
		final DEPNode node = new DEPNode(tokenIndex++, wt.getCoveredText());
		node.setPOSTag(wt.getPartOfSpeech());
		final FSArray lemmas = wt.getLemmas();
		if (lemmas != null && lemmas.size() > 0) {
			final WordLemma wl = (WordLemma) lemmas.get(0);
			node.setLemma(wl.getLemmaForm());
		}
		tree.add(node);
	}
	return tree;
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:24,代码来源:ClearNlpParser.java

示例2: getSlotMentionByName

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static CCPSlotMention getSlotMentionByName(CCPClassMention ccpClassMention, String slotMentionName) {
	FSArray slotMentionsArray = ccpClassMention.getSlotMentions();
	if (slotMentionsArray != null) {
		CCPSlotMention returnSlotMention = null;
		for (int i = 0; i < slotMentionsArray.size(); i++) {
			FeatureStructure fs = slotMentionsArray.get(i);
			if (fs instanceof CCPSlotMention) {
				CCPSlotMention ccpSlotMention = (CCPSlotMention) fs;
				if (ccpSlotMention.getMentionName().equals(slotMentionName)) {
					returnSlotMention = ccpSlotMention;
					break;
				}
			} else {
				logger.error("Expecting CCPSlotMention but got a : " + fs.getClass().getName());
			}
		}
		return returnSlotMention;
	} else {
		return null;
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:22,代码来源:UIMA_Util.java

示例3: getPrimitiveSlotMentionByName

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static CCPPrimitiveSlotMention getPrimitiveSlotMentionByName(CCPClassMention ccpClassMention,
		String slotMentionName) {
	FSArray slotMentionsArray = ccpClassMention.getSlotMentions();
	if (slotMentionsArray != null) {
		CCPPrimitiveSlotMention returnSlotMention = null;
		for (int i = 0; i < slotMentionsArray.size(); i++) {
			FeatureStructure fs = slotMentionsArray.get(i);
			if (fs instanceof CCPPrimitiveSlotMention) {
				CCPPrimitiveSlotMention ccpSlotMention = (CCPPrimitiveSlotMention) fs;
				if (ccpSlotMention.getMentionName().equals(slotMentionName)) {
					returnSlotMention = ccpSlotMention;
					break;
				}
			}
		}
		return returnSlotMention;
	} else {
		return null;
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:21,代码来源:UIMA_Util.java

示例4: getComplexSlotMentionByName

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static CCPComplexSlotMention getComplexSlotMentionByName(CCPClassMention ccpClassMention,
		String slotMentionName) {

	FSArray slotMentionsArray = ccpClassMention.getSlotMentions();
	if (slotMentionsArray != null) {
		CCPComplexSlotMention returnSlotMention = null;
		for (int i = 0; i < slotMentionsArray.size(); i++) {
			FeatureStructure fs = slotMentionsArray.get(i);
			if (fs instanceof CCPComplexSlotMention) {
				CCPComplexSlotMention ccpSlotMention = (CCPComplexSlotMention) fs;
				if (ccpSlotMention.getMentionName().equals(slotMentionName)) {
					returnSlotMention = ccpSlotMention;
					break;
				}
			}
		}
		return returnSlotMention;
	} else {
		return null;
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:22,代码来源:UIMA_Util.java

示例5: validateCCPClassMention

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
 * This method checks each slot mention associated with the input class mention for valid slot
 * fillers. True is returned if the CCPClassMention has a valid mention structure, false
 * otherwise.
 * 
 * @param ccpTA
 * @return
 */
public static boolean validateCCPClassMention(CCPClassMention ccpCM) {
	boolean isValid = true;

	FSArray shouldBeSlotMentions = ccpCM.getSlotMentions();
	if (shouldBeSlotMentions != null) {
		for (int i = 0; i < shouldBeSlotMentions.size(); i++) {
			Object shouldBeSM = shouldBeSlotMentions.get(i);
			if (shouldBeSM != null) {
				if (shouldBeSM instanceof CCPSlotMention) {
					return validateCCPSlotMention((CCPSlotMention) shouldBeSM);
				} else {
					logger.error("Invalid mention structure detected. Unexpected object found in FSArray holding CCPSlotMentions for the CCPClassMention: \""
							+ ccpCM.getMentionName() + "\" -- " + shouldBeSM.getClass().getName());
					logger.debug("Returning false from validateCCPClassMention() mid1");
					return false;
				}
			}
		}
	}

	logger.debug("Returning " + isValid + " from validateCCPClassMention() end");
	return isValid;

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

示例6: validateCCPComplexSlotMention

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
 * This method checks for valid slot fillers of the input CCPComplexSlotMention, i.e. slot
 * fillers must be valid CCPClassMentions. True is returned if the CCPClassMention has a valid
 * mention structure, false otherwise.
 * 
 * @param ccpTA
 * @return
 */
public static boolean validateCCPComplexSlotMention(CCPComplexSlotMention ccpCSM) {
	boolean isValid = true;

	FSArray slotValues = ccpCSM.getClassMentions();
	if (slotValues != null) {
		for (int i = 0; i < slotValues.size(); i++) {
			Object shouldBeAClassMention = slotValues.get(i);
			if (shouldBeAClassMention != null) {
				if (shouldBeAClassMention instanceof CCPClassMention) {
					isValid = isValid && validateCCPClassMention((CCPClassMention) shouldBeAClassMention);
				} else {
					logger.error("Invalid mention structure discovered. Instead of a CCPClassMention, this slot filler for this CCPComplexSlotMention is a: "
							+ shouldBeAClassMention.getClass().getName());
					logger.debug("Returning false from validateCCPComplexSlotMention()");
					return false;
				}
			}
		}
	}
	logger.debug("Returning " + isValid + " from validateCCPComplexSlotMention() end");
	return isValid;
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:31,代码来源:UIMA_Util.java

示例7: getAnnotationProperties

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
 * 
 * Returns a Collection of a specific annotation property type
 * 
 * 
 * 
 * @param <T>
 * 
 * @param ccpTA
 * 
 * @param annotationPropertyClass
 * 
 * @param jcas
 * 
 * @return
 */
//public static <T extends AnnotationProperty> Collection<T> getAnnotationProperties(
public static <T extends AnnotationMetadataProperty> Collection<T> getAnnotationProperties(
		CCPTextAnnotation ccpTA, Class<T> annotationPropertyClass, JCas jcas) {
	// int returnType = getFeatureStructureType(annotationPropertyClass);
	Collection<T> annotationPropertiesToReturn = new ArrayList<T>();
	AnnotationMetadata metaData = getAnnotationMetadata(ccpTA, jcas);
	FSArray annotationProperties = metaData.getMetadataProperties();
	if (annotationProperties != null) {
		for (int i = 0; i < annotationProperties.size(); i++) {
			FeatureStructure fs = annotationProperties.get(i);
			if (annotationPropertyClass.isAssignableFrom(fs.getClass())) {
				annotationPropertiesToReturn.add(annotationPropertyClass.cast(fs));
			}
		}
	}
	return annotationPropertiesToReturn;
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:34,代码来源:UIMA_Annotation_Util.java

示例8: getSrl

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
 * Extracts all semantic predicates with respective arguments (the underscore
 *          is used to concatenate parts).
 * 
 * @param jCas            input jCas    
 * @param goodToks        an object keeping information on all the good tokens.
 * @param useLabels       include the argument-type label?
 * @return a string with space-separated semantic predicate tuples (with parts 
 *         concatenated using the underscore).
 */
public String getSrl(final JCas jCas, final GoodTokens goodToks, 
                     boolean useLabels) {
  StringBuffer sb = new StringBuffer();
  
  for (SemanticPredicate pred : JCasUtil.select(jCas, SemanticPredicate.class)) {
    FSArray fa = pred.getArguments();
    for (Token tokPred: JCasUtil.selectCovered(Token.class, pred)) {
      String textPred = goodToks.mMap.get(tokPred);
      if (null == textPred) continue; // e.g. if text1 is a stop word
      for (int i = 0; i < fa.size(); ++i) {
        SemanticArgument arg = (SemanticArgument)fa.get(i); 
        for (Token tokArg: JCasUtil.selectCovered(Token.class, arg)) {
          String textArg = goodToks.mMap.get(tokArg);
          if (null == textArg) continue; // e.g. if text2 is a stop word
          if (sb.length() > 0) {
            sb.append(' ');
          }
          sb.append(textPred + "_" + (useLabels ? arg.getRole() + "_": "") + textArg);
        }
      }
    }
  }
  
  return strFromStrStream(sb);
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:36,代码来源:ExtractTextReps.java

示例9: testAuthors

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
@Test
public void testAuthors() throws Exception {

    // http://www.ncbi.nlm.nih.gov/pubmed/?term=1&report=xml&format=text
    CollectionReader cr = createReader(PubmedDatabaseCR.class,
            BlueUima.PARAM_BETWEEN, new int[] { 0, 1 },
            BlueUima.PARAM_SKIP_EMPTY_DOCS, false);

    String[] lastNames = { "Makar", "McMartin", "Palese", "Tephly" };
    String[] foreNames = { "A B", "K E", "M", "T R" };
    // AB___A B___Makar__-__KE___K
    // E___McMartin__-__M___M___Palese__-__TR___T R___Tephly
    for (JCas jCas : asList(cr)) {
        Header header = JCasUtil.selectSingle(jCas, Header.class);

        FSArray authors = header.getAuthors();
        for (int i = 0; i < authors.size(); i++) {
            AuthorInfo a = (AuthorInfo) authors.get(i);
            assertEquals(foreNames[i], a.getForeName());
            assertEquals(lastNames[i], a.getLastName());
        }

        assertEquals("1976-01-16", header.getCopyright());
    }
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:26,代码来源:PubmedDatabaseCRTest.java

示例10: getPrefPOSTag

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
private POSTag getPrefPOSTag(Token token) {
    POSTag tag = null;
    FSArray postags = token.getPosTag();
    for (int i = 0; i < postags.size(); i++) {
        POSTag fs = (POSTag) postags.get(i);
        // if there are POS Tags
        if (fs != null) {

            // compare to the desired type of POS Tag Set
            if (fs.getType().getName().equals(posTagSetPreference)) {

                i = postags.size();
                return (POSTag) fs;
            }
        }
    }
    return tag;
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:19,代码来源:ChunkAnnotator.java

示例11: loadAnswers

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static List<Answer> loadAnswers(JCas candidateView, List<String> featureLabels) {
	List<Answer> result = new ArrayList<Answer>();
	Iterator<?> it = candidateView.getJFSIndexRepository().getAllIndexedFS(
			AnswerList.type);

	if (it.hasNext()) {
		AnswerList answers = (AnswerList) it.next();
		if (featureLabels != null && answers.getFeatureLabels() != null) {
			for (int i = 0; i < answers.getFeatureLabels().size(); i++) {
				featureLabels.add(answers.getFeatureLabels(i));
			}
		}
		FSArray answerList = answers.getAnswerList();
		for (int i = 0; i < answerList.size(); i++) {
			Answer a = (Answer) answerList.get(i);
			result.add(a);
		}
	}
	return result;
}
 
开发者ID:brmson,项目名称:blanqa,代码行数:21,代码来源:AnswerJCasManipulator.java

示例12: getAnnotationProperty

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
 * Returns the annotation value based on the given annotation type.
 * 
 * @param annotation
 *            {@see IdentifiedAnnotation} object.
 * @param property
 *            {@see CTAKESAnnotationProperty} enum used to identify the
 *            annotation type.
 * @return the annotation value.
 */
public static String getAnnotationProperty(IdentifiedAnnotation annotation,
		CTAKESAnnotationProperty property) {
	String value = null;
	if (property == CTAKESAnnotationProperty.BEGIN) {
		value = Integer.toString(annotation.getBegin());
	} else if (property == CTAKESAnnotationProperty.END) {
		value = Integer.toString(annotation.getEnd());
	} else if (property == CTAKESAnnotationProperty.CONDITIONAL) {
		value = Boolean.toString(annotation.getConditional());
	} else if (property == CTAKESAnnotationProperty.CONFIDENCE) {
		value = Float.toString(annotation.getConfidence());
	} else if (property == CTAKESAnnotationProperty.DISCOVERY_TECNIQUE) {
		value = Integer.toString(annotation.getDiscoveryTechnique());
	} else if (property == CTAKESAnnotationProperty.GENERIC) {
		value = Boolean.toString(annotation.getGeneric());
	} else if (property == CTAKESAnnotationProperty.HISTORY_OF) {
		value = Integer.toString(annotation.getHistoryOf());
	} else if (property == CTAKESAnnotationProperty.ID) {
		value = Integer.toString(annotation.getId());
	} else if (property == CTAKESAnnotationProperty.ONTOLOGY_CONCEPT_ARR) {
		FSArray mentions = annotation.getOntologyConceptArr();
		StringBuilder sb = new StringBuilder();
		if (mentions != null) {
			for (int i = 0; i < mentions.size(); i++) {
				if (mentions.get(i) instanceof UmlsConcept) {
					UmlsConcept concept = (UmlsConcept) mentions.get(i);
					sb.append(concept.getCui());
					if (i < mentions.size() - 1) {
						sb.append(",");
					}
				}
			}
		}
		value = sb.toString();
	} else if (property == CTAKESAnnotationProperty.POLARITY) {
		value = Integer.toString(annotation.getPolarity());
	}
	return value;
}
 
开发者ID:theyiwenliu,项目名称:CTAKESContentToMetadataHandler,代码行数:50,代码来源:CTAKESUtils.java

示例13: checkForIgnoreBasedOnAnnotationSet

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
protected boolean checkForIgnoreBasedOnAnnotationSet(CCPTextAnnotation ccpTA) {
	boolean ignore = false;
	FSArray annotationSets = ccpTA.getAnnotationSets();
	if (annotationSets != null & annotationSetsToIgnore != null) {
		for (int i = 0; i < annotationSets.size(); i++) {
			CCPAnnotationSet aSet = (CCPAnnotationSet) annotationSets.get(i);
			if (annotationSetsToIgnore.contains(aSet.getAnnotationSetID())) {
				ignore = true;
				break;
			}
		}
	}
	return ignore;
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:15,代码来源:AnnotationSetOverrider_AE.java

示例14: getSlotValues

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public Collection<ClassMention> getSlotValues() {
	Collection<ClassMention> classMentionsToReturn = new ArrayList<ClassMention>();
	FSArray slotValues = wrappedCSM.getClassMentions();
	if (slotValues != null) {
		for (int i = 0; i < slotValues.size(); i++) {
			CCPClassMention ccpCM = (CCPClassMention) slotValues.get(i);
			classMentionsToReturn.add(new WrappedCCPClassMention(ccpCM));
		}
	}
	return classMentionsToReturn;
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:12,代码来源:WrappedCCPComplexSlotMention.java

示例15: swapClassMentionInfo

import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static void swapClassMentionInfo(CCPClassMention fromCM, CCPClassMention toCM) throws CASException {
	toCM.setMentionName(fromCM.getMentionName());
	JCas jcas = fromCM.getCAS().getJCas();
	FSArray fromSlotMentions = fromCM.getSlotMentions();
	if (fromSlotMentions != null) {
		FSArray toSlotMentions = new FSArray(jcas, fromSlotMentions.size());
		for (int i = 0; i < fromSlotMentions.size(); i++) {
			if (fromSlotMentions.get(i) instanceof CCPPrimitiveSlotMention) {
				toSlotMentions.set(i,
						copyCCPPrimitiveSlotMention((CCPPrimitiveSlotMention) fromSlotMentions.get(i)));
			} else if (fromSlotMentions.get(i) instanceof CCPComplexSlotMention) {
				CCPComplexSlotMention toSM = new CCPComplexSlotMention(jcas);
				UIMA_Util.swapComplexSlotMentionInfo((CCPComplexSlotMention) fromSlotMentions.get(i), toSM);
				toSlotMentions.set(i, toSM);
			} else {
				System.err.println("Expecting CCPNonComplexSlotMention of CCPComplexSlotMention but got: "
						+ fromSlotMentions.get(i).getClass().getName());
			}
		}
		toCM.setSlotMentions(toSlotMentions);
	}

	CCPTextAnnotation fromTextAnnotation = fromCM.getCcpTextAnnotation();
	if (fromTextAnnotation != null) {
		toCM.setCcpTextAnnotation(fromTextAnnotation);
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:28,代码来源:UIMA_Util.java


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