Class: SubstitutionTagger

Inherits:
Tagger
  • Object
show all
Defined in:
lib/taggers/substitution_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

#initializeSubstitutionTagger

Returns a new instance of SubstitutionTagger.



18
19
20
21
22
23
24
25
26
27
# File 'lib/taggers/substitution_tagger.rb', line 18

def initialize
    @default_precondition = /(?x)(?:no\s+(substitutes?|substitutions?)|dispense\s+as\s+written|may
               \s+not\s+substitutes?|substitutions?\s+(?:$be\s+)?not\s+
               (?:permitted|permissible|allowed))/i
    @default_search = /(?x)(no\s+(substitutes?|substitutions?)|dispense\s+as\s+written|may
                  \s+not\s+(substitutes?|substitutions?)\s+(?:$be\s+)?not\s+
                  (?:permitted|permissible|allowed))/i
    @content_group = 1
    @name = 'sub_status'
end

Instance Method Details

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



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/taggers/substitution_tagger.rb', line 28

def parse_text(text, precondition, search, content_group)
    tags_1a = super text, @default_precondition, @default_search
    local_precondition = /(?x)(?:may\s+substitute|substitutions?\s+(?:$be\s+)?
               (?:permitted|permissible|allowed))/i
    local_search = /(may\s+substitute|substitutions?\s+(?:$be\s+)?(?x)
                   (?:permitted|permissible|allowed))/i
    tags_1b = super text, local_precondition, local_search
    local_precondition = /(brand)|(generic)/i
    local_search = /((brand)|(generic))/i
    tags_1c = super text, local_precondition, local_search
    tags = tags_1a
    tags += tags_1b
    tags += tags_1c

    return tags
end