abstractor 4.2.2 → 4.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/abstractor/abstractor_abstractions/_ungrouped_abstractions_list.html.haml +1 -1
- data/app/views/abstractor/abstractor_abstractions/edit.html.haml +2 -0
- data/db/migrate/20150223033848_add_custom_nlp_provider_to_abstractor_abstraction_sources.rb +5 -0
- data/lib/abstractor/custom_nlp_provider.rb +112 -0
- data/lib/abstractor/enum.rb +5 -0
- data/lib/abstractor/methods/controllers/abstractor_suggestions_controller.rb +24 -2
- data/lib/abstractor/methods/models/abstractor_abstraction.rb +22 -0
- data/lib/abstractor/methods/models/abstractor_subject.rb +58 -1
- data/lib/abstractor/methods/models/abstractor_suggestion.rb +3 -3
- data/lib/abstractor/setup.rb +2 -0
- data/lib/abstractor/version.rb +1 -1
- data/lib/tasks/abstractor_tasks.rake +23 -0
- metadata +49 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3703df4ac762d87fe77f41a0d3109533896943b
|
4
|
+
data.tar.gz: 10fb7cb823fa9ef4b2b0ccddb481d461fe3d6cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c939fc27c31fc6fb653f0ad6a9ff6e0dc17b8ef9c386b27a7051c1142d0fb05efedb2f84f37e741f39e06d6fc9e0b0c6b3e2c9f1a662ff5b5800832965e55309
|
7
|
+
data.tar.gz: b510b62d7fd32f365590f34f793fb767a589b6e5194c4603d1bf8b3f99c203355c9277fcae274f646a029d1eaa726e303e7f670684fab29bbcc1f70940942f62
|
@@ -1,5 +1,5 @@
|
|
1
1
|
.abstractor_abstractions_ungrouped
|
2
|
-
- ungrouped_subjects = about.class.abstractor_subjects(grouped: false, namespace_type: namespace_type, namespace_id: namespace_id)
|
2
|
+
- ungrouped_subjects = about.class.abstractor_subjects(grouped: false, namespace_type: namespace_type, namespace_id: namespace_id).order('abstractor_subjects.id')
|
3
3
|
- if ungrouped_subjects.any?
|
4
4
|
%fieldset
|
5
5
|
.abstractor_abstractions_header
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module Abstractor
|
2
|
+
module CustomNlpProvider
|
3
|
+
##
|
4
|
+
# Determines the suggestion endpoint for the passed in custom NLP provider.
|
5
|
+
#
|
6
|
+
# The endpoint is assumed to be configured in config/abstractor/custom_nlp_providers.yml.
|
7
|
+
# A template configratuon file can be generated in the host application by
|
8
|
+
# calling the rake task abstractor:custom_nlp_provider.
|
9
|
+
# @param [String] custom_nlp_provider The name of the custom NLP provider whose endpoint should be determined.
|
10
|
+
# @return [String] The endpoint.
|
11
|
+
def self.determine_suggestion_endpoint(custom_nlp_provider)
|
12
|
+
suggestion_endpoint = YAML.load_file("#{Rails.root}/config/abstractor/custom_nlp_providers.yml")[custom_nlp_provider]['suggestion_endpoint'][Rails.env]
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Formats the object values and object value variants for the passed in Abstractor::AbstractorSubject.
|
17
|
+
#
|
18
|
+
# Preperation for submision to a custom NLP provider endpoint.
|
19
|
+
#
|
20
|
+
# @example Example of body prepared by Abstractor to submit to an custom NLP provider
|
21
|
+
# {
|
22
|
+
# "abstractor_abstraction_schema_id":1,
|
23
|
+
# "abstractor_abstraction_id":1,
|
24
|
+
# "abstractor_abstraction_source_id":1,
|
25
|
+
# "source_type": "PathologyCase",
|
26
|
+
# "source_method": "note_text",
|
27
|
+
# "text": "The patient has a diagnosis of glioblastoma. GBM does not have a good prognosis. But I can't rule out meningioma.",
|
28
|
+
# "object_values": [
|
29
|
+
# { "value": "glioblastoma, nos",
|
30
|
+
# "object_value_variants":[
|
31
|
+
# { "value": "glioblastoma" },
|
32
|
+
# { "value": "gbm" },
|
33
|
+
# { "value": "spongioblastoma multiforme"}
|
34
|
+
# ]
|
35
|
+
# },
|
36
|
+
# { "value": "meningioma, nos",
|
37
|
+
# "object_value_variants":[
|
38
|
+
# { "value": "meningioma" },
|
39
|
+
# { "value": "leptomeningioma" },
|
40
|
+
# { "value": "meningeal fibroblastoma" }
|
41
|
+
# ]
|
42
|
+
# }
|
43
|
+
# ]
|
44
|
+
# }
|
45
|
+
#
|
46
|
+
#
|
47
|
+
# @param [Abstractor::AbstractorSubject] abstractor_subject The abstractor subject having the desired object values.
|
48
|
+
# @return [Hash]
|
49
|
+
def self.abstractor_object_values(abstractor_subject)
|
50
|
+
object_values = []
|
51
|
+
abstractor_subject.abstractor_abstraction_schema.abstractor_object_values.each do |abstractor_object_value|
|
52
|
+
object_value = {}
|
53
|
+
object_value[:value] = abstractor_object_value.value
|
54
|
+
object_value[:object_value_variants] = []
|
55
|
+
abstractor_object_value.abstractor_object_value_variants.each do |abstractor_object_value_variant|
|
56
|
+
object_value[:object_value_variants] << { value: abstractor_object_value_variant.value }
|
57
|
+
end
|
58
|
+
object_values << object_value
|
59
|
+
end
|
60
|
+
object_values
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Formats the JSON body in preparation for submision to a custom NLP provider endpoint.
|
65
|
+
#
|
66
|
+
# @example Example of body prepared by Abstractor to submit to an custom NLP provider
|
67
|
+
# {
|
68
|
+
# "abstractor_abstraction_schema_id":1,
|
69
|
+
# "abstractor_abstraction_id":1,
|
70
|
+
# "abstractor_abstraction_source_id":1,
|
71
|
+
# "source_type": "PathologyCase",
|
72
|
+
# "source_method": "note_text",
|
73
|
+
# "text": "The patient has a diagnosis of glioblastoma. GBM does not have a good prognosis. But I can't rule out meningioma.",
|
74
|
+
# "object_values": [
|
75
|
+
# { "value": "glioblastoma, nos",
|
76
|
+
# "object_value_variants":[
|
77
|
+
# { "value": "glioblastoma" },
|
78
|
+
# { "value": "gbm" },
|
79
|
+
# { "value": "spongioblastoma multiforme"}
|
80
|
+
# ]
|
81
|
+
# },
|
82
|
+
# { "value": "meningioma, nos",
|
83
|
+
# "object_value_variants":[
|
84
|
+
# { "value": "meningioma" },
|
85
|
+
# { "value": "leptomeningioma" },
|
86
|
+
# { "value": "meningeal fibroblastoma" }
|
87
|
+
# ]
|
88
|
+
# }
|
89
|
+
# ]
|
90
|
+
# }
|
91
|
+
#
|
92
|
+
#
|
93
|
+
# @param [Abstractor::AbstractorAbstraction] abstractor_abstraction The abstractor abstraction to be formated for submission to a custom nlp provider endpoint.
|
94
|
+
# @param [Abstractor::AbstractorAbstractionSource] abstractor_abstraction_source The abstractor abstraction source to be formated for submission to a custom nlp provider endpoint.
|
95
|
+
# @param [String] abstractor_text The text be formated for submission to a custom nlp provider endpoint.
|
96
|
+
# @param [Hash] source The hash of values representing the source for submission to a custom nlp provider endpoint.
|
97
|
+
# @return [Hash] The formatted body.
|
98
|
+
def self.format_body_for_suggestion_endpoint(abstractor_abstraction, abstractor_abstraction_source, abstractor_text, source)
|
99
|
+
object_values = CustomNlpProvider.abstractor_object_values(abstractor_abstraction.abstractor_subject)
|
100
|
+
{
|
101
|
+
abstractor_abstraction_schema_id: abstractor_abstraction.abstractor_subject.abstractor_abstraction_schema.id,
|
102
|
+
abstractor_abstraction_id: abstractor_abstraction.id,
|
103
|
+
abstractor_abstraction_source_id: abstractor_abstraction_source.id,
|
104
|
+
source_id: source[:source_id],
|
105
|
+
source_type: source[:source_type].to_s,
|
106
|
+
source_method: source[:source_method],
|
107
|
+
text: abstractor_text,
|
108
|
+
object_values: object_values
|
109
|
+
}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/abstractor/enum.rb
CHANGED
@@ -10,5 +10,10 @@ module Abstractor
|
|
10
10
|
|
11
11
|
ABSTRACTOR_SECTION_TYPE_CUSTOM = 'custom'
|
12
12
|
ABSTRACTOR_SECTION_TYPE_NAME_VALUE = 'name/value'
|
13
|
+
|
14
|
+
ABSTRACTOR_SUGGESTION_STATUS_NEEDS_REVIEW = 'Needs review'
|
15
|
+
ABSTRACTOR_SUGGESTION_STATUS_ACCEPTED = 'Accepted'
|
16
|
+
ABSTRACTOR_SUGGESTION_STATUS_REJECTED = 'Rejected'
|
17
|
+
ABSTRACTOR_SUGGESTION_STATUSES = [ABSTRACTOR_SUGGESTION_STATUS_NEEDS_REVIEW, ABSTRACTOR_SUGGESTION_STATUS_ACCEPTED, ABSTRACTOR_SUGGESTION_STATUS_REJECTED]
|
13
18
|
end
|
14
19
|
end
|
@@ -4,6 +4,25 @@ module Abstractor
|
|
4
4
|
module AbstractorSuggestionsController
|
5
5
|
def self.included(base)
|
6
6
|
base.send :before_filter, :set_abstractor_suggestion, :only => [:update]
|
7
|
+
base.send :before_filter, :set_abstractor_abstraction
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
respond_to do |format|
|
12
|
+
begin
|
13
|
+
suggestion = params[:abstractor_suggestion]
|
14
|
+
abstractor_abstraction_source = Abstractor::AbstractorAbstractionSource.find(suggestion[:abstractor_abstraction_source_id])
|
15
|
+
abstractor_suggestion = nil
|
16
|
+
Abstractor::AbstractorSuggestion.transaction do
|
17
|
+
suggestion[:suggestion_sources].each do |suggestion_source|
|
18
|
+
abstractor_suggestion = @abstractor_abstraction.abstractor_subject.suggest(@abstractor_abstraction, abstractor_abstraction_source, suggestion_source[:match_value], suggestion_source[:sentence_match_value], suggestion[:source_id], suggestion[:source_type], suggestion[:source_method], nil, suggestion[:value], suggestion[:unknown], suggestion[:not_applicable], nil, nil)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
format.json { render json: abstractor_suggestion, status: :created }
|
22
|
+
rescue => e
|
23
|
+
format.json { render json: "Error processing request to create abstractor suggestions: #{e}", status: :unprocessable_entity }
|
24
|
+
end
|
25
|
+
end
|
7
26
|
end
|
8
27
|
|
9
28
|
def update
|
@@ -17,12 +36,15 @@ module Abstractor
|
|
17
36
|
end
|
18
37
|
|
19
38
|
private
|
20
|
-
def
|
39
|
+
def set_abstractor_abstraction
|
21
40
|
@abstractor_abstraction = Abstractor::AbstractorAbstraction.find(params[:abstractor_abstraction_id])
|
22
|
-
@abstractor_suggestion = Abstractor::AbstractorSuggestion.find(params[:id])
|
23
41
|
@about = @abstractor_abstraction.about
|
24
42
|
end
|
25
43
|
|
44
|
+
def set_abstractor_suggestion
|
45
|
+
@abstractor_suggestion = Abstractor::AbstractorSuggestion.find(params[:id])
|
46
|
+
end
|
47
|
+
|
26
48
|
def abstractor_suggestion_params
|
27
49
|
params.require(:abstractor_suggestion).permit(:id, :abstractor_abstraction_id, :abstractor_suggestion_status_id, :suggested_value, :unknown, :not_applicable, :deleted_at, :_destroy)
|
28
50
|
end
|
@@ -90,6 +90,28 @@ module Abstractor
|
|
90
90
|
ais.abstractor_abstraction_source == abstractor_abstraction_source
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Returns all the suggestions for the abstraction with a suggestion status of 'needs review'
|
96
|
+
#
|
97
|
+
# @return [ActiveRecord::Relation] List of [Abstractor::AbstractorSuggestion].
|
98
|
+
def unreviewed_abstractor_suggestions
|
99
|
+
abstractor_suggestions.select { |abstractor_suggestion| abstractor_suggestion.abstractor_suggestion_status.name == Abstractor::Enum::ABSTRACTOR_SUGGESTION_STATUS_NEEDS_REVIEW }
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# Remove suggestions on the abstraction with a suggestion status of 'needs review' that are not present in the array of hashes representing suggestions passed in.
|
104
|
+
#
|
105
|
+
# @param [Array<Hash>] suggestions
|
106
|
+
# @return [void]
|
107
|
+
def remove_unreviewed_suggestions_not_matching_suggestions(suggestions)
|
108
|
+
unreviewed_abstractor_suggestions.each do |abstractor_suggestion|
|
109
|
+
not_detritus = suggestions.detect { |suggestion| suggestion[:suggestion] == abstractor_suggestion.suggested_value }
|
110
|
+
unless not_detritus
|
111
|
+
abstractor_suggestion.destroy
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
93
115
|
end
|
94
116
|
|
95
117
|
module ClassMethods
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rest_client'
|
1
2
|
module Abstractor
|
2
3
|
module Methods
|
3
4
|
module Models
|
@@ -37,6 +38,7 @@ module Abstractor
|
|
37
38
|
# * 'nlp suggestion': creates instances of Abstractor::AbstractorSuggestion based on natural language processing (nlp) logic searching the text provided by the Abstractor::AbstractorSubject#from_methd attribute.
|
38
39
|
# * 'custom suggestion': creates instances of Abstractor::AbstractorSuggestion based on custom logic delegated to the method configured in AbstractorAbstractionSource#custom_method.
|
39
40
|
# * 'indirect': creates an instance of Abstractor::AbstractorIndirectSource wih null source_type, source_id, source_method attributes -- all waiting to be set upon selection of an indirect source.
|
41
|
+
# * 'custom nlp suggestion': looks up a suggestion endpoint to submit text, object values and object value variants to an external, custom NLP provider for the delegation of suggestion generation.
|
40
42
|
#
|
41
43
|
# @param [ActiveRecord::Base] about The entity to abstract. An instance of the class specified in the Abstractor::AbstractorSubject#subject_type attribute.
|
42
44
|
# @return [void]
|
@@ -51,6 +53,8 @@ module Abstractor
|
|
51
53
|
abstract_custom_suggestion(about, abstractor_abstraction, abstractor_abstraction_source)
|
52
54
|
when 'indirect'
|
53
55
|
abstract_indirect_source(about, abstractor_abstraction, abstractor_abstraction_source)
|
56
|
+
when 'custom nlp suggestion'
|
57
|
+
abstract_custom_nlp_suggestion(about, abstractor_abstraction, abstractor_abstraction_source)
|
54
58
|
end
|
55
59
|
end
|
56
60
|
end
|
@@ -127,13 +131,66 @@ module Abstractor
|
|
127
131
|
# @param [Abstractor::AbstractorAbstractionSource] abstractor_abstraction_source The instance of the Abstractor::AbstractorAbstractionSource that provides the custom method to invoke on the abstractable entity to make custom suggestions.
|
128
132
|
# @return [void]
|
129
133
|
def abstract_custom_suggestion(about, abstractor_abstraction, abstractor_abstraction_source)
|
130
|
-
suggestions = about.send(abstractor_abstraction_source.custom_method)
|
134
|
+
suggestions = about.send(abstractor_abstraction_source.custom_method, abstractor_abstraction)
|
131
135
|
suggestions.each do |suggestion|
|
132
136
|
suggest(abstractor_abstraction, abstractor_abstraction_source, nil, nil, about.id, about.class.to_s, abstractor_abstraction_source.from_method, abstractor_abstraction_source.section_name, suggestion[:suggestion], nil, nil, abstractor_abstraction_source.custom_method, suggestion[:explanation])
|
133
137
|
end
|
134
138
|
create_unknown_abstractor_suggestion(about, abstractor_abstraction, abstractor_abstraction_source)
|
135
139
|
end
|
136
140
|
|
141
|
+
# Looks up a suggestion endpoint to submit text, object values and object value variants
|
142
|
+
# to an external, custom NLP provider for the delegation of suggestion generation.
|
143
|
+
#
|
144
|
+
# The method will determine an endpoint by looking in
|
145
|
+
# config/abstractor/custom_nlp_providers.yml based on the current environment
|
146
|
+
# and the value of the AbstractorAbstractionSource#custom_nlp_provider attribute.
|
147
|
+
#
|
148
|
+
# A template configratuon file can be generated in the the host application by
|
149
|
+
# calling the rake task abstractor:custom_nlp_provider. The configuration
|
150
|
+
# is expected to provide different endpoints per environment, per provider.
|
151
|
+
# Abstractor will format a JSON body to post to the discovered endpoint.
|
152
|
+
# The custom NLP provider will be expected to generate suggestions
|
153
|
+
# and post them back to /abstractor_abstractions/:abstractor_abstraction_id/abstractor_suggestions/
|
154
|
+
# @example Example of body prepared by Abstractor to submit to an custom NLP provider
|
155
|
+
# {
|
156
|
+
# "abstractor_abstraction_schema_id":1,
|
157
|
+
# "abstractor_abstraction_id":1,
|
158
|
+
# "abstractor_abstraction_source_id":1,
|
159
|
+
# "source_type": "PathologyCase",
|
160
|
+
# "source_method": "note_text",
|
161
|
+
# "text": "The patient has a diagnosis of glioblastoma. GBM does not have a good prognosis. But I can't rule out meningioma.",
|
162
|
+
# "object_values": [
|
163
|
+
# { "value": "glioblastoma, nos",
|
164
|
+
# "object_value_variants":[
|
165
|
+
# { "value": "glioblastoma" },
|
166
|
+
# { "value": "gbm" },
|
167
|
+
# { "value": "spongioblastoma multiforme"}
|
168
|
+
# ]
|
169
|
+
# },
|
170
|
+
# { "value": "meningioma, nos",
|
171
|
+
# "object_value_variants":[
|
172
|
+
# { "value": "meningioma" },
|
173
|
+
# { "value": "leptomeningioma" },
|
174
|
+
# { "value": "meningeal fibroblastoma" }
|
175
|
+
# ]
|
176
|
+
# }
|
177
|
+
# ]
|
178
|
+
# }
|
179
|
+
#
|
180
|
+
# @param [ActiveRecord::Base] about The entity to abstract. An instance of the class specified in the Abstractor::AbstractorSubject#subject_type attribute.
|
181
|
+
# @param [Abstractor::AbstractorAbstraction] abstractor_abstraction The instance of Abstractor::AbstractorAbstraction to make suggestions against.
|
182
|
+
# @param [Abstractor::AbstractorAbstractionSource] abstractor_abstraction_source The instance of the Abstractor::AbstractorAbstractionSource that provides the name of the custom NLP provider.
|
183
|
+
# @return [void]
|
184
|
+
def abstract_custom_nlp_suggestion(about, abstractor_abstraction, abstractor_abstraction_source)
|
185
|
+
suggestion_endpoint = CustomNlpProvider.determine_suggestion_endpoint(abstractor_abstraction_source.custom_nlp_provider)
|
186
|
+
object_values = CustomNlpProvider.abstractor_object_values(self)
|
187
|
+
abstractor_abstraction_source.normalize_from_method_to_sources(about).each do |source|
|
188
|
+
abstractor_text = Abstractor::AbstractorAbstractionSource.abstractor_text(source)
|
189
|
+
body = Abstractor::CustomNlpProvider.format_body_for_suggestion_endpoint(abstractor_abstraction, abstractor_abstraction_source, abstractor_text, source)
|
190
|
+
RestClient.post(suggestion_endpoint, body.to_json, content_type: :json)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
137
194
|
def abstract_unknown(about, abstractor_abstraction, abstractor_abstraction_source)
|
138
195
|
create_unknown_abstractor_suggestion(about, abstractor_abstraction, abstractor_abstraction_source)
|
139
196
|
end
|
@@ -9,10 +9,10 @@ module Abstractor
|
|
9
9
|
base.send :belongs_to, :abstractor_abstraction
|
10
10
|
base.send :belongs_to, :abstractor_suggestion_status
|
11
11
|
|
12
|
-
base.send :has_one, :abstractor_suggestion_object_value
|
13
|
-
base.send :has_one, :abstractor_object_value, :
|
12
|
+
base.send :has_one, :abstractor_suggestion_object_value, dependent: :destroy
|
13
|
+
base.send :has_one, :abstractor_object_value, through: :abstractor_suggestion_object_value
|
14
14
|
|
15
|
-
base.send :has_many, :abstractor_suggestion_sources
|
15
|
+
base.send :has_many, :abstractor_suggestion_sources, dependent: :destroy
|
16
16
|
|
17
17
|
# base.send :attr_accessible, :abstractor_abstraction, :abstractor_abstraction_id, :abstractor_suggestion_sources, :abstractor_suggestion_source_id, :abstractor_suggestion_status, :abstractor_suggestion_status_id, :suggested_value, :deleted_at, :unknown, :not_applicable
|
18
18
|
|
data/lib/abstractor/setup.rb
CHANGED
@@ -9,6 +9,7 @@ module Abstractor
|
|
9
9
|
Abstractor::AbstractorObjectType.where(value: 'radio button list').first_or_create
|
10
10
|
Abstractor::AbstractorObjectType.where(value: 'date').first_or_create
|
11
11
|
Abstractor::AbstractorObjectType.where(value: 'dynamic list').first_or_create
|
12
|
+
Abstractor::AbstractorObjectType.where(value: 'text').first_or_create
|
12
13
|
|
13
14
|
puts 'Setting up Abstractor::AbstractorRuleType'
|
14
15
|
Abstractor::AbstractorRuleType.where(name: 'name/value', description:'search for value associated with name').first_or_create
|
@@ -28,6 +29,7 @@ module Abstractor
|
|
28
29
|
Abstractor::AbstractorAbstractionSourceType.where(name: 'nlp suggestion').first_or_create
|
29
30
|
Abstractor::AbstractorAbstractionSourceType.where(name: 'custom suggestion').first_or_create
|
30
31
|
Abstractor::AbstractorAbstractionSourceType.where(name: 'indirect').first_or_create
|
32
|
+
Abstractor::AbstractorAbstractionSourceType.where(name: 'custom nlp suggestion').first_or_create
|
31
33
|
|
32
34
|
puts 'Setting up Abstractor::AbstractorSectionType'
|
33
35
|
Abstractor::AbstractorSectionType.where(name: Abstractor::Enum::ABSTRACTOR_SECTION_TYPE_CUSTOM).first_or_create
|
data/lib/abstractor/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'zip'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
namespace :abstractor do
|
5
6
|
namespace :setup do
|
@@ -26,6 +27,28 @@ namespace :abstractor do
|
|
26
27
|
fo.print open('https://github.com/louismullie/stanford-core-nlp/blob/master/bin/bridge.jar?raw=true').read
|
27
28
|
end
|
28
29
|
end
|
30
|
+
|
31
|
+
desc "Custom NLP provider"
|
32
|
+
task(custom_nlp_provider: :environment) do
|
33
|
+
FileUtils.mkdir_p 'config/abstractor'
|
34
|
+
|
35
|
+
template = <<EOS
|
36
|
+
# Add the actual name of your custom nlp provider.
|
37
|
+
# Specify the sugestion endpoint per environemnt.
|
38
|
+
custom_nlp_provider_name:
|
39
|
+
suggestion_endpoint:
|
40
|
+
development: http://custom-nlp-provider.dev/suggest
|
41
|
+
test: http://custom-nlp-provider.test/suggest
|
42
|
+
staging: http://custom-nlp-provider-staging.org/suggest
|
43
|
+
production: http://custom-nlp-provider.org/suggest
|
44
|
+
EOS
|
45
|
+
|
46
|
+
if !File.exist?('config/abstractor/custom_nlp_providers.yml')
|
47
|
+
File.open('config/abstractor/custom_nlp_providers.yml', 'w+'){ |f|
|
48
|
+
f << template
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
29
52
|
end
|
30
53
|
|
31
54
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Gurley, Yulia Bushmanova
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -119,25 +119,25 @@ dependencies:
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: 3.0.0
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
|
-
name: stanford-core-nlp
|
122
|
+
name: stanford-core-nlp-abstractor
|
123
123
|
requirement: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
125
|
- - "~>"
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version: 0.5.
|
127
|
+
version: 0.5.3
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0.5.
|
130
|
+
version: 0.5.3
|
131
131
|
type: :runtime
|
132
132
|
prerelease: false
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0.5.
|
137
|
+
version: 0.5.3
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: 0.5.
|
140
|
+
version: 0.5.3
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: rubyzip
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,26 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: 4.0.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rest-client
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '1.7'
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: 1.7.0
|
191
|
+
type: :runtime
|
192
|
+
prerelease: false
|
193
|
+
version_requirements: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - "~>"
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '1.7'
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: 1.7.0
|
181
201
|
- !ruby/object:Gem::Dependency
|
182
202
|
name: sqlite3
|
183
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -398,6 +418,26 @@ dependencies:
|
|
398
418
|
- - ">="
|
399
419
|
- !ruby/object:Gem::Version
|
400
420
|
version: 3.1.1
|
421
|
+
- !ruby/object:Gem::Dependency
|
422
|
+
name: webmock
|
423
|
+
requirement: !ruby/object:Gem::Requirement
|
424
|
+
requirements:
|
425
|
+
- - "~>"
|
426
|
+
- !ruby/object:Gem::Version
|
427
|
+
version: '1.2'
|
428
|
+
- - ">="
|
429
|
+
- !ruby/object:Gem::Version
|
430
|
+
version: 1.2.0
|
431
|
+
type: :development
|
432
|
+
prerelease: false
|
433
|
+
version_requirements: !ruby/object:Gem::Requirement
|
434
|
+
requirements:
|
435
|
+
- - "~>"
|
436
|
+
- !ruby/object:Gem::Version
|
437
|
+
version: '1.2'
|
438
|
+
- - ">="
|
439
|
+
- !ruby/object:Gem::Version
|
440
|
+
version: 1.2.0
|
401
441
|
description: A Rails engine gem for deriving discrete data points from narrative text
|
402
442
|
via natural language processing (NLP). The gem includes a user interface to present
|
403
443
|
the abstracted data points for confirmation/revision by curator.
|
@@ -513,10 +553,12 @@ files:
|
|
513
553
|
- db/migrate/20141107171413_add_sectioning.rb
|
514
554
|
- db/migrate/20141120044606_add_system_generated_to_abstractor_abstraction_groups.rb
|
515
555
|
- db/migrate/20150110002921_create_indexes_for_performance.rb
|
556
|
+
- db/migrate/20150223033848_add_custom_nlp_provider_to_abstractor_abstraction_sources.rb
|
516
557
|
- db/seeds.rb
|
517
558
|
- lib/abstractor.rb
|
518
559
|
- lib/abstractor/abstractable.rb
|
519
560
|
- lib/abstractor/core_ext/string.rb
|
561
|
+
- lib/abstractor/custom_nlp_provider.rb
|
520
562
|
- lib/abstractor/engine.rb
|
521
563
|
- lib/abstractor/enum.rb
|
522
564
|
- lib/abstractor/methods/controllers/abstractor_abstraction_groups_controller.rb
|