Class: DispenseQuantityTagger

Inherits:
Tagger
  • Object
show all
Defined in:
lib/taggers/dispense_quantity_tagger.rb

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

Methods inherited from Tagger

#normalize, #parse_main

Constructor Details

#initializeDispenseQuantityTagger

Returns a new instance of DispenseQuantityTagger.



18
19
20
21
22
23
# File 'lib/taggers/dispense_quantity_tagger.rb', line 18

def initialize
    @default_precondition = /(?:dispense|quantity)\s+(?:$be\s+)?\d+/i
    @default_search = /((?:(?:dispense|quantity)\s+)(?:$be\s+)?)(\d+)/i
    @content_group = 2
    @name = 'dispense'
end

Instance Method Details

#parse_text(text, precondition, search, content_group) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/taggers/dispense_quantity_tagger.rb', line 25

def parse_text(text, precondition, search, content_group)
    tags = super text, @default_precondition, @default_search
    local_precondition = /(?x)(?:dispense|quantity)\s+(?:$be\s+)?(?:one|two|three|
                four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|
                twenty|thirty|forty|fifty|sixty)/i
    local_search = /(?x)((?:dispense|quantity)\s+(?:$be\s+)?)(one|two|
                    three|four|five|six|seven|eight|nine|ten|eleven|
                    twelve|thirty|forty|fifty|sixty)/i
    tags += super text, local_precondition, local_search
    return tags
end