本文整理汇总了Java中org.apache.lucene.search.vectorhighlight.FieldFragList.WeightedFragInfo.getSubInfos方法的典型用法代码示例。如果您正苦于以下问题:Java WeightedFragInfo.getSubInfos方法的具体用法?Java WeightedFragInfo.getSubInfos怎么用?Java WeightedFragInfo.getSubInfos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.vectorhighlight.FieldFragList.WeightedFragInfo
的用法示例。
在下文中一共展示了WeightedFragInfo.getSubInfos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeFragment
import org.apache.lucene.search.vectorhighlight.FieldFragList.WeightedFragInfo; //导入方法依赖的package包/类
protected String makeFragment( StringBuilder buffer, int[] index, Field[] values, WeightedFragInfo fragInfo,
String[] preTags, String[] postTags, Encoder encoder ){
StringBuilder fragment = new StringBuilder();
final int s = fragInfo.getStartOffset();
int[] modifiedStartOffset = { s };
String src = getFragmentSourceMSO( buffer, index, values, s, fragInfo.getEndOffset(), modifiedStartOffset );
int srcIndex = 0;
for( SubInfo subInfo : fragInfo.getSubInfos() ){
for( Toffs to : subInfo.getTermsOffsets() ){
fragment
.append( encoder.encodeText( src.substring( srcIndex, to.getStartOffset() - modifiedStartOffset[0] ) ) )
.append( getPreTag( preTags, subInfo.getSeqnum() ) )
.append( encoder.encodeText( src.substring( to.getStartOffset() - modifiedStartOffset[0], to.getEndOffset() - modifiedStartOffset[0] ) ) )
.append( getPostTag( postTags, subInfo.getSeqnum() ) );
srcIndex = to.getEndOffset() - modifiedStartOffset[0];
}
}
fragment.append( encoder.encodeText( src.substring( srcIndex ) ) );
return fragment.toString();
}
示例2: testCase
import org.apache.lucene.search.vectorhighlight.FieldFragList.WeightedFragInfo; //导入方法依赖的package包/类
private void testCase( Query query, int fragCharSize, String expectedFragInfo,
double expectedTotalSubInfoBoost ) throws Exception {
makeIndexLongMV();
FieldQuery fq = new FieldQuery( query, true, true );
FieldTermStack stack = new FieldTermStack( reader, 0, F, fq );
FieldPhraseList fpl = new FieldPhraseList( stack, fq );
WeightedFragListBuilder wflb = new WeightedFragListBuilder();
FieldFragList ffl = wflb.createFieldFragList( fpl, fragCharSize );
assertEquals( 1, ffl.getFragInfos().size() );
assertEquals( expectedFragInfo, ffl.getFragInfos().get( 0 ).toString() );
float totalSubInfoBoost = 0;
for ( WeightedFragInfo info : ffl.getFragInfos() ) {
for ( SubInfo subInfo : info.getSubInfos() ) {
totalSubInfoBoost += subInfo.getBoost();
}
}
assertEquals( expectedTotalSubInfoBoost, totalSubInfoBoost, .0000001 );
}