Class: Riddle::Configuration::Index

Inherits:
Section
  • Object
show all
Defined in:
lib/riddle/configuration/index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *sources) ⇒ Index

Returns a new instance of Index.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/riddle/configuration/index.rb', line 27

def initialize(name, *sources)
  @name                     = name
  @sources                  = sources
  @morphologies             = []
  @stopword_files           = []
  @wordform_files           = []
  @exception_files          = []
  @ignore_characters        = []
  @prefix_field_names       = []
  @infix_field_names        = []
  @ngram_characters         = []
  @phrase_boundaries        = []
  @html_remove_element_tags = []
end

Instance Attribute Details

#blend_charsObject

Returns the value of attribute blend_chars.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def blend_chars
  @blend_chars
end

#charset_dictpathObject

Returns the value of attribute charset_dictpath.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def charset_dictpath
  @charset_dictpath
end

#charset_tableObject

Returns the value of attribute charset_table.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def charset_table
  @charset_table
end

#charset_typeObject

Returns the value of attribute charset_type.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def charset_type
  @charset_type
end

#docinfoObject

Returns the value of attribute docinfo.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def docinfo
  @docinfo
end

#enable_starObject

Returns the value of attribute enable_star.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def enable_star
  @enable_star
end

#exception_filesObject

Returns the value of attribute exception_files.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def exception_files
  @exception_files
end

#expand_keywordsObject

Returns the value of attribute expand_keywords.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def expand_keywords
  @expand_keywords
end

#hitless_wordsObject

Returns the value of attribute hitless_words.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def hitless_words
  @hitless_words
end

#html_index_attrsObject

Returns the value of attribute html_index_attrs.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def html_index_attrs
  @html_index_attrs
end

#html_remove_element_tagsObject

Returns the value of attribute html_remove_element_tags.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def html_remove_element_tags
  @html_remove_element_tags
end

#html_stripObject

Returns the value of attribute html_strip.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def html_strip
  @html_strip
end

#ignore_charactersObject

Returns the value of attribute ignore_characters.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def ignore_characters
  @ignore_characters
end

#index_exact_wordsObject

Returns the value of attribute index_exact_words.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def index_exact_words
  @index_exact_words
end

#infix_field_namesObject

Returns the value of attribute infix_field_names.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def infix_field_names
  @infix_field_names
end

#inplace_docinfo_gapObject

Returns the value of attribute inplace_docinfo_gap.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def inplace_docinfo_gap
  @inplace_docinfo_gap
end

#inplace_enableObject

Returns the value of attribute inplace_enable.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def inplace_enable
  @inplace_enable
end

#inplace_hit_gapObject

Returns the value of attribute inplace_hit_gap.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def inplace_hit_gap
  @inplace_hit_gap
end

#inplace_reloc_factorObject

Returns the value of attribute inplace_reloc_factor.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def inplace_reloc_factor
  @inplace_reloc_factor
end

#inplace_write_factorObject

Returns the value of attribute inplace_write_factor.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def inplace_write_factor
  @inplace_write_factor
end

#min_infix_lenObject

Returns the value of attribute min_infix_len.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def min_infix_len
  @min_infix_len
end

#min_prefix_lenObject

Returns the value of attribute min_prefix_len.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def min_prefix_len
  @min_prefix_len
end

#min_stemming_lenObject

Returns the value of attribute min_stemming_len.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def min_stemming_len
  @min_stemming_len
end

#min_word_lenObject

Returns the value of attribute min_word_len.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def min_word_len
  @min_word_len
end

#mlockObject

Returns the value of attribute mlock.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def mlock
  @mlock
end

#morphologiesObject

Returns the value of attribute morphologies.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def morphologies
  @morphologies
end

#nameObject

Returns the value of attribute name.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def name
  @name
end

#ngram_charactersObject

Returns the value of attribute ngram_characters.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def ngram_characters
  @ngram_characters
end

#ngram_lenObject

Returns the value of attribute ngram_len.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def ngram_len
  @ngram_len
end

#ondisk_dictObject

Returns the value of attribute ondisk_dict.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def ondisk_dict
  @ondisk_dict
end

#overshort_stepObject

Returns the value of attribute overshort_step.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def overshort_step
  @overshort_step
end

#parentObject

Returns the value of attribute parent.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def parent
  @parent
end

#pathObject

Returns the value of attribute path.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def path
  @path
end

#phrase_boundariesObject

Returns the value of attribute phrase_boundaries.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def phrase_boundaries
  @phrase_boundaries
end

#phrase_boundary_stepObject

Returns the value of attribute phrase_boundary_step.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def phrase_boundary_step
  @phrase_boundary_step
end

#prefix_field_namesObject

Returns the value of attribute prefix_field_names.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def prefix_field_names
  @prefix_field_names
end

#preopenObject

Returns the value of attribute preopen.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def preopen
  @preopen
end

#sourcesObject

Returns the value of attribute sources.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def sources
  @sources
end

#stopword_filesObject

Returns the value of attribute stopword_files.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def stopword_files
  @stopword_files
end

#stopwords_stepObject

Returns the value of attribute stopwords_step.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def stopwords_step
  @stopwords_step
end

#typeObject

Returns the value of attribute type.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def type
  @type
end

#wordform_filesObject

Returns the value of attribute wordform_files.



15
16
17
# File 'lib/riddle/configuration/index.rb', line 15

def wordform_files
  @wordform_files
end

Instance Method Details

#exceptionsObject



70
71
72
# File 'lib/riddle/configuration/index.rb', line 70

def exceptions
  nil_join @exception_files, " "
end

#exceptions=(exceptions) ⇒ Object



74
75
76
# File 'lib/riddle/configuration/index.rb', line 74

def exceptions=(exceptions)
  @exception_files = nil_split exceptions, ' '
end

#html_remove_elementsObject



110
111
112
# File 'lib/riddle/configuration/index.rb', line 110

def html_remove_elements
  nil_join @html_remove_element_tags, ", "
end

#html_remove_elements=(html_remove_elements) ⇒ Object



114
115
116
# File 'lib/riddle/configuration/index.rb', line 114

def html_remove_elements=(html_remove_elements)
  @html_remove_element_tags = nil_split html_remove_elements, /,\s?/
end

#ignore_charsObject



78
79
80
# File 'lib/riddle/configuration/index.rb', line 78

def ignore_chars
  nil_join @ignore_characters, ", "
end

#ignore_chars=(ignore_chars) ⇒ Object



82
83
84
# File 'lib/riddle/configuration/index.rb', line 82

def ignore_chars=(ignore_chars)
  @ignore_characters = nil_split ignore_chars, /,\s?/
end

#infix_fieldsObject



90
91
92
# File 'lib/riddle/configuration/index.rb', line 90

def infix_fields
  nil_join @infix_field_names, ", "
end

#morphologyObject



46
47
48
# File 'lib/riddle/configuration/index.rb', line 46

def morphology
  nil_join @morphologies, ", "
end

#morphology=(morphology) ⇒ Object



50
51
52
# File 'lib/riddle/configuration/index.rb', line 50

def morphology=(morphology)
  @morphologies = nil_split morphology, /,\s?/
end

#ngram_charsObject



94
95
96
# File 'lib/riddle/configuration/index.rb', line 94

def ngram_chars
  nil_join @ngram_characters, ", "
end

#ngram_chars=(ngram_chars) ⇒ Object



98
99
100
# File 'lib/riddle/configuration/index.rb', line 98

def ngram_chars=(ngram_chars)
  @ngram_characters = nil_split ngram_chars, /,\s?/
end

#phrase_boundaryObject



102
103
104
# File 'lib/riddle/configuration/index.rb', line 102

def phrase_boundary
  nil_join @phrase_boundaries, ", "
end

#phrase_boundary=(phrase_boundary) ⇒ Object



106
107
108
# File 'lib/riddle/configuration/index.rb', line 106

def phrase_boundary=(phrase_boundary)
  @phrase_boundaries = nil_split phrase_boundary, /,\s?/
end

#prefix_fieldsObject



86
87
88
# File 'lib/riddle/configuration/index.rb', line 86

def prefix_fields
  nil_join @prefix_field_names, ", "
end

#renderObject

Raises:



118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/riddle/configuration/index.rb', line 118

def render
  raise ConfigurationError, "#{@name} #{@sources.inspect} #{@path} #{@parent}" unless valid?
  
  inherited_name = "#{name}"
  inherited_name << " : #{parent}" if parent
  (
    @sources.collect { |s| s.render } +
    ["index #{inherited_name}", "{"] +
    settings_body +
    ["}", ""]
  ).join("\n")
end

#sourceObject



42
43
44
# File 'lib/riddle/configuration/index.rb', line 42

def source
  @sources.collect { |s| s.name }
end

#stopwordsObject



54
55
56
# File 'lib/riddle/configuration/index.rb', line 54

def stopwords
  nil_join @stopword_files, " "
end

#stopwords=(stopwords) ⇒ Object



58
59
60
# File 'lib/riddle/configuration/index.rb', line 58

def stopwords=(stopwords)
  @stopword_files = nil_split stopwords, ' '
end

#valid?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/riddle/configuration/index.rb', line 131

def valid?
  (!@name.nil?) && (!( @sources.length == 0 || @path.nil? ) || !@parent.nil?)
end

#wordformsObject



62
63
64
# File 'lib/riddle/configuration/index.rb', line 62

def wordforms
  nil_join @wordform_files, " "
end

#wordforms=(wordforms) ⇒ Object



66
67
68
# File 'lib/riddle/configuration/index.rb', line 66

def wordforms=(wordforms)
  @wordform_files = nil_split wordforms, ' '
end