@ Override public Map < Integer , String > extract ( final String text ) { Set < String > tmpKwd = new LinkedHashSet <> ( generateTokenizer ( ) . tokenize ( text ) ) ; Map < Integer , String > keywordSequence = new LinkedHashMap <> ( ) ; int position = 0 ; for ( String keyword : tmpKwd ) { keywordSequence . put ( position , keyword ) ; ++ position ; } return keywordSequence ; }
This method gets as input a string and returns as output a numbered sequence of the unique tokens . In the returned map as keys we store the position of the word in the original string and as value the actual unique token in that position . Note that the sequence includes only the position of the first occurrence of each word while the next occurrences are ignored .