Class: TextNlp::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/text_nlp/pattern.rb

Instance Method Summary collapse

Constructor Details

#initialize(pattern, options = {}) ⇒ Pattern

Returns a new instance of Pattern.



7
8
9
10
11
12
13
14
# File 'lib/text_nlp/pattern.rb', line 7

def initialize(pattern, options = {})
  options = {:normalize => true}.merge(options)
  if options[:normalize]
    normalize_pattern(pattern) 
    @to_normalize = true
  end
  @text_query = TextQuery.new(pattern, {:ignorecase => options[:normalize]})
end

Instance Method Details

#match?(text) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/text_nlp/pattern.rb', line 16

def match?(text)
  text.normalize! if @to_normalize
  @text_query.match?(text)
end