Method: TextRank.extract_keywords

Defined in:
lib/text_rank.rb

.extract_keywords(text, **options) ⇒ Hash<String, Float>

A convenience method for quickly extracting keywords from text with default options

Parameters:

  • text (String, Array<String>)

    text from which to extract keywords

Options Hash (**options):

  • :char_filters (Array<Class, Symbol, #filter!>)

    A list of filters to be applied prior to tokenization

  • :tokenizers (Array<Symbol, Regexp, String>)

    A list of tokenizer regular expressions to perform tokenization

  • :token_filters (Array<Class, Symbol, #filter!>)

    A list of filters to be applied to each token after tokenization

  • :graph_strategy (Class, Symbol, #build_graph)

    A class or strategy instance for producing a graph from tokens

  • :rank_filters (Array<Class, Symbol, #filter!>)

    A list of filters to be applied to the keyword ranks after keyword extraction

  • :strategy (Symbol)

    PageRank strategy to use (either :sparse or :dense)

  • :damping (Float)

    The probability of following the graph vs. randomly choosing a new node

  • :tolerance (Float)

    The desired accuracy of the results

Returns:

  • (Hash<String, Float>)

    of tokens and text rank (in descending order)



26
27
28
# File 'lib/text_rank.rb', line 26

def self.extract_keywords(text, **options)
  TextRank::KeywordExtractor.basic(**options).extract(text, **options)
end