Class: RefillTagger
Overview
Copyright 2015 The MITRE Corporation
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Method Summary collapse
-
#initialize ⇒ RefillTagger
constructor
A new instance of RefillTagger.
- #parse_text(text, precondition, search, content_group) ⇒ Object
Methods inherited from Tagger
Constructor Details
#initialize ⇒ RefillTagger
Returns a new instance of RefillTagger.
18 19 20 21 22 23 |
# File 'lib/taggers/refill_tagger.rb', line 18 def initialize @default_precondition = /\d+\s+refills?/i @default_search = /(\d+)(\s+refills?)/i @content_group = 1 @name = 'refill' end |
Instance Method Details
#parse_text(text, precondition, search, content_group) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/taggers/refill_tagger.rb', line 24 def parse_text(text, precondition, search, content_group) = super text, @default_precondition, @default_search, @content_group local_precondition = /refill\s+\d+\s+times?/i local_search = /(refill\s+)(\d+)(\s+times?)/i local_content_group = 2 += super text, local_precondition, local_search, local_content_group @precondition = /refills?\s+times\s+\d+/i @search = /(refills?\s+times\s+)(\d+)/i += super text, local_precondition, local_search, local_content_group local_precondition = /(?x)\b(?:no|zero|one|two|three|four|five|six|seven| eight|nine|ten|eleven|twelve)\s+refills?/i local_search = /(?x)\b(no|zero|one|two|three|four|five|six|seven| eight|nine|ten|eleven|twelve)(\s+refills?)/i local_content_group = 1 += super text, local_precondition, local_search, local_content_group @precondition = /(?x)refill\s+(?:no|zero|one|two|three|four|five|six| seven|eight|nine|ten|eleven|twelve)\s+times?/i @search = /(?x)(refill\s+)(no|zero|one|two|three|four|five|six| seven|eight|nine|ten|eleven|twelve)(\s+times?)/i local_content_group = 2 += super text, local_precondition, local_search, local_content_group @precondition = /(?x)(?:refills?\s+(?:times\s+)?)(?:none|zero|one|two| three|four|five|six|seven|eight|nine|ten|eleven|twelve)+/i @search = /(?x)(refills?\s+(?:times\s+)?)(none|zero|one|two| three|four|five|six|seven|eight|nine|ten|eleven|twelve)/i += super text, local_precondition, local_search, local_content_group return end |