本文整理了Java中de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence
类的一些代码示例,展示了Sentence
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sentence
类的具体详情如下:
包路径:de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence
类名称:Sentence
[英]Updated by JCasGen Thu Feb 28 07:53:35 UTC 2019 XML source: /usr/src/mvn_workdir/dkpro-core-api-segmentation-asl/target/jcasgen/typesystem.xml
[中]JCasGen Thu于2019年2月28日07:53:35 UTC XML source:/usr/src/mvn_workdir/dkpro核心api分段asl/target/JCasGen/typesystem更新。xml
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.tsv
Sentence outSentence = new Sentence(aJCas);
outSentence.setBegin(tokensStored.get("t_" + firstTokenInSentence.get(i)).getEnd());
outSentence.setEnd(tokensStored.get("t_" + (tokensStored.size())).getEnd());
outSentence.addToIndexes();
break;
outSentence.setBegin(tokensStored.get("t_" + firstTokenInSentence.get(i))
.getBegin());
outSentence.setEnd(tokensStored.get("t_" + (tokensStored.size())).getEnd());
outSentence.addToIndexes();
outSentence.setBegin(tokensStored.get("t_" + firstTokenInSentence.get(i))
.getBegin());
outSentence.setEnd(tokensStored.get("t_" + firstTokenInSentence.get(i + 1))
.getEnd());
outSentence.addToIndexes();
.setBegin(tokensStored.get("t_" + firstTokenInSentence.get(i)).getEnd() + 1);
outSentence.setEnd(tokensStored.get("t_" + firstTokenInSentence.get(i + 1))
.getEnd());
outSentence.addToIndexes();
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat
/**
* Get the cureent sentence based on the anotation begin/end offset
*/
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()>=aEnd){
currentSentence = sentence;
break;
}
}
return currentSentence;
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat
Sentence.class,
BratAjaxCasUtil.getLastSentenceAddressInDisplayWindow(jCas,
firstSentence.getAddress(), windowSize));
begin = firstSentence.getBegin();
end = lastSentence.getEnd();
sentenceNumber = BratAjaxCasUtil.getFirstSentenceNumber(jCas, firstSentence.getAddress());
segmentAdress.put(username, new HashMap<Integer, Integer>());
segmentBeginEnd.put(sentence.getBegin(), sentence.getEnd());
segmentText.put(sentence.getBegin(), sentence.getCoveredText().toString());
segmentNumber.put(sentence.getBegin(), sentenceNumber);
segmentAdress.get(username).put(sentence.getBegin(), sentence.getAddress());
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.api.segmentation-asl
/** @generated
* @param jcas JCas to which this Feature Structure belongs
* @param begin offset to the begin spot in the SofA
* @param end offset to the end spot in the SofA
*/
public Sentence(JCas jcas, int begin, int end) {
super(jcas);
setBegin(begin);
setEnd(end);
readObject();
}
代码示例来源:origin: dkpro/dkpro-tc
protected void setSentence(JCas aJCas, int begin, int end)
{
Sentence sentence = new Sentence(aJCas, begin, end);
sentence.addToIndexes();
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-dao
public static void tokenize(JCas aJCas)
{
BreakIterator bi = BreakIterator.getWordInstance(Locale.US);
for (Sentence s : select(aJCas, Sentence.class)) {
bi.setText(s.getCoveredText());
int last = bi.first();
int cur = bi.next();
while (cur != BreakIterator.DONE) {
int[] span = new int[] { last, cur };
trim(s.getCoveredText(), span);
if (!isEmpty(span[0], span[1])) {
Token seg = new Token(aJCas, span[0] + s.getBegin(), span[1] + s.getBegin());
seg.addToIndexes(aJCas);
}
last = cur;
cur = bi.next();
}
}
}
代码示例来源:origin: webanno/webanno
private static JCas makeJCasOneSentence(String aText) throws UIMAException
{
JCas jcas = makeJCas();
TokenBuilder<Token, Sentence> tb = new TokenBuilder<>(Token.class,
Sentence.class);
tb.buildTokens(jcas, aText);
// Remove the sentences generated by the token builder which treats the line break as a
// sentence break
for (Sentence s : select(jcas, Sentence.class)) {
s.removeFromIndexes();
}
// Add a new sentence covering the whole text
new Sentence(jcas, 0, jcas.getDocumentText().length()).addToIndexes();
return jcas;
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat
private static int getLastSentenceAddress(BratAnnotatorModel aBratAnnotatorModel, JCas jCas,
JCas userJCas)
{
Sentence sentence = selectByAddr(userJCas, Sentence.class,
aBratAnnotatorModel.getLastSentenceAddress());
List<Sentence> sentences = JCasUtil.selectCovered(jCas, Sentence.class,
sentence.getBegin(), sentence.getEnd());
return sentences.get(0).getAddress();
}
代码示例来源:origin: webanno/webanno
public int getBegin()
{
return uimaSentence.getBegin();
}
代码示例来源: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: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl
List<CoreMap> sentences = new ArrayList<>();
for (Sentence s : select(aJCas, Sentence.class)) {
Annotation sentence = new Annotation(s.getCoveredText());
sentence.set(CharacterOffsetBeginAnnotation.class, s.getBegin());
sentence.set(CharacterOffsetEndAnnotation.class, s.getEnd());
sentence.set(SentenceIndexAnnotation.class, sentences.size());
代码示例来源:origin: UKPLab/argument-reasoning-comprehension-task
@Override
public boolean keepArgument(JCas jCas)
{
List<Sentence> sentences = new ArrayList<>(JCasUtil.select(jCas, Sentence.class));
// remove one-sentence arguments
if (sentences.size() == 1) {
return false;
}
for (Sentence s : sentences) {
if (s.getCoveredText().length() > MAX_SENTENCE_LENGTH) {
return false;
}
}
return true;
}
}
代码示例来源:origin: oaqa/knn4qa
private void copyAnnotations(JCas jCasSrc, JCas jCasDst) {
CasCopier copier = new CasCopier(jCasSrc.getCas(), jCasDst.getCas());
for (Sentence anSrc : JCasUtil.select(jCasSrc, Sentence.class)) {
Sentence anDst = (Sentence) copier.copyFs(anSrc);
anDst.addToIndexes();
}
for (Token anSrc : JCasUtil.select(jCasSrc, Token.class)) {
Token anDst = (Token) copier.copyFs(anSrc);
anDst.addToIndexes();
}
for (POS anSrc : JCasUtil.select(jCasSrc, POS.class)) {
POS anDst = (POS) copier.copyFs(anSrc);
anDst.addToIndexes();
}
}
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
private Annotation getAnnotationObject(JCas aJCas, String viewName, String type, Integer[] index) throws Exception{
if (type.matches(txpAnn.token))
return new Token(aJCas.getView(viewName));
if (type.matches(txpAnn.lemma))
return new Lemma(aJCas.getView(viewName));
if (type.matches(txpAnn.pos))
return getAnnotationObject(aJCas, viewName, txpAnn.getAnnotation(type).get(index), POS.class);
if (type.matches(txpAnn.sentence))
return new Sentence(aJCas.getView(viewName));
if (type.matches(txpAnn.ne))
return getAnnotationObject(aJCas, viewName, txpAnn.getNEtype(index), NamedEntity.class);
return new Annotation(aJCas.getView(viewName));
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-io-tsv
public int getEnd()
{
return uimaSentence.getEnd();
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.io.penntree-asl
private void annotateSentence(JCas aJCas, int aBegin, int aEnd)
{
new Sentence(aJCas, aBegin, aEnd).addToIndexes();
}
代码示例来源:origin: webanno/webanno
public static void tokenize(JCas aJCas)
{
BreakIterator bi = BreakIterator.getWordInstance(Locale.US);
for (Sentence s : select(aJCas, Sentence.class)) {
bi.setText(s.getCoveredText());
int last = bi.first();
int cur = bi.next();
while (cur != BreakIterator.DONE) {
int[] span = new int[] { last, cur };
trim(s.getCoveredText(), span);
if (!isEmpty(span[0], span[1])) {
Token seg = new Token(aJCas, span[0] + s.getBegin(), span[1] + s.getBegin());
seg.addToIndexes(aJCas);
}
last = cur;
cur = bi.next();
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat
/**
* Get the sentence address for jCas from userJCas.
*/
private static int getSentenceAddress(BratAnnotatorModel aBratAnnotatorModel, JCas jCas,
JCas userJCas)
{
int sentenceAddress = BratAjaxCasUtil.selectSentenceAt(userJCas,
aBratAnnotatorModel.getSentenceBeginOffset(),
aBratAnnotatorModel.getSentenceEndOffset()).getAddress();
Sentence sentence = selectByAddr(userJCas, Sentence.class, sentenceAddress);
List<Sentence> sentences = JCasUtil.selectCovered(jCas, Sentence.class,
sentence.getBegin(), sentence.getEnd());
return sentences.get(0).getAddress();
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-io-tsv
public int getBegin()
{
return uimaSentence.getBegin();
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
/**
* <B>NOTE:</B> Must be called only after one of the conversion methods was called.
* @return a mapping between a root, and the text of the tree's sentence. This is an ordered map,
* ordered by the order of sentences in the text.
* @throws CasTreeConverterException
*/
public LinkedHashMap<BasicNode, String> getTreesToSentences() throws CasTreeConverterException {
if (lastRootList == null || lastSentenceList == null) {
throw new CasTreeConverterException("getTreesToSentences() called before a conversion method was called.");
}
if (lastRootList.size() != lastSentenceList.size()) {
throw new CasTreeConverterException("Internal error - lastRootList(size=" + lastRootList.size() + ") and lastSentenceList(size=" +
lastSentenceList.size() + ") are in different sizes.");
}
LinkedHashMap<BasicNode, String> result = new LinkedHashMap<BasicNode, String>(lastRootList.size());
Iterator<Sentence> iterSentences = lastSentenceList.iterator();
for (BasicNode node : lastRootList) {
Sentence sentence = iterSentences.next();
result.put(node, sentence.getCoveredText());
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!