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


Java FSArray类代码示例

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


FSArray类属于org.apache.uima.jcas.cas包,在下文中一共展示了FSArray类的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: outputPattern

import org.apache.uima.jcas.cas.FSArray; //导入依赖的package包/类
private void outputPattern(final JCas jCas, final PatternExtract pattern) {
	final Pattern a = new Pattern(jCas);
	a.setBegin(pattern.getStart());
	a.setEnd(pattern.getEnd());
	a.setSource(pattern.getFrom());
	a.setTarget(pattern.getTo());

	final List<WordToken> tokens = pattern.getWordTokens();
	final FSArray array = new FSArray(jCas, tokens.size());
	int i = 0;
	for (final WordToken w : tokens) {
		array.set(i, w);
		i++;
	}
	a.setWords(array);
	addToJCasIndex(a);
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:18,代码来源:PatternExtractor.java

示例3: doProcess

import org.apache.uima.jcas.cas.FSArray; //导入依赖的package包/类
@Override
protected void doProcess(JCas jCas) throws AnalysisEngineProcessException {
	for (WordToken t : JCasUtil.select(jCas, WordToken.class)) {
		if (t.getLemmas() == null || t.getLemmas().size() > 0) {
			String text = t.getCoveredText();
			POS pos = WordNetUtils.toPos(t.getPartOfSpeech());
			if (pos != null) {
				Optional<IndexWord> lookupWord = wordnet.lookupWord(pos, text);
				if (lookupWord.isPresent()) {
					t.setLemmas(new FSArray(jCas, 1));
					WordLemma wordLemma = new WordLemma(jCas);
					wordLemma.setLemmaForm(lookupWord.get().getLemma());
					t.setLemmas(0, wordLemma);
				}
			}
		}
	}
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:19,代码来源:WordNetLemmatizer.java

示例4: setSlotValues

import org.apache.uima.jcas.cas.FSArray; //导入依赖的package包/类
public void setSlotValues(Collection<ClassMention> slotValues) throws InvalidInputException {
	List<CCPClassMention> updatedClassMentions = new ArrayList<CCPClassMention>();
	for (ClassMention cm : slotValues) {
		Object wrappedClassMention = cm.getWrappedObject();
		if (wrappedClassMention instanceof CCPClassMention) {
			CCPClassMention ccpCM = (CCPClassMention) wrappedClassMention;
			updatedClassMentions.add(ccpCM);
		} else {
			throw new InvalidInputException("Expected CCPClassMention. Cannot add class"
					+ wrappedClassMention.getClass().getName()
					+ " to the ClassMentions list of a CCPComplexSlotMention");
		}
	}

	FSArray updatedCMs = new FSArray(jcas, updatedClassMentions.size());
	for (int i = 0; i < updatedClassMentions.size(); i++) {
		updatedCMs.set(i, updatedClassMentions.get(i));
	}
	wrappedCSM.setClassMentions(updatedCMs);
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:21,代码来源:WrappedCCPComplexSlotMention.java

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

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

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

示例8: 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);
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:17,代码来源:UIMA_Util.java

示例9: getMultipleSlotMentionsByName

import org.apache.uima.jcas.cas.FSArray; //导入依赖的package包/类
public static List<CCPSlotMention> getMultipleSlotMentionsByName(CCPClassMention ccpClassMention,
		String slotMentionName) {
	List<CCPSlotMention> returnSlotMentions = new ArrayList<CCPSlotMention>();
	FSArray slotMentionsArray = ccpClassMention.getSlotMentions();
	if (slotMentionsArray != null) {
		FeatureStructure[] slotMentions = slotMentionsArray.toArray();
		for (FeatureStructure fs : slotMentions) {
			CCPSlotMention ccpSlotMention = (CCPSlotMention) fs;
			if (ccpSlotMention.getMentionName().equals(slotMentionName)) {
				returnSlotMentions.add(ccpSlotMention);
			}
		}
		return returnSlotMentions;
	} else {
		return null;
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:18,代码来源:UIMA_Util.java

示例10: addSlotValue

import org.apache.uima.jcas.cas.FSArray; //导入依赖的package包/类
public static void addSlotValue(CCPClassMention ccpClassMention, String slotMentionName,
		CCPClassMention slotFillerCM) throws CASException {
	CCPComplexSlotMention ccpComplexSlotMention = (CCPComplexSlotMention) UIMA_Util.getSlotMentionByName(
			ccpClassMention, slotMentionName);
	if (ccpComplexSlotMention == null) { // then we need to create a new
		// CCPNonComplexSlotMention
		JCas jcas = ccpClassMention.getCAS().getJCas();
		ccpComplexSlotMention = new CCPComplexSlotMention(jcas);
		ccpComplexSlotMention.setMentionName(slotMentionName);
		FSArray classMentions = new FSArray(jcas, 1);
		classMentions.set(0, slotFillerCM);
		ccpComplexSlotMention.setClassMentions(classMentions);
		addSlotMention(ccpClassMention, ccpComplexSlotMention);
	} else {
		addClassMentionAsCSMSlotFiller(ccpComplexSlotMention, slotFillerCM);
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:18,代码来源:UIMA_Util.java

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

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

示例13: createCCPTextAnnotation

import org.apache.uima.jcas.cas.FSArray; //导入依赖的package包/类
public static CCPTextAnnotation createCCPTextAnnotation(String mentionType, int[] span, JCas jcas,
		CCPAnnotator annotatorInfo, CCPAnnotationSet annotationSetInfo) {
	CCPTextAnnotation ccpTA = new CCPTextAnnotation(jcas);
	int startIndex = span[0];
	int endIndex = span[1];
	ccpTA.setBegin(startIndex);
	ccpTA.setEnd(endIndex);
	/* create span */
	FSArray ccpSpans = new FSArray(jcas, 1);
	CCPSpan ccpSpan = new CCPSpan(jcas);
	ccpSpan.setSpanStart(startIndex);
	ccpSpan.setSpanEnd(endIndex);
	ccpSpans.set(0, ccpSpan);
	ccpTA.setSpans(ccpSpans);
	ccpTA.setAnnotator(annotatorInfo);
	FSArray asets = new FSArray(jcas, 1);
	asets.set(0, annotationSetInfo);
	ccpTA.setAnnotationSets(asets);
	ccpTA.setDocumentSectionID(-1);
	CCPClassMention ccpCM = new CCPClassMention(jcas);
	ccpCM.setMentionName(mentionType);
	ccpTA.setClassMention(ccpCM);
	ccpCM.setCcpTextAnnotation(ccpTA);
	ccpTA.addToIndexes();
	return ccpTA;
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:27,代码来源:UIMA_Annotation_Util.java

示例14: 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.");
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:32,代码来源:UIMA_Annotation_Util.java

示例15: getLeadingSpan

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 getLeadingSpan(CCPTextAnnotation ccpTA) throws KnowledgeRepresentationWrapperException {
	FSArray spanList = ccpTA.getSpans();
	if (spanList != null && spanList.size() > 0) {
		CCPSpan leadingSpan = getExpectedSpan(spanList.get(0));
		for (int i = 1; i < spanList.size(); i++) {
			CCPSpan span = getExpectedSpan(spanList.get(i));
			if (span.getSpanStart() < leadingSpan.getSpanStart()) {
				leadingSpan = span;
			}
		}
		return leadingSpan;
	} else {
		throw new KnowledgeRepresentationWrapperException(
				"Cannot get leading span, the CCPTextAnnotation has no span list.");
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:29,代码来源:UIMA_Annotation_Util.java


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