本文整理匯總了Java中edu.jhu.hlt.concrete.TextSpan.getStart方法的典型用法代碼示例。如果您正苦於以下問題:Java TextSpan.getStart方法的具體用法?Java TextSpan.getStart怎麽用?Java TextSpan.getStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.jhu.hlt.concrete.TextSpan
的用法示例。
在下文中一共展示了TextSpan.getStart方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tokenizationToCoreLabelList
import edu.jhu.hlt.concrete.TextSpan; //導入方法依賴的package包/類
private static List<CoreLabel> tokenizationToCoreLabelList(final Tokenization tkz, int sentIdx, int offset) {
List<CoreLabel> clList = new ArrayList<CoreLabel>();
TokenList tl = tkz.getTokenList();
List<Token> tokList = tl.getTokenList();
for (Token tok : tokList) {
final TextSpan ts = tok.getTextSpan();
final int idx = tok.getTokenIndex();
final int idxPlusOne = idx + 1;
final int begin = ts.getStart() - offset;
final int length = ts.getEnding() - ts.getStart();
CoreLabel cl = factory.makeToken(tok.getText(), begin, length);
cl.setIndex(idxPlusOne);
cl.setSentIndex(sentIdx);
// cl.setOriginalText(tok.getText());
// cl.set(OriginalTextAnnotation.class, tok.getText());
clList.add(cl);
}
return clList;
}
示例2: concreteSectionToCoreMapList
import edu.jhu.hlt.concrete.TextSpan; //導入方法依賴的package包/類
public static List<CoreMap> concreteSectionToCoreMapList(final Section sect, final String commText) {
List<CoreMap> toRet = new ArrayList<>();
List<Sentence> sentList = sect.getSentenceList();
int tokOffset = 0;
for (int i = 0; i < sentList.size(); i++) {
Sentence st = sentList.get(i);
CoreMap cm = new ArrayCoreMap();
cm.set(SentenceIndexAnnotation.class, i);
final TextSpan sts = st.getTextSpan();
final int sentCharStart = sts.getStart();
final int sentCharEnd = sts.getEnding();
LOGGER.debug("Setting stanford sentence BeginChar = {}", sentCharStart);
cm.set(CharacterOffsetBeginAnnotation.class, sentCharStart);
LOGGER.debug("Setting stanford sentence EndChar = {}", sentCharEnd);
cm.set(CharacterOffsetEndAnnotation.class, sentCharEnd);
String sectText = commText.substring(sentCharStart, sentCharEnd);
LOGGER.debug("Setting text: {}", sectText);
cm.set(TextAnnotation.class, sectText);
Tokenization tkz = st.getTokenization();
List<CoreLabel> clList = tokenizationToCoreLabelList(tkz, i, sentCharStart);
final int maxIdx = clList.size();
LOGGER.debug("Setting stanford sentence token begin: {}", tokOffset);
cm.set(TokenBeginAnnotation.class, tokOffset);
final int tokEnd = tokOffset + maxIdx;
LOGGER.debug("Setting stanford sentence token end: {}", tokEnd);
cm.set(TokenEndAnnotation.class, tokEnd);
cm.set(TokensAnnotation.class, clList);
tokOffset = tokEnd;
toRet.add(cm);
}
return toRet;
}
示例3: TokPtr
import edu.jhu.hlt.concrete.TextSpan; //導入方法依賴的package包/類
public TokPtr(Tokenization tok, TextSpan ts, int index) {
this(tok, ts.getStart(), ts.getEnding(), index);
}