private DoubleVector groupConvolution ( Queue < String > prevWords , Queue < String > nextWords ) { // Generate an empty DoubleVector to hold the convolution. DoubleVector result = new DenseVector ( indexVectorSize ) ; // Do the convolutions starting at index 0. String prevWord = prevWords . peek ( ) ; DoubleVector tempConvolution ; if ( ! prevWord . equals ( IteratorFactory . EMPTY_TOKEN ) ) { tempConvolution = convolute ( vectorMap . get ( prevWords . peek ( ) ) , placeHolder ) ; VectorMath . add ( result , tempConvolution ) ; } else tempConvolution = placeHolder ; for ( String term : nextWords ) { if ( term . equals ( IteratorFactory . EMPTY_TOKEN ) ) continue ; tempConvolution = convolute ( tempConvolution , vectorMap . get ( term ) ) ; VectorMath . add ( result , tempConvolution ) ; } tempConvolution = placeHolder ; // Do the convolutions starting at index 1. for ( String term : nextWords ) { if ( term . equals ( IteratorFactory . EMPTY_TOKEN ) ) continue ; tempConvolution = convolute ( tempConvolution , vectorMap . get ( term ) ) ; VectorMath . add ( result , tempConvolution ) ; } return result ; }
Generate the circular convoltion of n - grams composed of words in the given context . The result of this convolution is returned as a DoubleVector .