class StrengthTagger

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.

Public Class Methods

new() click to toggle source
# File lib/taggers/strength_tagger.rb, line 18
def initialize
    @shared_search = /(?x)(?:units?|micrograms?|milligrams?|grams?|millimoles?
             |milliequivalents?|percent|(?:au|pnu)(?:\/|per\s*)ml
             |mg\.?(?:(?:\/|per\s*)(one|five|1|5)?\s*(?:ml|cc)\.?)?
             |\%|gr\.?|meq\.?|mmol\.?|ugm?s?|mcg)/i
    @default_precondition = /\s(\.\d+)\s+#{@shared_search}/i
    @default_search = /\s(\.\d+)\s*(#{@shared_search})/i
    @content_group = 1
    @name = 'strength'
end

Public Instance Methods

parse_text(text, precondition, search, content_group) click to toggle source
Calls superclass method Tagger#parse_text
# File lib/taggers/strength_tagger.rb, line 28
def parse_text(text, precondition, search, content_group)
    tags = super text, @default_precondition, @default_search
    local_precondition = /#{@shared_search}/i
    local_search = /(?x)\s((?:(?:\d+\/)?(?:\d+,)?\d+(?:\.\d+)?|one|two)
                  (?:\shundred|\sthousand)?(?:(?:-|\s+to\s+)
                  (?:(?:\d+,)?\d+(?:\.\d+)?|one|two)
                  (?:\shundred|\sthousand)?)?)\s*(#{@shared_search})/i
    tags += super text, local_precondition, local_search
    return tags
end