Class: Kreuzberg::Config::Keywords

Inherits:
Object
  • Object
show all
Defined in:
lib/kreuzberg/config.rb

Overview

Keyword extraction configuration for document analysis

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm: nil, max_keywords: nil, min_score: nil, ngram_range: nil, language: nil, yake_params: nil, rake_params: nil) ⇒ Keywords

Returns a new instance of Keywords.



699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# File 'lib/kreuzberg/config.rb', line 699

def initialize(
  algorithm: nil,
  max_keywords: nil,
  min_score: nil,
  ngram_range: nil,
  language: nil,
  yake_params: nil,
  rake_params: nil
)
  @algorithm = algorithm&.to_s
  @max_keywords = max_keywords&.to_i
  @min_score = min_score&.to_f
  @ngram_range = ngram_range&.map(&:to_i)
  @language = language&.to_s
  @yake_params = normalize_nested(yake_params, KeywordYakeParams)
  @rake_params = normalize_nested(rake_params, KeywordRakeParams)
end

Instance Attribute Details

#algorithmObject (readonly)

Returns the value of attribute algorithm.



696
697
698
# File 'lib/kreuzberg/config.rb', line 696

def algorithm
  @algorithm
end

#languageObject (readonly)

Returns the value of attribute language.



696
697
698
# File 'lib/kreuzberg/config.rb', line 696

def language
  @language
end

#max_keywordsObject (readonly)

Returns the value of attribute max_keywords.



696
697
698
# File 'lib/kreuzberg/config.rb', line 696

def max_keywords
  @max_keywords
end

#min_scoreObject (readonly)

Returns the value of attribute min_score.



696
697
698
# File 'lib/kreuzberg/config.rb', line 696

def min_score
  @min_score
end

#ngram_rangeObject (readonly)

Returns the value of attribute ngram_range.



696
697
698
# File 'lib/kreuzberg/config.rb', line 696

def ngram_range
  @ngram_range
end

#rake_paramsObject (readonly)

Returns the value of attribute rake_params.



696
697
698
# File 'lib/kreuzberg/config.rb', line 696

def rake_params
  @rake_params
end

#yake_paramsObject (readonly)

Returns the value of attribute yake_params.



696
697
698
# File 'lib/kreuzberg/config.rb', line 696

def yake_params
  @yake_params
end

Instance Method Details

#to_hObject



717
718
719
720
721
722
723
724
725
726
727
# File 'lib/kreuzberg/config.rb', line 717

def to_h
  {
    algorithm: @algorithm,
    max_keywords: @max_keywords,
    min_score: @min_score,
    ngram_range: @ngram_range,
    language: @language,
    yake_params: @yake_params&.to_h,
    rake_params: @rake_params&.to_h
  }.compact
end