@ Override public Collection < String > wordsNearest ( String label , int n ) { if ( ! vocabCache . hasToken ( label ) ) return new ArrayList <> ( ) ; Collection < String > collection = wordsNearest ( Arrays . asList ( label ) , new ArrayList < String > ( ) , n + 1 ) ; if ( collection . contains ( label ) ) collection . remove ( label ) ; return collection ; }
This method returns nearest words for target word based on tree structure . This method is recommended to use if you re going to call for nearest words multiple times . VPTree will be built upon firt call to this method