Class: TextNlp::Pattern
- Inherits:
-
Object
- Object
- TextNlp::Pattern
- Defined in:
- lib/text_nlp/pattern.rb
Instance Method Summary collapse
-
#initialize(pattern, options = {}) ⇒ Pattern
constructor
A new instance of Pattern.
- #match?(text) ⇒ Boolean
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, = {}) = {:normalize => true}.merge() if [:normalize] normalize_pattern(pattern) @to_normalize = true end @text_query = TextQuery.new(pattern, {:ignorecase => [:normalize]}) end |
Instance Method Details
#match?(text) ⇒ 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 |