本文整理汇总了Java中de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence.getEnd方法的典型用法代码示例。如果您正苦于以下问题:Java Sentence.getEnd方法的具体用法?Java Sentence.getEnd怎么用?Java Sentence.getEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence
的用法示例。
在下文中一共展示了Sentence.getEnd方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
@Override
public void process(JCas aJCas)
throws AnalysisEngineProcessException
{
for (Sentence sent : JCasUtil.select(aJCas, Sentence.class)) {
TextClassificationSequence sequence = new TextClassificationSequence(aJCas,
sent.getBegin(), sent.getEnd());
sequence.addToIndexes();
List<Token> tokens = JCasUtil.selectCovered(aJCas, Token.class, sent);
for (Token token : tokens) {
TextClassificationTarget target = new TextClassificationTarget(aJCas, token.getBegin(),
token.getEnd());
target.setId(tcId++);
target.setSuffix(token.getCoveredText());
target.addToIndexes();
TextClassificationOutcome outcome = new TextClassificationOutcome(aJCas,
token.getBegin(), token.getEnd());
outcome.setOutcome(getTextClassificationOutcome(aJCas, target));
outcome.addToIndexes();
}
}
}
示例2: setFirstVisibleUnit
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
@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();
}
示例3: getSentenceNumber
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
/**
* Get the sentence number at this specific position
*
* @param aJcas
* the JCas.
* @param aBeginOffset
* the begin offset.
* @return the sentence number.
*/
public static int getSentenceNumber(JCas aJcas, int aBeginOffset)
{
int sentenceNumber = 0;
Collection<Sentence> sentences = select(aJcas, Sentence.class);
if (sentences.isEmpty()) {
throw new IndexOutOfBoundsException("No sentences");
}
for (Sentence sentence : select(aJcas, Sentence.class)) {
if (sentence.getBegin() <= aBeginOffset && aBeginOffset <= sentence.getEnd()) {
sentenceNumber++;
break;
}
sentenceNumber++;
}
return sentenceNumber;
}
示例4: getSentenceByAnnoEnd
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
/**
* Get a sentence at the end of an annotation
*/
private static Sentence getSentenceByAnnoEnd(List<Sentence> aSentences, int aEnd)
{
int prevEnd = 0;
Sentence sent = null;
for (Sentence sentence : aSentences) {
if (prevEnd >= aEnd) {
return sent;
}
sent = sentence;
prevEnd = sent.getEnd();
}
return sent;
}
示例5: isSameSentence
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
/**
* Check if the two given offsets are within the same sentence.
*
* @param aJcas
* the JCAs.
* @param aReferenceOffset
* the reference offset.
* @param aCompareOffset
* the comparison offset.
* @return if the two offsets are within the same sentence.
*/
public static boolean isSameSentence(JCas aJcas, int aReferenceOffset, int aCompareOffset)
{
// Trivial case
if (aReferenceOffset == aCompareOffset) {
return true;
}
int offset1 = Math.min(aReferenceOffset, aCompareOffset);
int offset2 = Math.max(aReferenceOffset, aCompareOffset);
// Scanning through sentences
Iterator<Sentence> si = JCasUtil.iterator(aJcas, Sentence.class);
while (si.hasNext()) {
Sentence s = si.next();
if (s.getBegin() <= offset1 && offset1 <= s.getEnd()) {
return s.getBegin() <= offset2 && offset2 <= s.getEnd();
}
// Sentences are sorted. When we hit the first sentence that is beyond the reference
// offset, we will never again find a sentence that contains it.
if (offset1 < s.getBegin()) {
return false;
}
}
return false;
}
示例6: getCurrentSentence
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
/**
* Get the current sentence based on the annotation begin/end offset
*
* @param aJCas
* the JCas.
* @param aBegin
* the begin offset.
* @param aEnd
* the end offset.
* @return the sentence.
*/
public static Sentence getCurrentSentence(JCas aJCas, int aBegin, int aEnd)
{
Sentence currentSentence = null;
for (Sentence sentence : select(aJCas, Sentence.class)) {
if (sentence.getBegin() <= aBegin && sentence.getEnd() > aBegin
&& sentence.getEnd() <= aEnd) {
currentSentence = sentence;
break;
}
}
return currentSentence;
}
示例7: getSentence
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
/**
* Get the sentence based on the annotation begin offset
*
* @param aJCas
* the JCas.
* @param aBegin
* the begin offset.
* @return the sentence.
*/
public static Sentence getSentence(JCas aJCas, int aBegin)
{
Sentence currentSentence = null;
for (Sentence sentence : select(aJCas, Sentence.class)) {
if (sentence.getBegin() <= aBegin && sentence.getEnd() > aBegin) {
currentSentence = sentence;
break;
}
}
return currentSentence;
}
示例8: check
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
@Override
public boolean check(Project aProject, CAS aCas, List<LogMessage> aMessages)
{
try {
boolean ok = true;
for (Token t : select(aCas.getJCas(), Token.class)) {
if (t.getBegin() >= t.getEnd()) {
aMessages.add(new LogMessage(this, LogLevel.ERROR,
"Token with illegal span: %s", t));
ok = false;
}
}
for (Sentence s : select(aCas.getJCas(), Sentence.class)) {
if (s.getBegin() >= s.getEnd()) {
aMessages.add(new LogMessage(this, LogLevel.ERROR,
"Sentence with illegal span: %s", s));
ok = false;
}
}
return ok;
}
catch (CASException e) {
log.error("Unabled to access JCas", e);
aMessages.add(new LogMessage(this, LogLevel.ERROR,
"Unabled to access JCas", e.getMessage()));
return false;
}
}
示例9: process
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
@Override
public void process(JCas aJCas)
throws AnalysisEngineProcessException
{
for (Sentence sentence : JCasUtil.select(aJCas, Sentence.class)) {
// all argument components present in the sentence
List<ArgumentComponent> argumentComponents = ArgumentUtils
.selectOverlappingComponentsWithoutPathosAndImplicit(sentence, aJCas);
// create new sentence-long annotation
BIOSimplifiedSentenceArgumentAnnotation sentenceArgumentAnnotation =
new BIOSimplifiedSentenceArgumentAnnotation(aJCas, sentence.getBegin(),
sentence.getEnd());
sentenceArgumentAnnotation.addToIndexes();
if (argumentComponents.isEmpty()) {
// empty labels = "O"
sentenceArgumentAnnotation.setTag(O_TAG);
}
else {
// find the maximum spanning argument component
ArgumentComponent coveringArgumentComponent = selectMainArgumentComponent(
argumentComponents);
StringBuilder outputLabel = new StringBuilder(
coveringArgumentComponent.getClass().getSimpleName());
// does the annotation start in this sentence?
if (this.startEachSentenceWithB || (
coveringArgumentComponent.getBegin() >= sentence.getBegin() &&
BIO.equals(this.codingGranularity))) {
outputLabel.append(B_SUFFIX);
}
else {
// otherwise it continues from the previous one
outputLabel.append(I_SUFFIX);
}
// set the label
sentenceArgumentAnnotation.setTag(outputLabel.toString());
}
}
}
示例10: repair
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; //导入方法依赖的package包/类
@Override
public void repair(Project aProject, CAS aCas, List<LogMessage> aMessages)
{
try {
for (Sentence s : select(aCas.getJCas(), Sentence.class)) {
if (s.getBegin() >= s.getEnd()) {
s.removeFromIndexes();
aMessages.add(new LogMessage(this, LogLevel.INFO,
"Removed sentence with illegal span: %s", s));
}
}
for (Token t : select(aCas.getJCas(), Token.class)) {
if (t.getBegin() >= t.getEnd()) {
Lemma lemma = t.getLemma();
if (lemma != null) {
lemma.removeFromIndexes();
aMessages.add(new LogMessage(this, LogLevel.INFO,
"Removed lemma attached to token with illegal span: %s", t));
}
POS pos = t.getPos();
if (pos != null) {
pos.removeFromIndexes();
aMessages.add(new LogMessage(this, LogLevel.INFO,
"Removed POS attached to token with illegal span: %s", t));
}
Stem stem = t.getStem();
if (stem != null) {
stem.removeFromIndexes();
aMessages.add(new LogMessage(this, LogLevel.INFO,
"Removed stem attached to token with illegal span: %s", t));
}
t.removeFromIndexes();
aMessages.add(new LogMessage(this, LogLevel.INFO,
"Removed token with illegal span: %s", t));
}
}
}
catch (CASException e) {
log.error("Unabled to access JCas", e);
aMessages.add(
new LogMessage(this, LogLevel.ERROR, "Unabled to access JCas", e.getMessage()));
}
}