本文整理了Java中de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence.getCAS()
方法的一些代码示例,展示了Sentence.getCAS()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sentence.getCAS()
方法的具体详情如下:
包路径:de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence
类名称:Sentence
方法名:getCAS
暂无
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.io.penntree-asl
public Constituent convertPennTree(Sentence aSentence, PennTreeNode aNode)
{
JCas jcas;
try {
jcas = aSentence.getCAS().getJCas();
}
catch (CASException e) {
throw new IllegalStateException(e);
}
List<Token> tokens = selectCovered(Token.class, aSentence);
List<PennTreeNode> preTerminalNodes = PennTreeUtils.getPreTerminals(aNode);
Map<PennTreeNode, Token> tokenMap = new HashMap<>();
for (int i = 0; i < tokens.size(); i++) {
tokenMap.put(preTerminalNodes.get(i), tokens.get(i));
}
return convertPennTree(jcas, aNode, null, tokenMap);
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-ui-automation
private static List<String> getAnnotation(TypeAdapter aAdapter, Sentence aSentence,
AnnotationFeature aFeature)
{
CAS cas = aSentence.getCAS();
Type type = getType(cas, aAdapter.getAnnotationTypeName());
List<String> annotations = new ArrayList<>();
for (Token token : selectCovered(Token.class, aSentence)) {
List<AnnotationFS> tokenLevelAnnotations = selectCovered(type, token);
if (tokenLevelAnnotations.size() > 0) {
AnnotationFS anno = tokenLevelAnnotations.get(0);
Feature labelFeature = anno.getType().getFeatureByBaseName(aFeature.getName());
annotations.add(anno.getFeatureValueAsString(labelFeature));
}
else {
annotations.add(NILL);
}
}
return annotations;
}
}
代码示例来源:origin: webanno/webanno
private static List<String> getAnnotation(TypeAdapter aAdapter, Sentence aSentence,
AnnotationFeature aFeature)
{
CAS cas = aSentence.getCAS();
Type type = getType(cas, aAdapter.getAnnotationTypeName());
List<String> annotations = new ArrayList<>();
for (Token token : selectCovered(Token.class, aSentence)) {
List<AnnotationFS> tokenLevelAnnotations = selectCovered(type, token);
if (tokenLevelAnnotations.size() > 0) {
AnnotationFS anno = tokenLevelAnnotations.get(0);
Feature labelFeature = anno.getType().getFeatureByBaseName(aFeature.getName());
annotations.add(anno.getFeatureValueAsString(labelFeature));
}
else {
annotations.add(NILL);
}
}
return annotations;
}
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat
public Map<Integer, String> getMultipleAnnotation(Sentence sentence, AnnotationFeature aFeature)
throws CASException
{
Map<Integer, String> multAnno = new HashMap<Integer, String>();
Type type = getType(sentence.getCAS(), getAnnotationTypeName());
for (AnnotationFS fs : selectCovered(sentence.getCAS(), type, sentence.getBegin(),
sentence.getEnd())) {
boolean isBegin = true;
Feature labelFeature = fs.getType().getFeatureByBaseName(aFeature.getName());
for (Token token : selectCovered(sentence.getCAS().getJCas(), Token.class,
fs.getBegin(), fs.getEnd())) {
if (multAnno.get(token.getAddress()) == null) {
if (isBegin) {
multAnno.put(token.getAddress(),
"B-" + fs.getFeatureValueAsString(labelFeature));
isBegin = false;
}
else {
multAnno.put(token.getAddress(),
"I-" + fs.getFeatureValueAsString(labelFeature));
}
}
}
}
return multAnno;
}
代码示例来源:origin: webanno/webanno
public static Map<Integer, String> getMultipleAnnotation(
AnnotationSchemaService aAnnotationService, Sentence sentence,
AnnotationFeature aFeature)
throws CASException
{
SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aFeature.getLayer());
Map<Integer, String> multAnno = new HashMap<>();
Type type = getType(sentence.getCAS(), adapter.getAnnotationTypeName());
for (AnnotationFS fs : selectCovered(type, sentence)) {
boolean isBegin = true;
Feature labelFeature = fs.getType().getFeatureByBaseName(aFeature.getName());
for (Token token : selectCovered(Token.class, fs)) {
if (multAnno.get(getAddr(token)) == null) {
if (isBegin) {
multAnno.put(getAddr(token),
"B-" + fs.getFeatureValueAsString(labelFeature));
isBegin = false;
}
else {
multAnno.put(getAddr(token),
"I-" + fs.getFeatureValueAsString(labelFeature));
}
}
}
}
return multAnno;
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-ui-automation
public static Map<Integer, String> getMultipleAnnotation(
AnnotationSchemaService aAnnotationService, Sentence sentence,
AnnotationFeature aFeature)
throws CASException
{
SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aFeature.getLayer());
Map<Integer, String> multAnno = new HashMap<>();
Type type = getType(sentence.getCAS(), adapter.getAnnotationTypeName());
for (AnnotationFS fs : selectCovered(type, sentence)) {
boolean isBegin = true;
Feature labelFeature = fs.getType().getFeatureByBaseName(aFeature.getName());
for (Token token : selectCovered(Token.class, fs)) {
if (multAnno.get(getAddr(token)) == null) {
if (isBegin) {
multAnno.put(getAddr(token),
"B-" + fs.getFeatureValueAsString(labelFeature));
isBegin = false;
}
else {
multAnno.put(getAddr(token),
"I-" + fs.getFeatureValueAsString(labelFeature));
}
}
}
}
return multAnno;
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-annotation
@Override
public void setFirstVisibleUnit(Sentence aFirstVisibleUnit)
{
JCas jcas;
try {
jcas = aFirstVisibleUnit.getCAS().getJCas();
}
catch (CASException e) {
throw new IllegalStateException("Unable to fetch JCas from CAS", e);
}
firstVisibleUnitAddress = WebAnnoCasUtil.getAddr(aFirstVisibleUnit);
firstVisibleUnitBegin = aFirstVisibleUnit.getBegin();
firstVisibleUnitEnd = aFirstVisibleUnit.getEnd();
Sentence lastVisibleUnit = getLastSentenceInDisplayWindow(jcas, getAddr(aFirstVisibleUnit),
getPreferences().getWindowSize());
firstVisibleUnitIndex = WebAnnoCasUtil.getSentenceNumber(jcas,
aFirstVisibleUnit.getBegin());
lastVisibleUnitIndex = WebAnnoCasUtil.getSentenceNumber(jcas, lastVisibleUnit.getBegin());
unitCount = select(jcas, Sentence.class).size();
windowBeginOffset = aFirstVisibleUnit.getBegin();
windowEndOffset = lastVisibleUnit.getEnd();
}
代码示例来源:origin: webanno/webanno
@Override
public void setFirstVisibleUnit(Sentence aFirstVisibleUnit)
{
JCas jcas;
try {
jcas = aFirstVisibleUnit.getCAS().getJCas();
}
catch (CASException e) {
throw new IllegalStateException("Unable to fetch JCas from CAS", e);
}
firstVisibleUnitAddress = WebAnnoCasUtil.getAddr(aFirstVisibleUnit);
firstVisibleUnitBegin = aFirstVisibleUnit.getBegin();
firstVisibleUnitEnd = aFirstVisibleUnit.getEnd();
Sentence lastVisibleUnit = getLastSentenceInDisplayWindow(jcas, getAddr(aFirstVisibleUnit),
getPreferences().getWindowSize());
firstVisibleUnitIndex = WebAnnoCasUtil.getSentenceNumber(jcas,
aFirstVisibleUnit.getBegin());
lastVisibleUnitIndex = WebAnnoCasUtil.getSentenceNumber(jcas, lastVisibleUnit.getBegin());
unitCount = select(jcas, Sentence.class).size();
windowBeginOffset = aFirstVisibleUnit.getBegin();
windowEndOffset = lastVisibleUnit.getEnd();
}
内容来源于网络,如有侵权,请联系作者删除!