Class: Buhos::AnalysisIncExcCriteria
- Inherits:
-
Object
- Object
- Buhos::AnalysisIncExcCriteria
- Defined in:
- lib/buhos/analysis_inc_exc_criteria.rb
Instance Attribute Summary collapse
-
#cd_ids ⇒ Object
readonly
Returns the value of attribute cd_ids.
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
-
#sr ⇒ Object
readonly
Returns the value of attribute sr.
Instance Method Summary collapse
-
#initialize(sr) ⇒ AnalysisIncExcCriteria
constructor
A new instance of AnalysisIncExcCriteria.
- #proportion_by_cd ⇒ Object
Constructor Details
#initialize(sr) ⇒ AnalysisIncExcCriteria
Returns a new instance of AnalysisIncExcCriteria.
35 36 37 38 39 40 41 42 43 |
# File 'lib/buhos/analysis_inc_exc_criteria.rb', line 35 def initialize(sr) @sr=sr @criteria=SrCriterion.join(:criteria, id: :criterion_id).where(systematic_review_id:@sr.id).order(:criteria_type, :criterion_id) set_canonical_documents @users_id=@sr.group_users.map(&:id) @user_n=@users_id.length @criteria_id=@criteria.map {|crit| crit[:id]} @cd_criteria=CdCriterion.where(systematic_review_id:@sr.id, canonical_document_id:@cd_ids, criterion_id:@criteria_id ).order(:user_id, :canonical_document_id, :criterion_id) end |
Instance Attribute Details
#cd_ids ⇒ Object (readonly)
Returns the value of attribute cd_ids.
34 35 36 |
# File 'lib/buhos/analysis_inc_exc_criteria.rb', line 34 def cd_ids @cd_ids end |
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
33 34 35 |
# File 'lib/buhos/analysis_inc_exc_criteria.rb', line 33 def criteria @criteria end |
#sr ⇒ Object (readonly)
Returns the value of attribute sr.
32 33 34 |
# File 'lib/buhos/analysis_inc_exc_criteria.rb', line 32 def sr @sr end |
Instance Method Details
#proportion_by_cd ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/buhos/analysis_inc_exc_criteria.rb', line 51 def proportion_by_cd crit_perc=lambda {@criteria.inject({}) { |ac,criterion| ac[criterion[:id]]=CdCriterion::PRESENCE_VALID.inject({}) {|ac2,presence| ac2[presence]=0; ac2} ac }} percents=@cd_ids.inject({}) do |ac,cd_id| ac[cd_id]=crit_perc.call ac end #$log.info(percents) @cd_criteria.each do |row| next unless @cd_ids.include? row[:canonical_document_id] and @criteria_id.include? row[:criterion_id] percents[row[:canonical_document_id]][row[:criterion_id]][row[:presence]]+= 1.to_f/@user_n end percents end |