medattrib 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDhmYjBjNjgyZDVhZjJmYTE1YjQzZDNiNDVmZWE4MmI4ZWFjN2UyZA==
5
- data.tar.gz: !binary |-
6
- OWNjMmFkYWZmMGFjMDFiMzIzNDgxMjQwMTNjODAwM2M2MmNhNjljNA==
2
+ SHA1:
3
+ metadata.gz: 514426a7afac6df0fc2125664f5e1ee24a416d1b
4
+ data.tar.gz: 5714a6d8bd82639ca8f9a7f60eff1a59d14f27af
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NDU3OTE4MjVhODBlMzJhYzAzNGE1YjZjMTA3YjRmNmEyNmE5MzQ5YTFhMmQ3
10
- MTQ2MTljMmJhOGVlMmNlY2M5NWQ0ZDcwNWFmNDY0ZTM5OGM3ZDc0MzFlNWM4
11
- OGE5OTQyMjNlYzVkMzk4NTk1YTRlMTQ2ZmVmMTBjNzA1OTQwMDY=
12
- data.tar.gz: !binary |-
13
- YTgwMzE0NjdlZDgzYTJmMWI4MjQyMmM0ZDI3YzEwNzU5ODM2MWQxYjhhZmI0
14
- MjliNDkyMWNiOTJmMDQ1NGQxZjVkM2Q0OTFiNzEyYTYxZTRmYmUwZGQzNzhl
15
- MjBiNTRmZjk3N2FjYmE3ZTg2N2IxNDQyZTVlYTMxYzNlM2Y5ZmE=
6
+ metadata.gz: 0213df3d7b3535f9940ec368a88009687db9fbc8d2b6a0a906f154c1ee9a322a913fb2ce3799ad10d9d552ce3e09eb4055c340f3afae9392793891affe3e37bf
7
+ data.tar.gz: 4c4739843ee124a0317906a0d69d8742942ed655a581f4387f280a1ce3742150a3a5ec5e8530072466d24d90c6a39eac98965cca05b7b27b036684c2f78c84d3
data/bin/medattrib CHANGED
File without changes
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ =begin
3
+ Copyright 2015 The MITRE Corporation.
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ zlimitations under the License.”
15
+ =end
16
+
17
+ class DoseAmountListTagger < ListTagger
18
+ def initialize
19
+ @name = 'doseamount'
20
+ @list = [/(low|high)
21
+
22
+ -? ?doses?/i]
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ =begin
3
+ Copyright 2015 The MITRE Corporation.
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ zlimitations under the License.”
15
+ =end
16
+
17
+ class DoseFormTagger < ListTagger
18
+ def initialize
19
+ @name = 'doseform'
20
+ @list = [/low-? ?doses?/i]
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ =begin
3
+ Copyright 2015 The MITRE Corporation.
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ zlimitations under the License.”
15
+ =end
16
+
17
+ class DoseAmountListTagger < ListTagger
18
+ def initialize
19
+ @name = 'doseamount'
20
+ @list = [/(low|high)-? ?doses?/i]
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ =begin
3
+ Copyright 2015 The MITRE Corporation.
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ zlimitations under the License.”
15
+ =end
16
+
17
+ class DoseAmountListTagger < ListTagger
18
+ def initialize
19
+ @name = 'doseform'
20
+ @list = [/low-? ?doses?/i]
21
+ end
22
+ end
@@ -21,9 +21,10 @@ class FrequencyTagger < ListTagger
21
21
  @list = [/q\.?\s?(?:a\.?m\.?|morning)/i,
22
22
  /q\.?\s?(?:p\.?m\.?|afternoon)/i,
23
23
  /q\.?\s?h\.?(?:s\.?)?/i,
24
- /nightly/i,
25
- /bedtime/i,
26
- /stat\b/i,
24
+ /(?:at\s*)?night(?:ly)?/i,
25
+ /(?:at\s*)bedtime/i,
26
+ /(?:at\s*)midday/i,
27
+ /in the morning/i,
27
28
  /immediately/i,
28
29
  /hs/i,
29
30
  /(?x)(?:(?:every|q\.?)\s*(?:\d\-)?
@@ -34,18 +35,19 @@ class FrequencyTagger < ListTagger
34
35
  (?:h(?:rs?|(?:ours?))?\.?))/i,
35
36
  /q\.?\s?d(?:\.|ay)?/i,
36
37
  /q-day/i,
37
- /(?x)(?:(?:every|each)\s*
38
- (?:day|hour|night|week|morning|afternoon|evening))/i,
39
- /(?:(?:once|twice)\s+(?:(?:a|per)\s+(?:day|week|night)))/i,
38
+ /(?x)(?:(?:every|each)\s*\d?\s*
39
+ (?:day|night|week|morning|afternoon|evening))/i,
40
+ /(?:(?:once|twice)\s+(?:(?:a|per)\s+(?:day|week|night|month)))/i,
40
41
  /(?x)(?:(?:(?:(?:\d\-)?(?:two|three|four|five|\d)
41
42
  \s+times?\s+)|(once|twice)\s+)?(?:daily|weekly|hourly))/i,
42
43
  /qod/i,
43
44
  /every other day/i,
44
45
  /[bqt]\.i\.d\./i,
45
46
  /[bqt]idh?\b/i,
46
- /(?x)(?:(?:\d\-)?(?:two|three|four|five|\d)\s+
47
- (?:times?|days?|nights?)\s?
48
- (?:a|per|\/)\s?(?:day|week|night))/i,
47
+ /(?x)(?:(?:\d\-?)?(?:one|two|three|four|five|\d)\s+
48
+ (?:times?|days?|nights?)?\s?
49
+ (?:a|per|\/)\s?(?:day|week|night|month))/i,
50
+ /(?:once|twice|(?:(?:\d+|one|two|three|four|five)\s*times))?monthly/i,
49
51
  /(?:as|when)\s+needed/i,
50
52
  /p\.?r\.?n\.?/i]
51
53
  end
data/lib/medattrib.rb CHANGED
@@ -30,7 +30,6 @@ puts annotated_string
30
30
  #=> "take <freq>daily</freq>."
31
31
  =end
32
32
 
33
- gem 'standoff', '>=0.0.3' #data model
34
33
  require 'standoff'
35
34
 
36
35
  require_relative 'tagger.rb' #taggers based on regex contexts
@@ -49,16 +48,19 @@ require_relative 'taggers/timing_tagger.rb'
49
48
 
50
49
  #ListTagger child classes:
51
50
  require_relative 'list_taggers/dose_form_tagger.rb'
51
+ require_relative 'list_taggers/dose_amount_list_tagger.rb'
52
52
  require_relative 'list_taggers/route_tagger.rb'
53
53
  require_relative 'list_taggers/frequency_tagger.rb'
54
54
 
55
55
 
56
56
  class MedAttrib
57
57
  def parse (text)
58
- text = REXML::Text.new(text, false, nil, false).to_s # escape special characters
58
+
59
+ # text = REXML::Text.new(text, true, nil, false).to_s # escape special characters
59
60
  taggersExceptDoseAmount = [StrengthTagger.new,
60
61
  StrengthUnitTagger.new,
61
62
  DoseFormTagger.new,
63
+ DoseAmountListTagger.new,
62
64
  RouteTagger.new,
63
65
  IndicationTagger.new,
64
66
  FrequencyTagger.new,
@@ -72,6 +74,7 @@ class MedAttrib
72
74
  taggersExceptDoseAmount.each {|tagger| tags += tagger.parse_main text}
73
75
  as = Standoff::AnnotatedString.new(:signal => text, :tags => tags)
74
76
  DoseAmountTagger.new.parse_annotated_string as
77
+
75
78
  partial_xml = as.to_s
76
79
  as
77
80
 
data/lib/tagger.rb CHANGED
@@ -16,11 +16,11 @@ limitations under the License.
16
16
 
17
17
  class Tagger
18
18
 
19
- @@unit_search_global =
20
- /(?:units?|micrograms?|milligrams?|mg|grams?|millimoles?
21
- |milliequivalents?|percent|(?:au|pnu)(?:\/|per\s*)ml
22
- |mg\.?(?:(?:\/|per\s*)(one|five|1|5)?\s*(?:ml|cc)\.?)?
23
- |\%|gr\.?|meq\.?|mmol\.?|ugm?s?|mcg)/i
19
+ @@unit_search_global =
20
+ /(?:mg\.?(?:(?:\/|\s*per\s*)(one|five|1|5)?\s*(?:ml|cc|m2|meters? squared|m squared)\.?)?
21
+ |units?|micrograms?|milligrams?|mg|grams?|millimoles?|milliequivalents?|percent
22
+ |(?:au|pnu)(?:\/|per\s*)ml
23
+ |\%|gr\.?|meq\.?|mmol\.?|ugm?s?|mcg)/ix
24
24
 
25
25
  @@number_word_search =
26
26
  /(?:one|two|three|four|five|six|seven|eight|nine|ten|fifteen|twenty|thirty|sixty)/
@@ -18,7 +18,7 @@ class DurationTagger < Tagger
18
18
  def initialize
19
19
  @shared_search = /(?x)(?:\d+(?:\-\d)?|one|two|three|four|five|six|seven|
20
20
  eight|nine|ten|fifteen|twenty|thirty|sixty)\s*
21
- (?:days?|weeks?|wks|months?|d\b)/i
21
+ (?:days?|weeks?|wks|months?|cycles?|d\b)/i
22
22
  @default_precondition = /#{@shared_search}/i
23
23
  @default_search = /(?x)((?:for|x)\s?(?:a\stotal\sof\s+)?(?:up\s+to\s+)?
24
24
  (?:the\snext\s+)?)(#{@shared_search})/i
@@ -28,9 +28,9 @@ class StrengthTagger < Tagger
28
28
  def parse_text(text, precondition, search, content_group)
29
29
  tags = super text, @default_precondition, @default_search
30
30
  local_precondition = /#{@shared_search}/i
31
- local_search = /(?x)\s((?:(?:\d+\/)?\d+(?:\.\d+)?|one|two)
31
+ local_search = /(?x)\s((?:(?:\d+\/)?(?:\d+,)?\d+(?:\.\d+)?|one|two)
32
32
  (?:\shundred|\sthousand)?(?:(?:-|\s+to\s+)
33
- (?:\d+(?:\.\d+)?|one|two)
33
+ (?:(?:\d+,)?\d+(?:\.\d+)?|one|two)
34
34
  (?:\shundred|\sthousand)?)?)\s*(#{@shared_search})/i
35
35
  tags += super text, local_precondition, local_search
36
36
  return tags
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medattrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cheryl Clark
@@ -18,14 +18,14 @@ dependencies:
18
18
  name: standoff
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ! '>='
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.0.5
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ! '>='
28
+ - - ">="
29
29
  - !ruby/object:Gem::Version
30
30
  version: 0.0.5
31
31
  description: A text tagger that annotates prescription concepts
@@ -39,12 +39,15 @@ files:
39
39
  - README.md
40
40
  - bin/medattrib
41
41
  - lib/list_tagger.rb
42
+ - lib/list_taggers/#dose_amount_list_tagger.rb#
43
+ - lib/list_taggers/DoseAmountListTagger.rb~
44
+ - lib/list_taggers/dose_amount_list_tagger.rb
45
+ - lib/list_taggers/dose_amount_list_tagger.rb~
42
46
  - lib/list_taggers/dose_form_tagger.rb
43
47
  - lib/list_taggers/frequency_tagger.rb
44
48
  - lib/list_taggers/route_tagger.rb
45
49
  - lib/medattrib.rb
46
50
  - lib/run_medattrib.rb
47
- - lib/run_medattrib.rb~
48
51
  - lib/tagger.rb
49
52
  - lib/taggers/dispense_quantity_tagger.rb
50
53
  - lib/taggers/dose_amount_tagger.rb
@@ -65,17 +68,17 @@ require_paths:
65
68
  - lib
66
69
  required_ruby_version: !ruby/object:Gem::Requirement
67
70
  requirements:
68
- - - ! '>='
71
+ - - ">="
69
72
  - !ruby/object:Gem::Version
70
73
  version: '0'
71
74
  required_rubygems_version: !ruby/object:Gem::Requirement
72
75
  requirements:
73
- - - ! '>='
76
+ - - ">="
74
77
  - !ruby/object:Gem::Version
75
78
  version: '0'
76
79
  requirements: []
77
80
  rubyforge_project:
78
- rubygems_version: 2.4.3
81
+ rubygems_version: 2.5.2.1
79
82
  signing_key:
80
83
  specification_version: 4
81
84
  summary: MedAttrib!
@@ -1,9 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- require "medattrib"
4
-
5
- tagger = MedAttrib.new
6
-
7
- while line = gets do
8
- puts tagger.parse(line).to_s
9
- end