本文整理汇总了Java中org.apache.uima.fit.util.CasUtil.selectCovered方法的典型用法代码示例。如果您正苦于以下问题:Java CasUtil.selectCovered方法的具体用法?Java CasUtil.selectCovered怎么用?Java CasUtil.selectCovered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.fit.util.CasUtil
的用法示例。
在下文中一共展示了CasUtil.selectCovered方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAllRoleAnnosOnPosition
import org.apache.uima.fit.util.CasUtil; //导入方法依赖的package包/类
private static void setAllRoleAnnosOnPosition(Map<String, JCas> aJCases,
Map<String, ArrayFS> slotAnnosPerUser, Set<String> aUsers, FeatureStructure aBaseAnno,
Feature aFeature)
{
Type t = aBaseAnno.getType();
int begin = ((AnnotationFS) aBaseAnno).getBegin();
int end = ((AnnotationFS) aBaseAnno).getEnd();
for (String usr : aUsers) {
for (FeatureStructure baseFS : CasUtil.selectCovered(aJCases.get(usr).getCas(), t,
begin, end)) {
// if non eqal stacked annotations with slot feature exists, get
// the right one
if (isSameAnno(aBaseAnno, baseFS)) {
ArrayFS roleFs = (ArrayFS) WebAnnoCasUtil.getFeatureFS(baseFS,
aFeature.getShortName());
slotAnnosPerUser.put(usr, roleFs);
break;
}
}
}
}
示例2: getSpan
import org.apache.uima.fit.util.CasUtil; //导入方法依赖的package包/类
public Serializable getSpan(JCas aJCas, int aBegin, int aEnd, AnnotationFeature aFeature,
String aLabelValue)
{
List<Token> tokens = selectOverlapping(aJCas, Token.class, aBegin, aEnd);
int begin = tokens.get(0).getBegin();
int end = tokens.get(tokens.size() - 1).getEnd();
String baseName = StringUtils.substringBeforeLast(getAnnotationTypeName(), CHAIN) + LINK;
Type linkType = CasUtil.getType(aJCas.getCas(), baseName);
for (AnnotationFS fs : CasUtil.selectCovered(aJCas.getCas(), linkType, begin, end)) {
if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) {
return getFeatureValue(aFeature, fs);
}
}
return null;
}
示例3: processSpan
import org.apache.uima.fit.util.CasUtil; //导入方法依赖的package包/类
private void processSpan(CAS cas, AnnotationFS span) throws AnalysisEngineProcessException {
List<AnnotationFS> tokens = CasUtil.selectCovered(cas, inputTokenType, span);
if (tokens.isEmpty()) return;
if (!(tokens instanceof RandomAccess)) {
tokens = Lists.newArrayList(tokens);
}
List<String> tokenNorms = Lists.transform(tokens, normFunction);
Set<Chunk<V>> matches = dictMatcher.chunks(tokenNorms);
if (matches == null) return;
for (Chunk<V> m : matches) {
AnnotationFS mFirstToken = tokens.get(m.start());
AnnotationFS mLastToken = tokens.get(m.end());
makeResultAnnotation(mFirstToken, mLastToken, m.metadata());
}
}
示例4: createAnnotation
import org.apache.uima.fit.util.CasUtil; //导入方法依赖的package包/类
/**
* A Helper method to add annotation to CAS
*/
private Integer createAnnotation(AnnotatorState aState, CAS aCas, int aBegin, int aEnd)
throws AnnotationException
{
// If stacking is not allowed and there already is an annotation, then return the address
// of the existing annotation.
Type type = CasUtil.getType(aCas, getAnnotationTypeName());
for (AnnotationFS fs : CasUtil.selectCovered(aCas, type, aBegin, aEnd)) {
if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) {
if (!allowStacking) {
return getAddr(fs);
}
}
}
AnnotationFS newAnnotation = aCas.createAnnotation(type, aBegin, aEnd);
// If if the layer attaches to a feature, then set the attach-feature to the newly
// created annotation.
if (getAttachFeatureName() != null) {
Type theType = CasUtil.getType(aCas, getAttachTypeName());
Feature attachFeature = theType.getFeatureByBaseName(getAttachFeatureName());
if (CasUtil.selectCovered(aCas, theType, aBegin, aEnd).isEmpty()) {
throw new AnnotationException("No annotation of type [" + getAttachTypeName()
+ "] to attach to at location [" + aBegin + "-" + aEnd + "].");
}
CasUtil.selectCovered(aCas, theType, aBegin, aEnd).get(0)
.setFeatureValue(attachFeature, newAnnotation);
}
aCas.addFsToIndexes(newAnnotation);
publishEvent(new SpanCreatedEvent(this, aState.getDocument(),
aState.getUser().getUsername(), newAnnotation));
return getAddr(newAnnotation);
}
示例5: delete
import org.apache.uima.fit.util.CasUtil; //导入方法依赖的package包/类
@Override
public void delete(AnnotatorState aState, JCas aJCas, AnnotationFeature aFeature, int aBegin,
int aEnd, Object aValue)
{
Type type = CasUtil.getType(aJCas.getCas(), getAnnotationTypeName());
for (AnnotationFS fs : CasUtil.selectCovered(aJCas.getCas(), type, aBegin, aEnd)) {
if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) {
if (ObjectUtils.equals(getFeatureValue(aFeature, fs), aValue)) {
delete(aState, aJCas, new VID(getAddr(fs)));
}
}
}
}
示例6: selectAt
import org.apache.uima.fit.util.CasUtil; //导入方法依赖的package包/类
public static List<AnnotationFS> selectAt(CAS aJcas, final Type type, int aBegin, int aEnd)
{
List<AnnotationFS> covered = CasUtil.selectCovered(aJcas, type, aBegin, aEnd);
// Remove all that do not have the exact same offset
covered.removeIf(cur -> !(cur.getBegin() == aBegin && cur.getEnd() == aEnd));
return covered;
}
示例7: selectAt
import org.apache.uima.fit.util.CasUtil; //导入方法依赖的package包/类
public static List<AnnotationFS> selectAt(CAS aJcas, final Type type, int aBegin, int aEnd)
{
List<AnnotationFS> covered = CasUtil.selectCovered(aJcas, type, aBegin, aEnd);
// Remove all that do not have the exact same offset
covered.removeIf(cur -> !(cur.getBegin() == aBegin && cur.getEnd() == aEnd));
return covered;
}
示例8: getAnnosOnPosition
import org.apache.uima.fit.util.CasUtil; //导入方法依赖的package包/类
public static List<AnnotationFS> getAnnosOnPosition(AnnotationFS aFs, JCas aJcas)
{
Type type = aFs.getType();
return CasUtil.selectCovered(aJcas.getCas(), type, aFs.getBegin(), aFs.getEnd());
}