本文整理汇总了Java中org.apache.uima.jcas.cas.FSArray.size方法的典型用法代码示例。如果您正苦于以下问题:Java FSArray.size方法的具体用法?Java FSArray.size怎么用?Java FSArray.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.jcas.cas.FSArray
的用法示例。
在下文中一共展示了FSArray.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAggregateSpan
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
*
* Extracts the aggregate span from the individual CCPSpans in the CCPTextAnnotation span list
*
*
*
* @param ccpTA
*
* @throws KnowledgeRepresentationWrapperException
*/
public static void updateAggregateSpan(CCPTextAnnotation ccpTA) throws KnowledgeRepresentationWrapperException {
FSArray spanList = ccpTA.getSpans();
if (spanList != null) {
int aggregateSpanStart = Integer.MAX_VALUE;
int aggregateSpanEnd = Integer.MIN_VALUE;
for (int i = 0; i < spanList.size(); i++) {
CCPSpan span = getExpectedSpan(spanList.get(i));
if (span.getSpanStart() < aggregateSpanStart) {
aggregateSpanStart = span.getSpanStart();
}
if (span.getSpanEnd() > aggregateSpanEnd) {
aggregateSpanEnd = span.getSpanEnd();
}
}
ccpTA.setBegin(aggregateSpanStart);
ccpTA.setEnd(aggregateSpanEnd);
} else {
throw new KnowledgeRepresentationWrapperException(
"Cannot update aggregate span, the CCPTextAnnotation has no span list.");
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例5: removeSlotMentions
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static void removeSlotMentions(CCPClassMention ccpCM, Class slotType, JCas jcas) {
List<CCPSlotMention> slotMentionsToKeep = new ArrayList<CCPSlotMention>();
FSArray slotMentions = ccpCM.getSlotMentions();
if (slotMentions != null) {
for (int i = 0; i < slotMentions.size(); i++) {
if (!(slotType.isInstance(slotMentions.get(i)))) {
slotMentionsToKeep.add((CCPSlotMention) slotMentions.get(i));
}
}
}
FSArray updatedSlotMentions = new FSArray(jcas, slotMentionsToKeep.size());
for (int i = 0; i < slotMentionsToKeep.size(); i++) {
updatedSlotMentions.set(i, slotMentionsToKeep.get(i));
}
ccpCM.setSlotMentions(updatedSlotMentions);
}
示例6: getTrailingSpan
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
*
* Returns the left-most CCPSpan in the span list.
*
*
*
* @param ccpTA
*
* @return
*
* @throws KnowledgeRepresentationWrapperException
*/
private static CCPSpan getTrailingSpan(CCPTextAnnotation ccpTA) throws KnowledgeRepresentationWrapperException {
FSArray spanList = ccpTA.getSpans();
if (spanList != null && spanList.size() > 0) {
CCPSpan trailingSpan = getExpectedSpan(spanList.get(0));
for (int i = 1; i < spanList.size(); i++) {
CCPSpan span = getExpectedSpan(spanList.get(i));
if (span.getSpanEnd() > trailingSpan.getSpanEnd()) {
trailingSpan = span;
}
}
return trailingSpan;
} else {
throw new KnowledgeRepresentationWrapperException(
"Cannot get leading span, the CCPTextAnnotation has no span list.");
}
}
示例7: 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;
}
示例8: 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;
}
示例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());
}
}
示例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;
}
示例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;
}
示例12: getSpanList
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
*
* Returns a list of Spans for the input CCPTextAnnotation
*
*
*
* @param ccpTA
*
* @return
*
* @throws KnowledgeRepresentationWrapperException
*/
public static List<Span> getSpanList(CCPTextAnnotation ccpTA) throws KnowledgeRepresentationWrapperException {
List<Span> spanListToReturn = new ArrayList<Span>();
FSArray spanList = ccpTA.getSpans();
if (spanList != null && spanList.size() > 0) {
for (int i = 0; i < spanList.size(); i++) {
CCPSpan ccpSpan = getExpectedSpan(spanList.get(i));
spanListToReturn.add(convertSpan(ccpSpan));
}
return spanListToReturn;
} else {
throw new KnowledgeRepresentationWrapperException(
"Cannot return list of spans, the CCPTextAnnotation has no span list.");
}
}
示例13: getLemma
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
private String getLemma(final WordToken token) {
final FSArray array = token.getLemmas();
if (array == null || array.size() == 0) {
return "_";
} else {
return ((WordLemma) array.get(0)).getLemmaForm();
}
}
示例14: 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;
}
示例15: removeComplexSlotMentions
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
*
* This method removes all CCPComplexSlotMentions from the input CCPClassMention
*
*
*
* @param ccpCM
*
* @param jcas
*/
public static void removeComplexSlotMentions(CCPClassMention ccpCM, JCas jcas) {
List<FeatureStructure> slotsToKeep = new ArrayList<FeatureStructure>();
FSArray slotMentions = ccpCM.getSlotMentions();
if (slotMentions != null) {
for (int i = 0; i < slotMentions.size(); i++) {
if (!(slotMentions.get(i) instanceof CCPComplexSlotMention)) {
slotsToKeep.add(slotMentions.get(i));
}
}
}
ccpCM.setSlotMentions(UIMA_Util.listToFsarray(slotsToKeep, jcas));
}