Class: StrengthTagger
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 ⇒ StrengthTagger
constructor
A new instance of StrengthTagger.
- #parse_text(text, precondition, search, content_group) ⇒ Object
Methods inherited from Tagger
Constructor Details
#initialize ⇒ StrengthTagger
Returns a new instance of StrengthTagger.
18 19 20 21 22 23 24 25 26 27 |
# 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 |
Instance Method Details
#parse_text(text, precondition, search, content_group) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/taggers/strength_tagger.rb', line 28 def parse_text(text, precondition, search, content_group) = 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 += super text, local_precondition, local_search return end |