本文整理了Java中org.apache.uima.cas.CAS.removeFsFromIndexes()
方法的一些代码示例,展示了CAS.removeFsFromIndexes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CAS.removeFsFromIndexes()
方法的具体详情如下:
包路径:org.apache.uima.cas.CAS
类名称:CAS
方法名:removeFsFromIndexes
[英]Remove a feature structure from all indexes in the repository associated with this CAS View. The remove operation removes the exact fs from the indexes, unlike operations such as moveTo which use the fs argument as a template. It is not an error if the FS is not present in the indexes.
[中]从与此CAS视图关联的存储库中的所有索引中删除功能结构。remove操作从索引中移除确切的fs,这与moveTo等使用fs参数作为模板的操作不同。如果索引中不存在FS,则不是错误。
代码示例来源:origin: apache/opennlp
cas.removeFsFromIndexes(it.next());
代码示例来源:origin: apache/opennlp
cas.removeFsFromIndexes(annotation);
代码示例来源:origin: inception-project/inception
private void removePredictions(CAS aCas, Type aPredictionType)
{
for (AnnotationFS fs : CasUtil.select(aCas, aPredictionType)) {
aCas.removeFsFromIndexes(fs);
}
}
代码示例来源:origin: org.apache.uima/textmarker-core
public static void removeSourceDocumentInformation(CAS cas) {
Type sdiType = cas.getTypeSystem()
.getType("org.apache.uima.examples.SourceDocumentInformation");
if (sdiType != null) {
AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex(sdiType);
List<AnnotationFS> toRemove = new ArrayList<AnnotationFS>();
for (AnnotationFS annotationFS : annotationIndex) {
toRemove.add(annotationFS);
}
for (AnnotationFS annotationFS : toRemove) {
cas.removeFsFromIndexes(annotationFS);
}
}
}
代码示例来源:origin: org.apache.uima/ruta-core
public static void removeSourceDocumentInformation(CAS cas) {
Type sdiType = cas.getTypeSystem()
.getType("org.apache.uima.examples.SourceDocumentInformation");
if (sdiType != null) {
AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex(sdiType);
List<AnnotationFS> toRemove = new ArrayList<AnnotationFS>();
for (AnnotationFS annotationFS : annotationIndex) {
toRemove.add(annotationFS);
}
for (AnnotationFS annotationFS : toRemove) {
cas.removeFsFromIndexes(annotationFS);
}
}
}
代码示例来源:origin: org.apache.opennlp/opennlp-uima
cas.removeFsFromIndexes(it.next());
代码示例来源:origin: CLLKazan/UIMA-Ext
private void removeAnnotations(CAS cas, Type t) {
LinkedList<AnnotationFS> annoToRemove = Lists.newLinkedList(cas.getAnnotationIndex(t));
for (AnnotationFS anno : annoToRemove) {
cas.removeFsFromIndexes(anno);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug(String.format(
"%s annotations of type %s have been removed",
annoToRemove.size(), t));
}
}
}
代码示例来源:origin: inception-project/inception
private void removePredictedAnnotations(CAS aCas)
{
Type type = CasUtil.getType(aCas, getPredictedType());
for (AnnotationFS annotationFS : CasUtil.select(aCas, type)) {
aCas.removeFsFromIndexes(annotationFS);
}
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-imls-external
private void removePredictedAnnotations(CAS aCas)
{
Type type = CasUtil.getType(aCas, getPredictedType());
for (AnnotationFS annotationFS : CasUtil.select(aCas, type)) {
aCas.removeFsFromIndexes(annotationFS);
}
}
代码示例来源:origin: org.apache.uima/ruta-core
public Type seed(String text, CAS cas) {
Type result = super.seed(text, cas);
JCas jCas = null;
try {
jCas = cas.getJCas();
} catch (CASException e) {
throw new RuntimeException(e);
}
// FIXME: lexer rules for html markup won't work. Therefore, those rules where removed in the
// grammar and the functionality is included directly with regex
if (text != null) {
Matcher matcher = markupPattern.matcher(text);
Collection<AnnotationFS> toRemove = new LinkedList<AnnotationFS>();
while (matcher.find()) {
int begin = matcher.start();
int end = matcher.end();
MARKUP markup = new MARKUP(jCas, begin, end);
markup.addToIndexes();
List<AnnotationFS> selectCovered = CasUtil.selectCovered(result, markup);
toRemove.addAll(selectCovered);
}
for (AnnotationFS each : toRemove) {
cas.removeFsFromIndexes(each);
}
}
return result;
}
}
代码示例来源:origin: CLLKazan/UIMA-Ext
/**
* {@inheritDoc}
*/
@Override
public void process(CAS cas) throws AnalysisEngineProcessException {
for (AnnotationFS anno : cas.getAnnotationIndex(annoType)) {
String featValue = extractValue(anno);
if (featValue == null) {
return;
}
Matcher matcher = pattern.matcher(featValue);
if (matcher.matches()) {
String newFeatValue = matcher.replaceAll(replaceBy);
if (!newFeatValue.equals(featValue)) {
cas.removeFsFromIndexes(anno);
setValue(anno, newFeatValue);
cas.addFsToIndexes(anno);
getLogger().info(String.format(
"Replacement done for feature %s.%s: '%s' => '%s'",
annoTypeName, featurePathString, featValue, newFeatValue));
}
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.bananasplit-asl
@Override
public void process(CAS aCas)
throws AnalysisEngineProcessException
{
Collection<FeatureStructure> toAdd = new ArrayList<FeatureStructure>();
Collection<FeatureStructure> toRemove = new ArrayList<FeatureStructure>();
Type type = aCas.getTypeSystem().getType(tokenType);
for (AnnotationFS token : select(aCas, type)) {
split(aCas, token, token.getCoveredText(), toAdd, toRemove);
}
for (FeatureStructure a : toAdd) {
aCas.addFsToIndexes(a);
}
for (FeatureStructure a : toRemove) {
aCas.removeFsFromIndexes(a);
}
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.jwordsplitter-asl
@Override
public void process(CAS aCas)
throws AnalysisEngineProcessException
{
Collection<FeatureStructure> toAdd = new ArrayList<FeatureStructure>();
Collection<FeatureStructure> toRemove = new ArrayList<FeatureStructure>();
Type type = aCas.getTypeSystem().getType(tokenType);
for (AnnotationFS token : select(aCas, type)) {
split(aCas, token, token.getCoveredText(), toAdd, toRemove);
}
for (FeatureStructure a : toAdd) {
aCas.addFsToIndexes(a);
}
for (FeatureStructure a : toRemove) {
aCas.removeFsFromIndexes(a);
}
}
代码示例来源:origin: nlpie/biomedicus
@Nullable
@Override
public String put(String key, String value) {
FeatureStructure check = metadataCas.createFS(metadataType);
check.setStringValue(keyFeature, key);
FeatureStructure fs = metadataIndex.find(check);
String existing = null;
if (fs != null) {
existing = fs.getStringValue(valueFeature);
metadataCas.removeFsFromIndexes(fs);
} else {
fs = check;
}
fs.setStringValue(valueFeature, value);
metadataCas.addFsToIndexes(fs);
return existing;
}
代码示例来源:origin: org.apache.uima/textmarker-core
cas.removeFsFromIndexes(toSplit);
toSplit.setEnd(anchor);
TextMarkerBasic newTMB = new TextMarkerBasic(getJCas(), anchor, newEnd);
代码示例来源:origin: org.apache.uima/textmarker-core
@Override
public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
InferenceCrowd crowd) {
List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(stream, null,
element.getContainer());
for (AnnotationFS matchedAnnotation : matchedAnnotations) {
if (matchedAnnotation == null) {
return;
}
Type type = getStructureType().getType(element.getParent());
List<AnnotationFS> list = stream.getAnnotationsInWindow(matchedAnnotation, type);
if (list.isEmpty()) {
list = stream.getOverappingAnnotations(matchedAnnotation, type);
}
//
// for (AnnotationFS each : list) {
// fillFeatures((Annotation)each, features, matchedAnnotation, element, stream);
// }
if (!list.isEmpty()) {
AnnotationFS annotationFS = list.get(0);
stream.getCas().removeFsFromIndexes(annotationFS);
fillFeatures((Annotation) annotationFS, features, matchedAnnotation, element, stream);
stream.getCas().addFsToIndexes(annotationFS);
}
}
}
代码示例来源:origin: org.apache.uima/ruta-core
public void removeAnnotation(AnnotationFS annotation, Type type) {
if (type.getName().equals(CAS.TYPE_NAME_DOCUMENT_ANNOTATION)) {
// do not remove DocumentAnnotation
return;
}
Collection<RutaBasic> basicAnnotationsInWindow = getAllBasicsInWindow(annotation);
for (RutaBasic basic : basicAnnotationsInWindow) {
basic.removePartOf(type);
}
Type parent = type;
RutaBasic beginAnchor = getBeginAnchor(annotation.getBegin());
RutaBasic endAnchor = getEndAnchor(annotation.getEnd());
if (beginAnchor != null) {
beginAnchor.removeBegin(annotation, parent);
}
if (endAnchor != null) {
endAnchor.removeEnd(annotation, parent);
}
if (!(annotation instanceof RutaBasic)) {
cas.removeFsFromIndexes(annotation);
}
}
代码示例来源:origin: org.apache.uima/textmarker-core
public void removeAnnotation(AnnotationFS annotation, Type type) {
Collection<TextMarkerBasic> basicAnnotationsInWindow = getAllBasicsInWindow(annotation);
for (TextMarkerBasic basic : basicAnnotationsInWindow) {
basic.removePartOf(type);
}
Type parent = type;
TextMarkerBasic beginAnchor = getBeginAnchor(annotation.getBegin());
TextMarkerBasic endAnchor = getEndAnchor(annotation.getEnd());
beginAnchor.removeBegin(annotation, parent);
endAnchor.removeEnd(annotation, parent);
if (!(annotation instanceof TextMarkerBasic)) {
cas.removeFsFromIndexes(annotation);
}
}
代码示例来源:origin: org.apache.uima/ruta-core
@Override
public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) {
RuleMatch match = context.getRuleMatch();
RuleElement element = context.getElement();
element.getParent();
String featureString = featureStringExpression.getStringValue(context, stream);
List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOfElement(element);
for (AnnotationFS annotationFS : matchedAnnotations) {
Feature feature = annotationFS.getType().getFeatureByBaseName(featureString);
if (feature != null) {
stream.getCas().removeFsFromIndexes(annotationFS);
stream.assignFeatureValue(annotationFS, feature, expr, context);
stream.getCas().addFsToIndexes(annotationFS);
} else {
throw new IllegalArgumentException("Not able to assign feature value (e.g., coveredText).");
}
}
}
代码示例来源:origin: org.apache.uima/ruta-core
private void splitAnnotationOnComplete(Annotation annotation, Type typeToSplit,
boolean addToBegin, boolean addToEnd, RuleMatch match, RutaStream stream) {
List<AnnotationFS> annotationsInWindow = stream.getAnnotationsInWindow(annotation, typeToSplit);
if (annotationsInWindow == null || annotationsInWindow.isEmpty()) {
return;
}
CAS cas = annotation.getCAS();
CasCopier cc = new CasCopier(cas, cas);
cas.removeFsFromIndexes(annotation);
int overallEnd = annotation.getEnd();
Annotation first = annotation;
for (AnnotationFS each : annotationsInWindow) {
int firstEnd = addToEnd ? each.getEnd() : each.getBegin();
first.setEnd(firstEnd);
boolean valid = trimInvisible(first, stream);
if (valid) {
stream.addAnnotation(first, true, true, match);
}
Annotation second = (Annotation) cc.copyFs(first);
int secondBegin = addToBegin ? each.getBegin() : each.getEnd();
second.setBegin(secondBegin);
second.setEnd(overallEnd);
valid = trimInvisible(second, stream);
if (valid) {
stream.addAnnotation(second, true, true, match);
}
first = second;
}
}
内容来源于网络,如有侵权,请联系作者删除!