Class: EstraierPure::Condition
- Inherits:
-
Object
- Object
- EstraierPure::Condition
- Defined in:
- lib/vendor/estraierpure.rb,
lib/acts_as_searchable.rb
Overview
++ Abstraction of search condition.
Constant Summary collapse
- SURE =
option: check N-gram keys skipping by three
1 << 0
- USUAL =
option: check N-gram keys skipping by two
1 << 1
- FAST =
option: without TF-IDF tuning
1 << 2
- AGITO =
option: with the simplified phrase
1 << 3
- NOIDF =
option: check every N-gram key
1 << 4
- SIMPLE =
option: check N-gram keys skipping by one
1 << 10
Instance Method Summary collapse
-
#add_attr(expr) ⇒ Object
Add an expression for an attribute.
-
#attrs ⇒ Object
Get expressions for attributes.
-
#max ⇒ Object
Get the maximum number of retrieval.
-
#options ⇒ Object
Get options of retrieval.
-
#order ⇒ Object
Get the order expression.
-
#phrase ⇒ Object
Get the search phrase.
-
#set_max(max) ⇒ Object
Set the maximum number of retrieval.
-
#set_options(options) ⇒ Object
Set options of retrieval.
-
#set_order(expr) ⇒ Object
Set the order of a condition object.
-
#set_phrase(phrase) ⇒ Object
Set the search phrase.
-
#set_skip(skip) ⇒ Object
Set the number of skipped documents.
-
#skip ⇒ Object
Get the number of skipped documents.
- #to_s ⇒ Object
Instance Method Details
#add_attr(expr) ⇒ Object
Add an expression for an attribute. ‘expr’ specifies an expression for an attribute. The return value is always ‘nil’.
243 244 245 246 247 248 249 |
# File 'lib/vendor/estraierpure.rb', line 243 def add_attr(expr) Utility::check_types({ expr=>String }) if $DEBUG expr = expr.gsub(/[ \t\r\n\v\f]+/, " ") expr = expr.strip.squeeze(" ") @attrs.push(expr) nil end |
#attrs ⇒ Object
Get expressions for attributes. The return value is expressions for attributes.
298 299 300 |
# File 'lib/vendor/estraierpure.rb', line 298 def attrs() @attrs end |
#max ⇒ Object
Get the maximum number of retrieval. The return value is the maximum number of retrieval.
308 309 310 |
# File 'lib/vendor/estraierpure.rb', line 308 def max() @max end |
#options ⇒ Object
Get options of retrieval. The return value is options by bitwise or.
318 319 320 |
# File 'lib/vendor/estraierpure.rb', line 318 def () @options end |
#order ⇒ Object
Get the order expression. The return value is the order expression.
303 304 305 |
# File 'lib/vendor/estraierpure.rb', line 303 def order() @order end |
#phrase ⇒ Object
Get the search phrase. The return value is the search phrase.
293 294 295 |
# File 'lib/vendor/estraierpure.rb', line 293 def phrase() @phrase end |
#set_max(max) ⇒ Object
Set the maximum number of retrieval. ‘max’ specifies the maximum number of retrieval. By default, the number of retrieval is not limited. The return value is always ‘nil’.
264 265 266 267 268 |
# File 'lib/vendor/estraierpure.rb', line 264 def set_max(max) Utility::check_types({ max=>Integer }) if $DEBUG @max = max if(max >= 0) nil end |
#set_options(options) ⇒ Object
Set options of retrieval. ‘options’ specifies options: ‘Condition::SURE’ specifies that it checks every N-gram key, ‘Condition::USU’, which is the default, specifies that it checks N-gram keys with skipping one key, ‘Condition::FAST’ skips two keys, ‘Condition::AGITO’ skips three keys, ‘Condition::NOIDF’ specifies not to perform TF-IDF tuning, ‘Condition::SIMPLE’ specifies to use simplified phrase. Each option can be specified at the same time by bitwise or. If keys are skipped, though search speed is improved, the relevance ratio grows less. The return value is always ‘nil’.
286 287 288 289 290 |
# File 'lib/vendor/estraierpure.rb', line 286 def () Utility::check_types({ =>Integer }) if $DEBUG @options |= nil end |
#set_order(expr) ⇒ Object
Set the order of a condition object. ‘expr’ specifies an expression for the order. By default, the order is by score descending. The return value is always ‘nil’.
253 254 255 256 257 258 259 |
# File 'lib/vendor/estraierpure.rb', line 253 def set_order(expr) Utility::check_types({ expr=>String }) if $DEBUG expr = expr.gsub(/[ \t\r\n\v\f]+/, " ") expr = expr.strip.squeeze(" ") @order = expr nil end |
#set_phrase(phrase) ⇒ Object
Set the search phrase. ‘phrase’ specifies a search phrase. The return value is always ‘nil’.
233 234 235 236 237 238 239 |
# File 'lib/vendor/estraierpure.rb', line 233 def set_phrase(phrase) Utility::check_types({ phrase=>String }) if $DEBUG phrase = phrase.gsub(/[ \t\r\n\v\f]+/, " ") phrase = phrase.strip.squeeze(" ") @phrase = phrase nil end |
#set_skip(skip) ⇒ Object
Set the number of skipped documents. ‘skip’ specifies the number of documents to be skipped in the search result. The return value is always ‘nil’.
272 273 274 275 276 |
# File 'lib/vendor/estraierpure.rb', line 272 def set_skip(skip) Utility::check_types({ skip=>Integer }) if $DEBUG @skip = skip if(skip >= 0) nil end |
#skip ⇒ Object
Get the number of skipped documents. The return value is the number of documents to be skipped in the search result.
313 314 315 |
# File 'lib/vendor/estraierpure.rb', line 313 def skip() @skip end |
#to_s ⇒ Object
356 357 358 |
# File 'lib/acts_as_searchable.rb', line 356 def to_s "phrase: %s, attrs: %s, max: %s, options: %s, order: %s, skip: %s" % [ phrase, attrs * ', ', max, , order, skip ] end |