public INDArray inferVector ( String text , double learningRate , double minLearningRate , int iterations ) { if ( tokenizerFactory == null ) throw new IllegalStateException ( "TokenizerFactory should be defined, prior to predict() call" ) ; if ( this . vocab == null || this . vocab . numWords ( ) == 0 ) reassignExistingModel ( ) ; List < String > tokens = tokenizerFactory . create ( text ) . getTokens ( ) ; List < VocabWord > document = new ArrayList <> ( ) ; for ( String token : tokens ) { if ( vocab . containsWord ( token ) ) { document . add ( vocab . wordFor ( token ) ) ; } } if ( document . isEmpty ( ) ) throw new ND4JIllegalStateException ( "Text passed for inference has no matches in model vocabulary." ) ; return inferVector ( document , learningRate , minLearningRate , iterations ) ; }
This method calculates inferred vector for given text