public List < String > getSynonyms ( AnalyzedTokenReadings token ) { List < String > synonyms = new ArrayList < String > ( ) ; if ( linguServices == null || token == null ) { return synonyms ; } List < AnalyzedToken > readings = token . getReadings ( ) ; for ( AnalyzedToken reading : readings ) { String lemma = reading . getLemma ( ) ; if ( lemma != null ) { List < String > rawSynonyms = linguServices . getSynonyms ( lemma , lang ) ; for ( String synonym : rawSynonyms ) { synonym = synonym . replaceAll ( "\\(.*\\)" , "" ) . trim ( ) ; if ( ! synonym . isEmpty ( ) && ! synonyms . contains ( synonym ) ) { synonyms . add ( synonym ) ; } } } } if ( synonyms . isEmpty ( ) ) { List < String > rawSynonyms = linguServices . getSynonyms ( token . getToken ( ) , lang ) ; for ( String synonym : rawSynonyms ) { synonym = synonym . replaceAll ( "\\(.*\\)" , "" ) . trim ( ) ; if ( ! synonym . isEmpty ( ) && ! synonyms . contains ( synonym ) ) { synonyms . add ( synonym ) ; } } } return synonyms ; }
get synonyms for a repeated word