本文整理了Java中org.apache.uima.cas.CAS.getDocumentAnnotation()
方法的一些代码示例,展示了CAS.getDocumentAnnotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CAS.getDocumentAnnotation()
方法的具体详情如下:
包路径:org.apache.uima.cas.CAS
类名称:CAS
方法名:getDocumentAnnotation
[英]Get the Document Annotation. The Document Annotation has a string-valued feature called "language" where the document language is specified.
[中]获取文档注释。文档注释有一个称为“语言”的字符串值功能,其中指定了文档语言。
代码示例来源:origin: org.apache.uima/uimafit-core
private void processDocumentMetadata(CAS aCAS) {
if (!writeDocumentMetaData) {
return;
}
processFeatureStructure(aCAS.getDocumentAnnotation());
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.testing-asl
private void processDocumentMetadata(CAS aCAS)
{
if (!writeDocumentMetaData) {
return;
}
processFeatureStructure(aCAS.getDocumentAnnotation());
}
代码示例来源:origin: dkpro/dkpro-core
private void processDocumentMetadata(CAS aCAS)
{
if (!writeDocumentMetaData) {
return;
}
processFeatureStructure(aCAS.getDocumentAnnotation());
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl
/**
* Determines whether the given FS is the DocumentAnnotation for its view. This is more than
* just a type check; we actually check if it is the one "special" DocumentAnnotation that
* CAS.getDocumentAnnotation() would return.
*/
private static boolean isDocumentAnnotation(FeatureStructure aFS)
{
return (aFS instanceof AnnotationFS)
&& aFS.equals(((AnnotationFS) aFS).getView().getDocumentAnnotation());
}
代码示例来源:origin: org.apache.uima/uimafit-core
private Set<String> getTypes(CAS cas) {
Set<String> types = new HashSet<String>();
Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator();
nextType: while (typeIt.hasNext()) {
Type type = typeIt.next();
if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) {
continue;
}
for (InExPattern p : cookedTypePatterns) {
p.matchter.reset(type.getName());
if (p.matchter.matches()) {
if (p.includeInOutput) {
types.add(type.getName());
} else {
types.remove(type.getName());
}
continue nextType;
}
}
}
return types;
}
代码示例来源:origin: dkpro/dkpro-core
private Set<String> getTypes(CAS cas)
{
Set<String> types = new HashSet<String>();
Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator();
nextType: while (typeIt.hasNext()) {
Type type = typeIt.next();
if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) {
continue;
}
for (InExPattern p : cookedTypePatterns) {
p.matchter.reset(type.getName());
if (p.matchter.matches()) {
if (p.includeInOutput) {
types.add(type.getName());
}
else {
types.remove(type.getName());
}
continue nextType;
}
}
}
return types;
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.testing-asl
private Set<String> getTypes(CAS cas)
{
Set<String> types = new HashSet<String>();
Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator();
nextType: while (typeIt.hasNext()) {
Type type = typeIt.next();
if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) {
continue;
}
for (InExPattern p : cookedTypePatterns) {
p.matchter.reset(type.getName());
if (p.matchter.matches()) {
if (p.includeInOutput) {
types.add(type.getName());
}
else {
types.remove(type.getName());
}
continue nextType;
}
}
}
return types;
}
代码示例来源:origin: org.apache.uima/textmarker-core
public static void addSourceDocumentInformation(CAS cas, File each) {
Type sdiType = cas.getTypeSystem()
.getType("org.apache.uima.examples.SourceDocumentInformation");
if (sdiType != null) {
if (cas.getAnnotationIndex(sdiType).size() == 0) {
AnnotationFS sdi = cas.createAnnotation(sdiType, cas.getDocumentAnnotation().getBegin(),
cas.getDocumentAnnotation().getEnd());
Feature uriFeature = sdiType.getFeatureByBaseName("uri");
sdi.setStringValue(uriFeature, each.toURI().getPath());
cas.addFsToIndexes(sdi);
}
}
}
代码示例来源:origin: org.apache.uima/ruta-core
public static void addSourceDocumentInformation(CAS cas, File each) {
Type sdiType = cas.getTypeSystem()
.getType("org.apache.uima.examples.SourceDocumentInformation");
if (sdiType != null) {
if (cas.getAnnotationIndex(sdiType).size() == 0) {
AnnotationFS sdi = cas.createAnnotation(sdiType, cas.getDocumentAnnotation().getBegin(),
cas.getDocumentAnnotation().getEnd());
Feature uriFeature = sdiType.getFeatureByBaseName("uri");
sdi.setStringValue(uriFeature, each.toURI().getPath());
cas.addFsToIndexes(sdi);
}
}
}
代码示例来源:origin: org.apache.uima/ruta-core-ext
@Override
public ScriptApply apply(RutaStream stream, InferenceCrowd crowd) {
CAS cas = stream.getCas();
AnnotationFS documentAnnotation = cas.getDocumentAnnotation();
RutaStream completeStream = stream.getWindowStream(documentAnnotation, documentAnnotation.getType());
ScriptApply result = super.apply(completeStream, crowd);
return result;
}
代码示例来源:origin: org.apache.uima/ruta-core
protected RutaStream(CAS cas, Type basicType, NavigableMap<Integer, RutaBasic> beginAnchors,
NavigableMap<Integer, RutaBasic> endAnchors, FilterManager filter,
boolean lowMemoryProfile, boolean simpleGreedyForComposed, boolean emptyIsInvisible,
TypeUsageInformation typeUsage, InferenceCrowd crowd) {
super();
this.cas = cas;
this.beginAnchors = beginAnchors;
this.endAnchors = endAnchors;
this.filter = filter;
this.basicType = basicType;
this.lowMemoryProfile = lowMemoryProfile;
this.simpleGreedyForComposed = simpleGreedyForComposed;
this.emptyIsInvisible = emptyIsInvisible;
this.typeUsage = typeUsage;
this.crowd = crowd;
AnnotationFS additionalWindow = filter.getWindowAnnotation();
updateIterators(cas, basicType, filter, additionalWindow);
// really an if? sub it of basic should fix this
if (additionalWindow == null) {
documentAnnotation = cas.getDocumentAnnotation();
documentAnnotationType = getCas().getDocumentAnnotation().getType();
basicIt.moveToFirst();
} else {
documentAnnotation = additionalWindow;
documentAnnotationType = filter.getWindowType();
}
}
代码示例来源:origin: org.apache.uima/ruta-core
public Collection<RutaBasic> getAllBasicsInWindow(AnnotationFS windowAnnotation) {
if (windowAnnotation.getBegin() >= windowAnnotation.getEnd()) {
return Collections.emptySet();
}
RutaBasic beginAnchor = getBeginAnchor(windowAnnotation.getBegin());
if (beginAnchor != null && beginAnchor.getEnd() == windowAnnotation.getEnd()) {
Collection<RutaBasic> result = new ArrayList<RutaBasic>(1);
result.add(beginAnchor);
return result;
}
Collection<RutaBasic> subSet = null;
if (windowAnnotation.getEnd() == cas.getDocumentAnnotation().getEnd()
&& windowAnnotation.getBegin() == 0) {
subSet = beginAnchors.values();
} else {
subSet = beginAnchors
.subMap(windowAnnotation.getBegin(), true, windowAnnotation.getEnd(), false).values();
}
return subSet;
}
代码示例来源:origin: org.apache.uima/uimaj-cpe
/**
* Gets the feature as int.
*
* @param aCas the a cas
* @param aFeature the a feature
* @param aName the a name
* @return the feature as int
* @throws Exception the exception
*/
public static int getFeatureAsInt(CAS aCas, Feature aFeature, String aName) throws Exception {
Feature seqNo2 = aFeature.getRange().getFeatureByBaseName(aName);
FeatureStructure documentMetaData = aCas.getView(CAS.NAME_DEFAULT_SOFA).getDocumentAnnotation()
.getFeatureValue(aFeature);
return documentMetaData.getIntValue(seqNo2);
}
代码示例来源:origin: org.apache.uima/ruta-core
AnnotationFS documentAnnotation = stream.getCas().getDocumentAnnotation();
Type docType = documentAnnotation.getType();
if (docType.equals(type)) {
代码示例来源:origin: org.apache.uima/ruta-core
return Collections.emptyList();
Type overallDAType = stream.getCas().getDocumentAnnotation().getType();
String name = type.getName();
if (StringUtils.equals(CAS.TYPE_NAME_DOCUMENT_ANNOTATION, name)
代码示例来源:origin: org.apache.uima/uimaj-cpe
/**
* Returns a value associated with a given feature.
*
* @param aCas -
* Cas containing data to extract
* @param aFeature -
* feature to locate in the CAS
* @param aName -
* name of the feature
* @return - value as String
* @throws Exception the exception
*/
public static String getFeatureAsString(CAS aCas, Feature aFeature, String aName)
throws Exception {
Feature seqNo2 = aFeature.getRange().getFeatureByBaseName(aName);
FeatureStructure documentMetaData = aCas.getView(CAS.NAME_DEFAULT_SOFA).getDocumentAnnotation()
.getFeatureValue(aFeature);
return documentMetaData.getStringValue(seqNo2);
}
代码示例来源:origin: org.apache.uima/ruta-core
public Collection<AnnotationFS> getAnnotations(Type type) {
Collection<AnnotationFS> result = new LinkedList<AnnotationFS>();
AnnotationFS windowAnnotation = filter.getWindowAnnotation();
if (windowAnnotation != null
&& (windowAnnotation.getBegin() != cas.getDocumentAnnotation().getBegin()
|| windowAnnotation.getEnd() != cas.getDocumentAnnotation().getEnd())) {
AnnotationFS frame = cas.createAnnotation(cas.getTypeSystem().getType(RutaEngine.FRAME_TYPE),
windowAnnotation.getBegin(), windowAnnotation.getEnd());
FSIterator<AnnotationFS> subiterator = cas.getAnnotationIndex(type).subiterator(frame);
while (subiterator.hasNext()) {
AnnotationFS each = subiterator.next();
if (isVisible(each)) {
result.add(each);
}
}
} else {
AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex(type);
for (AnnotationFS each : annotationIndex) {
if (isVisible(each)) {
result.add(each);
}
}
}
return result;
}
代码示例来源:origin: org.apache.uima/ruta-core
public AnnotationFS getVeryFirstBeforeWindow(boolean direction) {
if (direction) {
RutaBasic firstBasicOfAll = getFirstBasicOfAll();
int begin = firstBasicOfAll.getBegin();
if (begin == 0) {
return documentBeginAnchor;
} else {
return getEndAnchor(begin);
}
} else {
RutaBasic lastBasicOfAll = getLastBasicOfAll();
int end = lastBasicOfAll.getEnd();
if (end == cas.getDocumentAnnotation().getEnd()) {
return documentEndAnchor;
} else {
return getBeginAnchor(end);
}
}
}
代码示例来源:origin: org.apache.uima/ruta-core
public RutaStream(CAS cas, Type basicType, FilterManager filter, boolean lowMemoryProfile,
boolean simpleGreedyForComposed, boolean emptyIsInvisible, TypeUsageInformation typeUsage,
InferenceCrowd crowd) {
super();
this.cas = cas;
this.filter = filter;
this.basicType = basicType;
this.lowMemoryProfile = lowMemoryProfile;
this.simpleGreedyForComposed = simpleGreedyForComposed;
this.emptyIsInvisible = emptyIsInvisible;
this.typeUsage = typeUsage;
this.crowd = crowd;
AnnotationFS additionalWindow = filter.getWindowAnnotation();
updateIterators(cas, basicType, filter, additionalWindow);
// really an if? sub it of basic should fix this
if (additionalWindow == null) {
documentAnnotation = cas.getDocumentAnnotation();
documentAnnotationType = getCas().getDocumentAnnotation().getType();
basicIt.moveToFirst();
documentBeginAnchor = new RutaOptional(getJCas(), 0, 0);
documentEndAnchor = new RutaOptional(getJCas(), documentAnnotation.getEnd(),
documentAnnotation.getEnd());
} else {
documentAnnotation = additionalWindow;
documentAnnotationType = filter.getWindowType();
}
}
代码示例来源:origin: org.apache.uima/ruta-core
final int mappedEnd = map[clone.getEnd()];
if (mappedBegin < mappedEnd) {
if (mappedEnd > fromJcas.getCas().getDocumentAnnotation().getEnd()) {
getContext().getLogger().log(Level.WARNING, "illegal annotation offset mapping");
} else {
int max = modview.getCas().getDocumentAnnotation().getEnd();
if (mappedBegin < max && mappedEnd <= max && mappedBegin >= 0 && mappedEnd > 0) {
clone.setBegin(mappedBegin);
内容来源于网络,如有侵权,请联系作者删除!