nl_tokens: Use the model trained so far to classify a new sample .
pl_tokens: function ( sample , explain , withScores ) { var labels = [ ] var scores = [ ] var explanations = [ ] ; var positive_explanations = { } ; var negative_explanations = [ ] for ( var label in this . mapClassnameToClassifier ) { var classifier = this . mapClassnameToClassifier [ label ] ; if ( this . <mask> ) console . dir ( "Classify for class=" + label ) // fs.writeFileSync('/tmp/labels/'+label, JSON.stringify(classifier.getFeatures(), null, 4), 'utf8'); var scoreWithExplain = classifier . classify ( sample , explain , withScores ) ; if ( this . debug ) console . log ( JSON . stringify ( scoreWithExplain , null , 4 ) ) var score = scoreWithExplain . explanation ? scoreWithExplain . classification : scoreWithExplain ; if ( this . debug ) console . dir ( "score=" + score ) explanations_string = scoreWithExplain . explanation // if (score>0.5) if ( score > 0 ) { labels . push ( [ label , score ] ) if ( explanations_string ) positive_explanations [ label ] = explanations_string ; } else { if ( explanations_string ) negative_explanations . push ( [ label , score , explanations_string ] ) } scores . push ( [ label , score ] ) } if ( this . debug ) console . dir ( scores ) if ( explain > 0 ) { scores = _ . sortBy ( scores , function ( num ) { return num [ 1 ] } ) . reverse ( ) var scores_hash = _ . object ( scores ) negative_explanations = _ . sortBy ( negative_explanations , function ( num ) { return num [ 1 ] } ) . reverse ( ) negative_explanations = _ . map ( negative_explanations , function ( num ) { return [ num [ 0 ] , num [ 2 ] ] } ) ; var negative_explanations_hash = _ . object ( negative_explanations ) } labels = _ . sortBy ( labels , function ( num ) { return num [ 1 ] } ) ; labels = _ . map ( labels . reverse ( ) , function ( num ) { return num [ 0 ] } ) ; return ( explain > 0 ? { classes : labels , scores : scores_hash , explanation : { positive : positive_explanations , negative : negative_explanations_hash , } } : labels ) ; }