本文整理汇总了C#中BitSet.get方法的典型用法代码示例。如果您正苦于以下问题:C# BitSet.get方法的具体用法?C# BitSet.get怎么用?C# BitSet.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitSet
的用法示例。
在下文中一共展示了BitSet.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buildLabels
void buildLabels( LingoProcessingContext context, ITermWeighting termWeighting )
{
PreprocessingContext preprocessingContext = context.preprocessingContext;
VectorSpaceModelContext vsmContext = context.vsmContext;
DoubleMatrix2D reducedTdMatrix = context.reducedVsmContext.baseMatrix;
int[] wordsStemIndex = preprocessingContext.allWords.stemIndex;
int[] labelsFeatureIndex = preprocessingContext.allLabels.featureIndex;
int[] mostFrequentOriginalWordIndex = preprocessingContext.allStems.mostFrequentOriginalWordIndex;
int[][] phrasesWordIndices = preprocessingContext.allPhrases.wordIndices;
BitSet[] labelsDocumentIndices = preprocessingContext.allLabels.documentIndices;
int wordCount = preprocessingContext.allWords.image.length;
int documentCount = preprocessingContext.documents.Size();
BitSet oneWordCandidateStemIndices = new BitSet();
for ( int i = 0; i < labelsFeatureIndex.Length; i++ )
{
int featureIndex = labelsFeatureIndex[i];
if ( featureIndex >= wordCount )
{
break;
}
oneWordCandidateStemIndices.set( wordsStemIndex[featureIndex] );
}
IntIntOpenHashMap stemToRowIndex = vsmContext.stemToRowIndex;
IntIntOpenHashMap filteredRowToStemIndex = new IntIntOpenHashMap();
IntArrayList filteredRows = new IntArrayList();
int filteredRowIndex = 0;
foreach ( IntIntCursor it in stemToRowIndex )
{
if ( oneWordCandidateStemIndices.get( it.key ) )
{
filteredRowToStemIndex.put( filteredRowIndex++, it.key );
filteredRows.add( it.value );
}
}
double[] featureScores = featureScorer != null ? featureScorer.getFeatureScores( context ) : null;
int[] wordLabelIndex = new int[wordCount];
for ( int i = 0; i < wordCount; i++ )
{
wordLabelIndex[i] = -1;
}
for ( int i = 0; i < labelsFeatureIndex.Length; i++ )
{
int featureIndex = labelsFeatureIndex[i];
if ( featureIndex < wordCount )
{
wordLabelIndex[featureIndex] = i;
}
}
DoubleMatrix2D stemCos = reducedTdMatrix.viewSelection(
filteredRows.toArray(), null ).copy();
for ( int r = 0; r < stemCos.rows(); r++ )
{
int labelIndex = wordLabelIndex[mostFrequentOriginalWordIndex[filteredRowToStemIndex.get( r )]];
double penalty = getDocumentCountPenalty( labelIndex, documentCount, labelsDocumentIndices );
if ( featureScores != null )
{
penalty *= featureScores[labelIndex];
}
stemCos.viewRow( r ).assign( Functions.mult( penalty ) );
}
DoubleMatrix2D phraseMatrix = vsmContext.termPhraseMatrix;
int firstPhraseIndex = preprocessingContext.allLabels.firstPhraseIndex;
DoubleMatrix2D phraseCos = null;
if ( phraseMatrix != null )
{
phraseCos = phraseMatrix.zMult( reducedTdMatrix, null, 1, 0, false, false );
if ( phraseLengthPenaltyStop < phraseLengthPenaltyStart )
{
phraseLengthPenaltyStop = phraseLengthPenaltyStart;
}
double penaltyStep = 1.0 / ( phraseLengthPenaltyStop - phraseLengthPenaltyStart + 1 );
for ( int row = 0; row < phraseCos.rows(); row++ )
{
int phraseFeature = labelsFeatureIndex[row + firstPhraseIndex];
int[] phraseWordIndices = phrasesWordIndices[phraseFeature - wordCount];
double penalty;
if ( phraseWordIndices.Length >= phraseLengthPenaltyStop )
{
penalty = 0;
}
else
{
penalty = getDocumentCountPenalty( row + firstPhraseIndex,
documentCount, labelsDocumentIndices );
if ( phraseWordIndices.Length >= phraseLengthPenaltyStart )
{
penalty *= 1 - penaltyStep
* ( phraseWordIndices.Length - phraseLengthPenaltyStart + 1 );
}
if ( featureScores != null )
{
penalty *= featureScores[row + firstPhraseIndex];
}
}
phraseCos.viewRow( row ).assign( Functions.mult( penalty * phraseLabelBoost ) );
}
}
labelAssigner.assignLabels( context, stemCos, filteredRowToStemIndex, phraseCos );
//.........这里部分代码省略.........