本文整理汇总了C++中Sentence::setEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ Sentence::setEnd方法的具体用法?C++ Sentence::setEnd怎么用?C++ Sentence::setEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentence
的用法示例。
在下文中一共展示了Sentence::setEnd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
////////////////////////////////////////////////////////////////////////////////
// 'getSentence' returns the first sentence that can be found starting
// from begin. Note that the Sentence that is returned may actually
// be empty (when there is no more sentence starting from begin and
// ending before end) in that case it returns false. It returns true
// if a sentence was found. The iterators are pointing into the
// document.
////////////////////////////////////////////////////////////////////////////////
bool
AF::getSentence(const Document* document,
const StringXML::size_type begin,
const StringXML::size_type end, Sentence& sentence) {
if (document==0) {
return false;
}
StringXML text=document->getString(begin, end);
StringXML::const_iterator tBegin=text.begin();
StringXML::const_iterator tEnd=text.end();
StringXML::const_iterator i=text.begin();
Token t;
if (!getToken(i, tEnd, t)) { // get first token
return false;
}
i=tBegin+t.getEnd();
// Skip sentence ends
while ((isSentenceEnd(t, text))) {
if (!getToken(i, tEnd, t, i-tBegin)) {
return false;
}
i=tBegin+t.getEnd();
}
StringXML::size_type sentenceBegin=t.getBegin();
StringXML::size_type sentenceEnd=t.getEnd();
while (getToken(i, tEnd, t, i-tBegin, false)
&&!(
(isXML(t, text) // XML is sentence end
||isSentenceEnd(t, text)
&&!isAbbreviation(
StringXML(tBegin+sentenceBegin, tBegin+t.getEnd()))))) {
sentenceEnd=t.getEnd();
i=tBegin+t.getEnd();
}
if (isSentenceEnd(t, text)) {
sentenceEnd=t.getEnd();
}
sentence.setBegin(begin+sentenceBegin);
sentence.setEnd(begin+sentenceEnd);
return true;
}