abstractor 2.1.2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +9 -6
  3. data/app/assets/javascripts/abstractor/abstractor.js.coffee +115 -0
  4. data/app/assets/javascripts/abstractor/application.js +0 -8
  5. data/app/assets/stylesheets/abstractor/abstractor_abstractions.css +21 -1
  6. data/app/views/abstractor/abstractor_abstraction_groups/_form.html.haml +3 -3
  7. data/app/views/abstractor/abstractor_abstractions/_fields.html.haml +15 -5
  8. data/app/views/abstractor/abstractor_abstractions/_list.html.haml +9 -13
  9. data/app/views/abstractor/abstractor_abstractions/edit.html.haml +3 -3
  10. data/db/migrate/20140816005228_add_namespace_to_abstractor_subjects.rb +6 -0
  11. data/lib/abstractor/abstractable.rb +228 -87
  12. data/lib/abstractor/enum.rb +4 -0
  13. data/lib/abstractor/methods/controllers/abstractor_abstractions_controller.rb +7 -1
  14. data/lib/abstractor/methods/controllers/abstractor_suggestions_controller.rb +6 -2
  15. data/lib/abstractor/methods/models/abstractor_abstraction.rb +1 -1
  16. data/lib/abstractor/methods/models/abstractor_abstraction_group.rb +1 -1
  17. data/lib/abstractor/methods/models/abstractor_abstraction_group_member.rb +1 -1
  18. data/lib/abstractor/methods/models/abstractor_abstraction_schema.rb +1 -1
  19. data/lib/abstractor/methods/models/abstractor_abstraction_schema_object_value.rb +1 -1
  20. data/lib/abstractor/methods/models/abstractor_abstraction_schema_predicate_variant.rb +1 -1
  21. data/lib/abstractor/methods/models/abstractor_abstraction_schema_relation.rb +1 -1
  22. data/lib/abstractor/methods/models/abstractor_abstraction_source.rb +1 -1
  23. data/lib/abstractor/methods/models/abstractor_abstraction_source_type.rb +1 -1
  24. data/lib/abstractor/methods/models/abstractor_indirect_source.rb +1 -1
  25. data/lib/abstractor/methods/models/abstractor_object_type.rb +1 -1
  26. data/lib/abstractor/methods/models/abstractor_object_value.rb +1 -2
  27. data/lib/abstractor/methods/models/abstractor_object_value_variant.rb +1 -1
  28. data/lib/abstractor/methods/models/abstractor_relation_type.rb +2 -1
  29. data/lib/abstractor/methods/models/abstractor_rule_type.rb +1 -1
  30. data/lib/abstractor/methods/models/abstractor_subject.rb +22 -18
  31. data/lib/abstractor/methods/models/abstractor_subject_group.rb +1 -1
  32. data/lib/abstractor/methods/models/abstractor_subject_group_member.rb +1 -1
  33. data/lib/abstractor/methods/models/abstractor_subject_relation.rb +1 -1
  34. data/lib/abstractor/methods/models/abstractor_suggestion.rb +1 -1
  35. data/lib/abstractor/methods/models/abstractor_suggestion_object_value.rb +1 -1
  36. data/lib/abstractor/methods/models/abstractor_suggestion_source.rb +1 -1
  37. data/lib/abstractor/methods/models/abstractor_suggestion_status.rb +1 -1
  38. data/lib/abstractor/negation_detection.rb +1 -1
  39. data/lib/abstractor/setup.rb +18 -18
  40. data/lib/abstractor/version.rb +1 -1
  41. data/lib/generators/abstractor/install/install_generator.rb +1 -1
  42. metadata +54 -34
  43. data/app/assets/javascripts/abstractor/abstractor.js +0 -108
  44. data/app/assets/javascripts/abstractor/nested_attributes.js +0 -69
@@ -3,5 +3,9 @@ module Abstractor
3
3
  ABSTRACTION_OTHER_VALUE_TYPE_UNKNOWN = 'unknown'
4
4
  ABSTRACTION_OTHER_VALUE_TYPE_NOT_APPLICABLE = 'not applicable'
5
5
  ABSTRACTION_OTHER_VALUE_TYPES = [ABSTRACTION_OTHER_VALUE_TYPE_UNKNOWN, ABSTRACTION_OTHER_VALUE_TYPE_NOT_APPLICABLE]
6
+
7
+ ABSTRACTION_STATUS_NEEDS_REVIEW = 'needs review'
8
+ ABSTRACTION_STATUS_REVIEWED = 'reviewed'
9
+ ABSTRACTION_STATUSES = [ABSTRACTION_STATUS_NEEDS_REVIEW, ABSTRACTION_STATUS_REVIEWED]
6
10
  end
7
11
  end
@@ -23,7 +23,7 @@ module Abstractor
23
23
 
24
24
  def update
25
25
  respond_to do |format|
26
- if @abstractor_abstraction.update_attributes(params[:abstractor_abstraction])
26
+ if @abstractor_abstraction.update_attributes(abstractor_abstraction_params)
27
27
  format.html { redirect_to(abstractor_abstraction_path(@abstractor_abstraction)) }
28
28
  else
29
29
  format.html { render :action => "edit" }
@@ -45,6 +45,12 @@ module Abstractor
45
45
  @abstractor_abstraction = Abstractor::AbstractorAbstraction.find(params[:id])
46
46
  @about = @abstractor_abstraction.about
47
47
  end
48
+
49
+ def abstractor_abstraction_params
50
+ params.require(:abstractor_abstraction).permit(:id, :abstractor_subject_id, :value, :about_type, :about_id, :unknown, :not_applicable, :deleted_at, :_destroy,
51
+ abstractor_indirect_sources_attributes: [:id, :abstractor_abstraction_id, :abstractor_abstraction_source_id, :source_type, :source_id, :source_method, :deleted_at, :_destroy]
52
+ )
53
+ end
48
54
  end
49
55
  end
50
56
  end
@@ -8,7 +8,7 @@ module Abstractor
8
8
 
9
9
  def update
10
10
  respond_to do |format|
11
- if @abstractor_suggestion.update_attributes(params[:abstractor_suggestion])
11
+ if @abstractor_suggestion.update_attributes(abstractor_suggestion_params)
12
12
  format.html { redirect_to(abstractor_abstraction_path(@abstractor_abstraction)) }
13
13
  else
14
14
  format.html { render "abstractor_abstractions/show" }
@@ -22,7 +22,11 @@ module Abstractor
22
22
  @abstractor_suggestion = Abstractor::AbstractorSuggestion.find(params[:id])
23
23
  @about = @abstractor_abstraction.about
24
24
  end
25
+
26
+ def abstractor_suggestion_params
27
+ params.require(:abstractor_suggestion).permit(:id, :abstractor_abstraction_id, :abstractor_suggestion_status_id, :suggested_value, :unknown, :not_applicable, :deleted_at, :_destroy)
28
+ end
25
29
  end
26
30
  end
27
31
  end
28
- end
32
+ end
@@ -22,7 +22,7 @@ module Abstractor
22
22
 
23
23
  base.send :belongs_to, :about, polymorphic: true
24
24
 
25
- base.send :attr_accessible, :about, :abstractor_subject, :abstractor_subject_id, :value, :about_type, :about_id, :unknown, :not_applicable, :deleted_at, :abstractor_indirect_sources_attributes
25
+ # base.send :attr_accessible, :about, :abstractor_subject, :abstractor_subject_id, :value, :about_type, :about_id, :unknown, :not_applicable, :deleted_at, :abstractor_indirect_sources_attributes
26
26
 
27
27
  # Hooks
28
28
  base.send :after_save, :review_matching_suggestions
@@ -12,7 +12,7 @@ module Abstractor
12
12
  base.send :has_many, :abstractor_abstraction_group_members
13
13
  base.send :has_many, :abstractor_abstractions, :through => :abstractor_abstraction_group_members
14
14
 
15
- base.send :attr_accessible, :abstractor_subject_group, :abstractor_subject_group_id, :deleted_at, :about, :about_type, :about_id
15
+ # base.send :attr_accessible, :abstractor_subject_group, :abstractor_subject_group_id, :deleted_at, :about, :about_type, :about_id
16
16
 
17
17
  # Hooks
18
18
  base.send :after_commit, :update_abstractor_abstraction_group_members, :on => :update, :if => Proc.new { |record| record.previous_changes.include?('deleted_at') }
@@ -9,7 +9,7 @@ module Abstractor
9
9
  base.send :belongs_to, :abstractor_abstraction_group
10
10
  base.send :belongs_to, :abstractor_abstraction
11
11
 
12
- base.send :attr_accessible, :abstractor_abstraction_group, :abstractor_abstraction_group_id, :abstractor_abstraction, :abstractor_abstraction_id, :deleted_at
12
+ # base.send :attr_accessible, :abstractor_abstraction_group, :abstractor_abstraction_group_id, :abstractor_abstraction, :abstractor_abstraction_id, :deleted_at
13
13
  end
14
14
  end
15
15
  end
@@ -14,7 +14,7 @@ module Abstractor
14
14
  base.send :has_many, :object_relations, :class_name => "Abstractor::AbstractorAbstractionSchemaRelation", :foreign_key => "object_id"
15
15
  base.send :has_many, :subject_relations, :class_name => "Abstractor::AbstractorAbstractionSchemaRelation", :foreign_key => "subject_id"
16
16
 
17
- base.send :attr_accessible, :abstractor_object_type, :abstractor_object_type_id, :display_name, :predicate, :preferred_name, :deleted_at
17
+ # base.send :attr_accessible, :abstractor_object_type, :abstractor_object_type_id, :display_name, :predicate, :preferred_name, :deleted_at
18
18
  end
19
19
 
20
20
  # Instance Methods
@@ -9,7 +9,7 @@ module Abstractor
9
9
  base.send :belongs_to, :abstractor_abstraction_schema
10
10
  base.send :belongs_to, :abstractor_object_value
11
11
 
12
- base.send :attr_accessible, :abstractor_abstraction_schema, :abstractor_abstraction_schema_id, :abstractor_object_value, :abstractor_object_value_id
12
+ # base.send :attr_accessible, :abstractor_abstraction_schema, :abstractor_abstraction_schema_id, :abstractor_object_value, :abstractor_object_value_id
13
13
  end
14
14
  end
15
15
  end
@@ -8,7 +8,7 @@ module Abstractor
8
8
  # Associations
9
9
  base.send :belongs_to, :abstractor_abstraction_schema
10
10
 
11
- base.send :attr_accessible, :abstractor_abstraction_schema, :abstractor_abstraction_schema_id, :deleted_at, :value
11
+ # base.send :attr_accessible, :abstractor_abstraction_schema, :abstractor_abstraction_schema_id, :deleted_at, :value
12
12
  end
13
13
  end
14
14
  end
@@ -10,7 +10,7 @@ module Abstractor
10
10
  base.send :belongs_to, :object, :class_name => "Abstractor::AbstractorAbstractionSchema", :foreign_key => "object_id"
11
11
  base.send :belongs_to, :subject, :class_name => "Abstractor::AbstractorAbstractionSchema", :foreign_key => "subject_id"
12
12
 
13
- base.send :attr_accessible, :abstractor_relation_type, :abstractor_relation_type_id, :object, :object_id, :subject, :subject_id, :deleted_at
13
+ # base.send :attr_accessible, :abstractor_relation_type, :abstractor_relation_type_id, :object, :object_id, :subject, :subject_id, :deleted_at
14
14
  end
15
15
  end
16
16
  end
@@ -13,7 +13,7 @@ module Abstractor
13
13
  base.send :has_many, :abstractor_abstractions, :through => :abstractor_suggestion_sources
14
14
  base.send :has_many, :abstractor_indirect_sources
15
15
 
16
- base.send :attr_accessible, :abstractor_subject, :abstractor_subject_id, :deleted_at, :from_method, :custom_method, :abstractor_rule_type, :abstractor_rule_type_id, :abstractor_abstraction_source_type, :abstractor_abstraction_source_type_id
16
+ # base.send :attr_accessible, :abstractor_subject, :abstractor_subject_id, :deleted_at, :from_method, :custom_method, :abstractor_rule_type, :abstractor_rule_type_id, :abstractor_abstraction_source_type, :abstractor_abstraction_source_type_id
17
17
  end
18
18
 
19
19
  def normalize_from_method_to_sources(about)
@@ -8,7 +8,7 @@ module Abstractor
8
8
  # Associations
9
9
  base.send :has_many, :abstractor_abstraction_sources
10
10
 
11
- base.send :attr_accessible, :deleted_at, :name
11
+ # base.send :attr_accessible, :deleted_at, :name
12
12
  end
13
13
  end
14
14
  end
@@ -9,7 +9,7 @@ module Abstractor
9
9
  base.send :belongs_to, :abstractor_abstraction_source
10
10
  base.send :belongs_to, :abstractor_abstraction
11
11
 
12
- base.send :attr_accessible, :abstractor_abstraction_id, :abstractor_abstraction, :abstractor_abstraction_source_id, :abstractor_abstraction_source, :source_type, :source_id, :source_method, :reviewed
12
+ # base.send :attr_accessible, :abstractor_abstraction_id, :abstractor_abstraction, :abstractor_abstraction_source_id, :abstractor_abstraction_source, :source_type, :source_id, :source_method, :reviewed
13
13
  end
14
14
  end
15
15
  end
@@ -8,7 +8,7 @@ module Abstractor
8
8
  # Associations
9
9
  base.send :has_many, :abstractor_abstraction_schemas
10
10
 
11
- base.send :attr_accessible, :deleted_at, :value
11
+ # base.send :attr_accessible, :deleted_at, :value
12
12
  end
13
13
  end
14
14
  end
@@ -10,8 +10,7 @@ module Abstractor
10
10
  base.send :has_many, :abstractor_abstraction_schema_object_values
11
11
  base.send :has_many, :abstractor_abstraction_schemas, :through => :abstractor_abstraction_schema_object_values
12
12
 
13
- #Validations
14
- base.send :attr_accessible, :value, :abstractor_object_value_variants, :abstractor_abstraction_schema_object_values, :abstractor_abstraction_schemas
13
+ # base.send :attr_accessible, :value, :abstractor_object_value_variants, :abstractor_abstraction_schema_object_values, :abstractor_abstraction_schemas
15
14
  end
16
15
 
17
16
  # Instance Methods
@@ -8,7 +8,7 @@ module Abstractor
8
8
  # Associations
9
9
  base.send :belongs_to, :abstractor_object_value
10
10
 
11
- base.send :attr_accessible, :abstractor_object_value, :abstractor_object_value_id, :deleted_at, :value
11
+ # base.send :attr_accessible, :abstractor_object_value, :abstractor_object_value_id, :deleted_at, :value
12
12
  end
13
13
  end
14
14
  end
@@ -8,7 +8,8 @@ module Abstractor
8
8
  # Associations
9
9
  base.send :has_many, :abstractor_abstraction_schema_relations
10
10
  base.send :has_many, :subject_relations
11
- base.send :attr_accessible, :deleted_at, :name
11
+
12
+ # base.send :attr_accessible, :deleted_at, :name
12
13
  end
13
14
  end
14
15
  end
@@ -8,7 +8,7 @@ module Abstractor
8
8
  # Associations
9
9
  base.send :has_many, :abstractor_abstraction_sources
10
10
 
11
- base.send :attr_accessible, :deleted_at, :description, :name, :abstractor_subjects
11
+ # base.send :attr_accessible, :deleted_at, :description, :name, :abstractor_subjects
12
12
  end
13
13
  end
14
14
  end
@@ -18,7 +18,7 @@ module Abstractor
18
18
  base.send :has_many, :subject_relations, :class_name => "Abstractor::AbstractorSubjectRelation", :foreign_key => "subject_id"
19
19
 
20
20
 
21
- base.send :attr_accessible, :abstractor_abstraction_schema, :abstractor_abstraction_schema_id, :subject_type, :dynamic_list_method
21
+ # base.send :attr_accessible, :abstractor_abstraction_schema, :abstractor_abstraction_schema_id, :subject_type, :dynamic_list_method
22
22
  base.send(:include, InstanceMethods)
23
23
  end
24
24
 
@@ -148,26 +148,30 @@ module Abstractor
148
148
  abstractor_text = source[:source_type].find(source[:source_id]).send(source[:source_method])
149
149
  abstractor_object_value_ids = abstractor_abstraction_schema.abstractor_object_values.map(&:id)
150
150
 
151
- adapter = ActiveRecord::Base.connection.instance_values["config"][:adapter]
152
- case adapter
153
- when 'sqlserver'
154
- abstractor_object_value_variants = Abstractor::AbstractorObjectValueVariant.where("abstractor_object_value_id in (?) AND EXISTS (SELECT 1 FROM #{source[:source_type].table_name} WHERE #{source[:source_type].table_name}.id = ? AND #{source[:source_type].table_name}.#{source[:source_method]} LIKE ('%' + abstractor_object_value_variants.value + '%'))", abstractor_object_value_ids, source[:source_id]).all
155
- when 'sqlite3'
156
- abstractor_object_value_variants = Abstractor::AbstractorObjectValueVariant.where("abstractor_object_value_id in (?) AND EXISTS (SELECT 1 FROM #{source[:source_type].table_name} WHERE #{source[:source_type].table_name}.id = ? AND #{source[:source_type].table_name}.#{source[:source_method]} LIKE ('%' || abstractor_object_value_variants.value || '%'))", abstractor_object_value_ids, source[:source_id]).all
157
- when 'postgresql'
158
- abstractor_object_value_variants = Abstractor::AbstractorObjectValueVariant.where("abstractor_object_value_id in (?) AND EXISTS (SELECT 1 FROM #{source[:source_type].table_name} WHERE #{source[:source_type].table_name}.id = ? AND #{source[:source_type].table_name}.#{source[:source_method]} ILIKE ('%' || abstractor_object_value_variants.value || '%'))", abstractor_object_value_ids, source[:source_id]).all
151
+ abstractor_object_values = []
152
+ abstractor_object_value_variants = []
153
+ target_abstractor_object_values =[]
154
+ target_abstractor_object_value_variants = Abstractor::AbstractorObjectValueVariant.where("abstractor_object_value_id in (?)", abstractor_object_value_ids).to_a
155
+
156
+ at = nil
157
+ at = abstractor_text.downcase unless abstractor_text.blank?
158
+ target_abstractor_object_value_variants.each do |abstractor_object_value_variant|
159
+ re = Regexp.new(Regexp.escape(abstractor_object_value_variant.value.downcase))
160
+ if re =~ at
161
+ abstractor_object_value_variants << abstractor_object_value_variant
162
+ abstractor_object_values << abstractor_object_value_variant.abstractor_object_value
163
+ target_abstractor_object_value_variants.delete_if { |aovv| aovv.abstractor_object_value.id == abstractor_object_value_variant.abstractor_object_value.id }
164
+ end
159
165
  end
160
166
 
161
- abstractor_object_values = abstractor_object_value_variants.map(&:abstractor_object_value).uniq
167
+ target_abstractor_object_values = abstractor_abstraction_schema.abstractor_object_values
168
+ target_abstractor_object_values = target_abstractor_object_values - abstractor_object_values
162
169
 
163
- adapter = ActiveRecord::Base.connection.instance_values["config"][:adapter]
164
- case adapter
165
- when 'sqlserver'
166
- abstractor_object_values.concat(Abstractor::AbstractorObjectValue.where("abstractor_object_values.id in (?) AND EXISTS (SELECT 1 FROM #{source[:source_type].table_name} WHERE #{source[:source_type].table_name}.id = ? AND #{source[:source_type].table_name}.#{source[:source_method]} LIKE ('%' + abstractor_object_values.value + '%'))", abstractor_object_value_ids, source[:source_id]).all).uniq
167
- when 'sqlite3'
168
- abstractor_object_values.concat(Abstractor::AbstractorObjectValue.where("abstractor_object_values.id in (?) AND EXISTS (SELECT 1 FROM #{source[:source_type].table_name} WHERE #{source[:source_type].table_name}.id = ? AND #{source[:source_type].table_name}.#{source[:source_method]} LIKE ('%' || abstractor_object_values.value || '%'))", abstractor_object_value_ids, source[:source_id]).all).uniq
169
- when 'postgresql'
170
- abstractor_object_values.concat(Abstractor::AbstractorObjectValue.where("abstractor_object_values.id in (?) AND EXISTS (SELECT 1 FROM #{source[:source_type].table_name} WHERE #{source[:source_type].table_name}.id = ? AND #{source[:source_type].table_name}.#{source[:source_method]} ILIKE ('%' || abstractor_object_values.value || '%'))", abstractor_object_value_ids, source[:source_id]).all).uniq
170
+ target_abstractor_object_values.each do |abstractor_object_value|
171
+ re = Regexp.new(Regexp.escape(abstractor_object_value.value.downcase))
172
+ if re =~ at
173
+ abstractor_object_values << abstractor_object_value
174
+ end
171
175
  end
172
176
 
173
177
  parser = Abstractor::Parser.new(abstractor_text)
@@ -11,7 +11,7 @@ module Abstractor
11
11
  base.send :has_many, :abstractor_abstraction_groups
12
12
  base.send :has_many, :abstractor_abstractions, :through => :abstractor_abstraction_groups
13
13
 
14
- base.send :attr_accessible, :deleted_at, :name
14
+ # base.send :attr_accessible, :deleted_at, :name
15
15
  end
16
16
  end
17
17
  end
@@ -9,7 +9,7 @@ module Abstractor
9
9
  base.send :belongs_to, :abstractor_subject_group
10
10
  base.send :belongs_to, :abstractor_subject
11
11
 
12
- base.send :attr_accessible, :abstractor_subject_group, :abstractor_subject_group_id, :abstractor_subject_id, :display_order, :deleted_at, :abstractor_subject
12
+ # base.send :attr_accessible, :abstractor_subject_group, :abstractor_subject_group_id, :abstractor_subject_id, :display_order, :deleted_at, :abstractor_subject
13
13
  end
14
14
  end
15
15
  end
@@ -10,7 +10,7 @@ module Abstractor
10
10
  base.send :belongs_to, :object, :class_name => "Abstractor::AbstractorSubject", :foreign_key => "object_id"
11
11
  base.send :belongs_to, :subject, :class_name => "Abstractor::AbstractorSubject", :foreign_key => "subject_id"
12
12
 
13
- base.send :attr_accessible, :abstractor_relation_type, :abstractor_relation_type_id, :object, :object_id, :subject, :subject_id, :deleted_at
13
+ # base.send :attr_accessible, :abstractor_relation_type, :abstractor_relation_type_id, :object, :object_id, :subject, :subject_id, :deleted_at
14
14
  end
15
15
  end
16
16
  end
@@ -14,7 +14,7 @@ module Abstractor
14
14
 
15
15
  base.send :has_many, :abstractor_suggestion_sources
16
16
 
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
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
 
19
19
  # Hooks
20
20
  base.send :after_save, :update_abstraction_value, :if => lambda {|abstractor_suggestion| abstractor_suggestion.abstractor_suggestion_status_id_changed?}
@@ -9,7 +9,7 @@ module Abstractor
9
9
  base.send :belongs_to, :abstractor_suggestion
10
10
  base.send :belongs_to, :abstractor_object_value
11
11
 
12
- base.send :attr_accessible, :abstractor_suggestion, :abstractor_suggestion_id, :abstractor_object_value, :abstractor_object_value_id, :deleted_at
12
+ # base.send :attr_accessible, :abstractor_suggestion, :abstractor_suggestion_id, :abstractor_object_value, :abstractor_object_value_id, :deleted_at
13
13
  end
14
14
  end
15
15
  end
@@ -9,7 +9,7 @@ module Abstractor
9
9
  base.send :belongs_to, :abstractor_abstraction_source
10
10
  base.send :belongs_to, :abstractor_suggestion
11
11
 
12
- base.send :attr_accessible, :abstractor_abstraction_source, :abstractor_abstraction_source_id, :abstractor_suggestion, :abstractor_suggestion_id, :source_id, :source_type, :source_method, :match_value, :deleted_at, :sentence_match_value, :custom_method, :custom_explanation
12
+ # base.send :attr_accessible, :abstractor_abstraction_source, :abstractor_abstraction_source_id, :abstractor_suggestion, :abstractor_suggestion_id, :source_id, :source_type, :source_method, :match_value, :deleted_at, :sentence_match_value, :custom_method, :custom_explanation
13
13
  end
14
14
  end
15
15
  end
@@ -8,7 +8,7 @@ module Abstractor
8
8
  # Associations
9
9
  base.send :has_many, :abstractor_suggestions
10
10
 
11
- base.send :attr_accessible, :deleted_at, :name
11
+ # base.send :attr_accessible, :deleted_at, :name
12
12
  end
13
13
 
14
14
  # Instance Methods
@@ -21,7 +21,7 @@ module Abstractor
21
21
 
22
22
  def self.manual_negated_match_value?(sentence, match_value)
23
23
  negated = false
24
- ['non-','\bthere is no evidence of a ', '\bthere is no evidence of a metastatic ', '\binsufficient to make the diagnosis of ', '\binsufficient to make the diagnosis of metastatic ', '\binsufficient for the diagnosis of ', '\binsufficient for the diagnosis of metastatic ', '\brule out ', '\brule out metastatic ', '\bnegative for ', '\bnegative for metastatic ', '\bno ', '\bno metastatic ', '\bnot ', '\bnot metastatic ', '\bno evidence of ', '\bno evidence of metastatic ', '\bno evidence of a ', '\bno evidence of a metastatic ', '\brules out the possibility of a ', '\brules out the possibility of a metastatic ', '\bto exclude the possibility of ', '\bto exclude the possibility of metastic '].each do |negation_cue|
24
+ ['no\b', 'non-','\bthere is no evidence of a ', '\bthere is no evidence of a metastatic ', '\binsufficient to make the diagnosis of ', '\binsufficient to make the diagnosis of metastatic ', '\binsufficient for the diagnosis of ', '\binsufficient for the diagnosis of metastatic ', '\brule out ', '\brule out metastatic ', '\bnegative for ', '\bnegative for metastatic ', '\bno ', '\bno metastatic ', '\bnot ', '\bnot metastatic ', '\bno evidence of ', '\bno evidence of metastatic ', '\bno evidence of a ', '\bno evidence of a metastatic ', '\brules out the possibility of a ', '\brules out the possibility of a metastatic ', '\bto exclude the possibility of ', '\bto exclude the possibility of metastic '].each do |negation_cue|
25
25
  if !(sentence.downcase.scan(Regexp.new(negation_cue + match_value.downcase)).empty?)
26
26
  negated = true
27
27
  end
@@ -2,32 +2,32 @@ module Abstractor
2
2
  module Setup
3
3
  def self.system
4
4
  puts 'Setting up Abstractor::AbstractorObjectType'
5
- Abstractor::AbstractorObjectType.find_or_create_by_value('list')
6
- Abstractor::AbstractorObjectType.find_or_create_by_value('number')
7
- Abstractor::AbstractorObjectType.find_or_create_by_value('boolean')
8
- Abstractor::AbstractorObjectType.find_or_create_by_value('string')
9
- Abstractor::AbstractorObjectType.find_or_create_by_value('radio button list')
10
- Abstractor::AbstractorObjectType.find_or_create_by_value('date')
11
- Abstractor::AbstractorObjectType.find_or_create_by_value('dynamic list')
5
+ Abstractor::AbstractorObjectType.where(value: 'list').first_or_create
6
+ Abstractor::AbstractorObjectType.where(value: 'number').first_or_create
7
+ Abstractor::AbstractorObjectType.where(value: 'boolean').first_or_create
8
+ Abstractor::AbstractorObjectType.where(value: 'string').first_or_create
9
+ Abstractor::AbstractorObjectType.where(value: 'radio button list').first_or_create
10
+ Abstractor::AbstractorObjectType.where(value: 'date').first_or_create
11
+ Abstractor::AbstractorObjectType.where(value: 'dynamic list').first_or_create
12
12
 
13
13
  puts 'Setting up Abstractor::AbstractorRuleType'
14
- Abstractor::AbstractorRuleType.find_or_create_by_name_and_description(name: 'name/value', description:'search for value associated with name')
15
- Abstractor::AbstractorRuleType.find_or_create_by_name_and_description(name:'value', description: 'search for value match')
16
- Abstractor::AbstractorRuleType.find_or_create_by_name_and_description(name: 'unknown', description: 'do not try to abstract, always assign "unknown"')
14
+ Abstractor::AbstractorRuleType.where(name: 'name/value', description:'search for value associated with name').first_or_create
15
+ Abstractor::AbstractorRuleType.where(name:'value', description: 'search for value match').first_or_create
16
+ Abstractor::AbstractorRuleType.where(name: 'unknown', description: 'do not try to abstract, always assign "unknown"').first_or_create
17
17
 
18
18
  puts 'Setting up Abstractor::AbstractorSuggestionStatus'
19
- Abstractor::AbstractorSuggestionStatus.find_or_create_by_name('Needs review')
20
- Abstractor::AbstractorSuggestionStatus.find_or_create_by_name('Accepted')
21
- Abstractor::AbstractorSuggestionStatus.find_or_create_by_name('Rejected')
19
+ Abstractor::AbstractorSuggestionStatus.where(name: 'Needs review').first_or_create
20
+ Abstractor::AbstractorSuggestionStatus.where(name: 'Accepted').first_or_create
21
+ Abstractor::AbstractorSuggestionStatus.where(name: 'Rejected').first_or_create
22
22
 
23
23
  puts 'Setting up Abstractor::AbstractorRelationType'
24
- Abstractor::AbstractorRelationType.find_or_create_by_name('member_of')
25
- Abstractor::AbstractorRelationType.find_or_create_by_name('preceded_by')
24
+ Abstractor::AbstractorRelationType.where(name: 'member_of').first_or_create
25
+ Abstractor::AbstractorRelationType.where(name: 'preceded_by').first_or_create
26
26
 
27
27
  puts 'Setting up Abstractor::AbstractorAbstractionSourceType'
28
- Abstractor::AbstractorAbstractionSourceType.find_or_create_by_name('nlp suggestion')
29
- Abstractor::AbstractorAbstractionSourceType.find_or_create_by_name('custom suggestion')
30
- Abstractor::AbstractorAbstractionSourceType.find_or_create_by_name('indirect')
28
+ Abstractor::AbstractorAbstractionSourceType.where(name: 'nlp suggestion').first_or_create
29
+ Abstractor::AbstractorAbstractionSourceType.where(name: 'custom suggestion').first_or_create
30
+ Abstractor::AbstractorAbstractionSourceType.where(name: 'indirect').first_or_create
31
31
  end
32
32
  end
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module Abstractor
2
- VERSION = '2.1.2'
2
+ VERSION = '4.0.0'
3
3
  end
@@ -60,7 +60,7 @@ module Abstractor
60
60
  puts 'Please be patient...this could take a while.'
61
61
  `rake abstractor:setup:stanford_core_nlp`
62
62
 
63
- insert_into_file("#{Rails.root}/config/environments/development.rb", :after => /::Application.configure do\n/) do
63
+ insert_into_file("#{Rails.root}/config/environments/development.rb", :after => /(::Application.configure do\n|application.configure do\n)/) do
64
64
  ' StanfordCoreNLP.use :english
65
65
  StanfordCoreNLP.model_files = {}
66
66
  StanfordCoreNLP.jar_path = "#{Rails.root}/lib/stanford-corenlp-full-2014-06-16/"
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: 2.1.2
4
+ version: 4.0.0
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: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2014-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '4.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '4.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jquery-rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,20 +90,20 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 3.2.6
93
+ version: 4.0.0
94
94
  - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
- version: 3.2.6
96
+ version: 4.0.0
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: 3.2.6
103
+ version: 4.0.0
104
104
  - - ! '>='
105
105
  - !ruby/object:Gem::Version
106
- version: 3.2.6
106
+ version: 4.0.0
107
107
  - !ruby/object:Gem::Dependency
108
108
  name: paper_trail
109
109
  requirement: !ruby/object:Gem::Requirement
@@ -164,46 +164,66 @@ dependencies:
164
164
  - - ! '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: 1.1.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: coffee-rails
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 4.0.1
174
+ - - ! '>='
175
+ - !ruby/object:Gem::Version
176
+ version: 4.0.1
177
+ type: :runtime
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ~>
182
+ - !ruby/object:Gem::Version
183
+ version: 4.0.1
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: 4.0.1
167
187
  - !ruby/object:Gem::Dependency
168
188
  name: sqlite3
169
189
  requirement: !ruby/object:Gem::Requirement
170
190
  requirements:
171
191
  - - ~>
172
192
  - !ruby/object:Gem::Version
173
- version: 1.3.8
193
+ version: 1.3.9
174
194
  - - ! '>='
175
195
  - !ruby/object:Gem::Version
176
- version: 1.3.8
196
+ version: 1.3.9
177
197
  type: :development
178
198
  prerelease: false
179
199
  version_requirements: !ruby/object:Gem::Requirement
180
200
  requirements:
181
201
  - - ~>
182
202
  - !ruby/object:Gem::Version
183
- version: 1.3.8
203
+ version: 1.3.9
184
204
  - - ! '>='
185
205
  - !ruby/object:Gem::Version
186
- version: 1.3.8
206
+ version: 1.3.9
187
207
  - !ruby/object:Gem::Dependency
188
208
  name: rspec-rails
189
209
  requirement: !ruby/object:Gem::Requirement
190
210
  requirements:
191
211
  - - ~>
192
212
  - !ruby/object:Gem::Version
193
- version: 2.14.1
213
+ version: 3.0.0
194
214
  - - ! '>='
195
215
  - !ruby/object:Gem::Version
196
- version: 2.14.1
216
+ version: 3.0.0
197
217
  type: :development
198
218
  prerelease: false
199
219
  version_requirements: !ruby/object:Gem::Requirement
200
220
  requirements:
201
221
  - - ~>
202
222
  - !ruby/object:Gem::Version
203
- version: 2.14.1
223
+ version: 3.0.0
204
224
  - - ! '>='
205
225
  - !ruby/object:Gem::Version
206
- version: 2.14.1
226
+ version: 3.0.0
207
227
  - !ruby/object:Gem::Dependency
208
228
  name: factory_girl_rails
209
229
  requirement: !ruby/object:Gem::Requirement
@@ -250,60 +270,60 @@ dependencies:
250
270
  requirements:
251
271
  - - ~>
252
272
  - !ruby/object:Gem::Version
253
- version: 2.2.1
273
+ version: 2.4.0
254
274
  - - ! '>='
255
275
  - !ruby/object:Gem::Version
256
- version: 2.2.1
276
+ version: 2.4.0
257
277
  type: :development
258
278
  prerelease: false
259
279
  version_requirements: !ruby/object:Gem::Requirement
260
280
  requirements:
261
281
  - - ~>
262
282
  - !ruby/object:Gem::Version
263
- version: 2.2.1
283
+ version: 2.4.0
264
284
  - - ! '>='
265
285
  - !ruby/object:Gem::Version
266
- version: 2.2.1
286
+ version: 2.4.0
267
287
  - !ruby/object:Gem::Dependency
268
288
  name: selenium-webdriver
269
289
  requirement: !ruby/object:Gem::Requirement
270
290
  requirements:
271
291
  - - ~>
272
292
  - !ruby/object:Gem::Version
273
- version: 2.40.0
293
+ version: 2.42.0
274
294
  - - ! '>='
275
295
  - !ruby/object:Gem::Version
276
- version: 2.40.0
296
+ version: 2.42.0
277
297
  type: :development
278
298
  prerelease: false
279
299
  version_requirements: !ruby/object:Gem::Requirement
280
300
  requirements:
281
301
  - - ~>
282
302
  - !ruby/object:Gem::Version
283
- version: 2.40.0
303
+ version: 2.42.0
284
304
  - - ! '>='
285
305
  - !ruby/object:Gem::Version
286
- version: 2.40.0
306
+ version: 2.42.0
287
307
  - !ruby/object:Gem::Dependency
288
308
  name: database_cleaner
289
309
  requirement: !ruby/object:Gem::Requirement
290
310
  requirements:
291
311
  - - ~>
292
312
  - !ruby/object:Gem::Version
293
- version: 1.2.0
313
+ version: 1.3.0
294
314
  - - ! '>='
295
315
  - !ruby/object:Gem::Version
296
- version: 1.2.0
316
+ version: 1.3.0
297
317
  type: :development
298
318
  prerelease: false
299
319
  version_requirements: !ruby/object:Gem::Requirement
300
320
  requirements:
301
321
  - - ~>
302
322
  - !ruby/object:Gem::Version
303
- version: 1.2.0
323
+ version: 1.3.0
304
324
  - - ! '>='
305
325
  - !ruby/object:Gem::Version
306
- version: 1.2.0
326
+ version: 1.3.0
307
327
  - !ruby/object:Gem::Dependency
308
328
  name: ansi
309
329
  requirement: !ruby/object:Gem::Requirement
@@ -330,20 +350,20 @@ dependencies:
330
350
  requirements:
331
351
  - - ~>
332
352
  - !ruby/object:Gem::Version
333
- version: 2.2.1
353
+ version: 2.12.1
334
354
  - - ! '>='
335
355
  - !ruby/object:Gem::Version
336
- version: 2.2.1
356
+ version: 2.12.1
337
357
  type: :development
338
358
  prerelease: false
339
359
  version_requirements: !ruby/object:Gem::Requirement
340
360
  requirements:
341
361
  - - ~>
342
362
  - !ruby/object:Gem::Version
343
- version: 2.2.1
363
+ version: 2.12.1
344
364
  - - ! '>='
345
365
  - !ruby/object:Gem::Version
346
- version: 2.2.1
366
+ version: 2.12.1
347
367
  - !ruby/object:Gem::Dependency
348
368
  name: yard
349
369
  requirement: !ruby/object:Gem::Requirement
@@ -417,11 +437,10 @@ files:
417
437
  - app/assets/images/abstractor/show.png
418
438
  - app/assets/images/abstractor/switch_minus.gif
419
439
  - app/assets/images/abstractor/switch_plus.gif
420
- - app/assets/javascripts/abstractor/abstractor.js
440
+ - app/assets/javascripts/abstractor/abstractor.js.coffee
421
441
  - app/assets/javascripts/abstractor/application.js
422
442
  - app/assets/javascripts/abstractor/combobox.js
423
443
  - app/assets/javascripts/abstractor/jquery/jquery.form.js
424
- - app/assets/javascripts/abstractor/nested_attributes.js
425
444
  - app/assets/stylesheets/abstractor/abstractor_abstractions.css
426
445
  - app/assets/stylesheets/abstractor/application.css
427
446
  - app/assets/stylesheets/abstractor/jquery.ui.override.css.scss
@@ -488,6 +507,7 @@ files:
488
507
  - db/migrate/20140716184049_add_dynamic_list_method_to_abstractor_subjects.rb
489
508
  - db/migrate/20140718014952_refactor_abstractor_rule_types.rb
490
509
  - db/migrate/20140803205149_add_custom_explanation_to_abstractor_suggestion_sources.rb
510
+ - db/migrate/20140816005228_add_namespace_to_abstractor_subjects.rb
491
511
  - db/seeds.rb
492
512
  - lib/abstractor.rb
493
513
  - lib/abstractor/abstractable.rb