aac-metrics 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62c96e82e12b2a0c9eb03ad38b65af63c348731faf58ac3920de4d87c77e2d1c
4
- data.tar.gz: 16c049e5e33c1b18cdb374afbf9117299fd47bddc91c15042284f2f41f96dc6b
3
+ metadata.gz: bddb8e430a21868a5b26312fb5924f36b914446dc212d849330462768fd9b233
4
+ data.tar.gz: c5ddd0e2b835678f0dabf8743099b29d462612d94a4aa4dd261e1cb7337eaa02
5
5
  SHA512:
6
- metadata.gz: c37bef0e90cbea57f8e0d860e2751c1508028b97b9c76e669c6a9f33d5921dc7cf34ea819249c744c7e30a0e08aa9ebb9e9c4bc19fbacc85e56f1ebd7121a9df
7
- data.tar.gz: bf47f7d0bbe809195ad6576269532e0ed4b26cae918ae605b671e6c562fcfdf1e5fba892bd7e0c936a18082b8a9c291c0bfec75a44eb9b9ec3f320e1bec1e52f
6
+ metadata.gz: 876e09d6be2b2e2b7579c11bb06367296ee7fbba627db0f8d421b4e60d2b7042d9a41433f9b1af10c78a6fc8ac84077170224e059a5a5ba30db6b217cab56936
7
+ data.tar.gz: 5072598db0226690da77985e4e1ed760b24f0d0edc2bc99a5961e59d7f8e8bfa549073f4d0b223559ba48d7d2348556041d8b513944e5427c9c158db3b467f6c
@@ -20,6 +20,7 @@ module AACMetrics::Loader
20
20
  }
21
21
  if button['load_board'] && button['load_board']['id']
22
22
  new_button['load_board'] = {'id' => button['load_board']['id']}
23
+ new_button['load_board']['add_to_sentence'] = true if button['load_board']['add_to_sentence']
23
24
  end
24
25
  new_board['buttons'].push(new_button)
25
26
  end
@@ -177,6 +178,7 @@ module AACMetrics::Loader
177
178
  else
178
179
  puts "Link found with no access #{btn['load_board'].to_json}"
179
180
  end
181
+ new_btn['load_board']['add_to_sentence'] = true if new_btn['load_board'] && btn['load_board']['add_to_sentence']
180
182
  elsif btn['action']
181
183
  # TODO: track keyboard actions and don't
182
184
  # treat action buttons for metrics
@@ -124,9 +124,9 @@ module AACMetrics::Metrics
124
124
  button_id = (board[:board]['grid']['order'][row_idx] || [])[col_idx]
125
125
  button = board[:board]['buttons'].detect{|b| b['id'] == button_id }
126
126
  if button && button['clone_id'] && set_pcts[button['clone_id']]
127
- reuse_discount += REUSED_CLONE_FROM_OTHER_DISCOUNT * set_pcts[button['clone_id']]
127
+ reuse_discount += REUSED_CLONE_FROM_OTHER_BONUS * set_pcts[button['clone_id']]
128
128
  elsif button && button['semantic_id'] && set_pcts[button['semantic_id']]
129
- reuse_discount += REUSED_SEMANTIC_FROM_OTHER_DISCOUNT * set_pcts[button['semantic_id']]
129
+ reuse_discount += REUSED_SEMANTIC_FROM_OTHER_BONUS * set_pcts[button['semantic_id']]
130
130
  end
131
131
  end
132
132
  end
@@ -195,9 +195,13 @@ module AACMetrics::Metrics
195
195
  button_effort = board_effort
196
196
  if board_pcts[button['semantic_id']]
197
197
  # TODO: Pull out these magic numbers
198
+ prior = button_effort
198
199
  button_effort = [button_effort, button_effort * SAME_LOCATION_AS_PRIOR_DISCOUNT / board_pcts[button['semantic_id']]].min
200
+ # puts " #{button['label']} #{prior.round(1)} - #{prior - button_effort}"
199
201
  elsif board_pcts["upstream-#{button['semantic_id']}"]
202
+ prior = button_effort
200
203
  button_effort = [button_effort, button_effort * RECOGNIZABLE_SEMANTIC_FROM_PRIOR_DISCOUNT / board_pcts["upstream-#{button['semantic_id']}"]].min
204
+ # puts " #{button['label']} #{prior.round(1)} - #{prior - button_effort}"
201
205
  end
202
206
  if board_pcts[button['clone_id']]
203
207
  button_effort = [button_effort, button_effort * SAME_LOCATION_AS_PRIOR_DISCOUNT / board_pcts[button['clone_id']]].min
@@ -246,6 +250,10 @@ module AACMetrics::Metrics
246
250
  effort += board[:prior_effort] || 0
247
251
  prior_buttons += 1
248
252
 
253
+ # TODO: If any board links are sticky, or if
254
+ # the board set isn't auto-home, or any board links
255
+ # are add_to_sentence, then the logic will be different
256
+ # for calculating effort scores, since the route matters
249
257
  if button['load_board']
250
258
  try_visit = false
251
259
  # For linked buttons, only traverse if
@@ -274,7 +282,8 @@ module AACMetrics::Metrics
274
282
  })
275
283
  end
276
284
  end
277
- else
285
+ end
286
+ if !button['load_board'] || button['load_board']['add_to_sentence']
278
287
  word = button['label']
279
288
  existing = known_buttons[word]
280
289
  if !existing || effort < existing[:effort] #board[:level] < existing[:level]
@@ -335,11 +344,11 @@ module AACMetrics::Metrics
335
344
  SKIPPED_VISUAL_SCAN_DISTANCE_MULTIPLIER = 0.5
336
345
  SAME_LOCATION_AS_PRIOR_DISCOUNT = 0.1
337
346
  RECOGNIZABLE_SEMANTIC_FROM_PRIOR_DISCOUNT = 0.5
338
- RECOGNIZABLE_SEMANTIC_FROM_OTHER_DISCOUNT = 0.6
347
+ RECOGNIZABLE_SEMANTIC_FROM_OTHER_DISCOUNT = 0.5
348
+ REUSED_SEMANTIC_FROM_OTHER_BONUS = 0.0025
339
349
  RECOGNIZABLE_CLONE_FROM_PRIOR_DISCOUNT = 0.33
340
- RECOGNIZABLE_CLONE_FROM_OTHER_DISCOUNT = 0.4
341
- REUSED_SEMANTIC_FROM_OTHER_DISCOUNT = 0.0025
342
- REUSED_CLONE_FROM_OTHER_DISCOUNT = 0.005
350
+ RECOGNIZABLE_CLONE_FROM_OTHER_DISCOUNT = 0.33
351
+ REUSED_CLONE_FROM_OTHER_BONUS = 0.005
343
352
 
344
353
  def self.button_size_effort(rows, cols)
345
354
  BUTTON_SIZE_MULTIPLIER * (rows + cols) / 2
@@ -486,6 +495,7 @@ module AACMetrics::Metrics
486
495
  res[:cores] = {
487
496
  :common => {name: "Common Word List", list: common_words, average_effort: common_effort, comp_effort: comp_effort}
488
497
  }
498
+ res[:care_components] = {}
489
499
  target_effort_tally = 0.0
490
500
  comp_effort_tally = 0.0
491
501
  # For each core list, find any missing words, and compute
@@ -515,6 +525,7 @@ module AACMetrics::Metrics
515
525
  end
516
526
  # Fallback penalty for missing word
517
527
  effort ||= spelling_effort(word)
528
+ reffort = effort
518
529
  list_effort += effort
519
530
 
520
531
  effort = comp_efforts[word]
@@ -523,6 +534,7 @@ module AACMetrics::Metrics
523
534
  end
524
535
  effort ||= spelling_effort(word)
525
536
  comp_effort += effort
537
+ # puts "#{word} - #{reffort.round(1)} - #{effort.round(1)}"
526
538
  end
527
539
  if missing.length > 0
528
540
  # puts "MISSING FROM #{list['id']} (#{missing.length}):"
@@ -535,8 +547,10 @@ module AACMetrics::Metrics
535
547
  comp_effort_tally += comp_effort
536
548
  res[:cores][list['id']] = {name: list['name'], list: list['words'], average_effort: list_effort, comp_effort: comp_effort}
537
549
  end
538
- target_effort_tally = (target_effort_tally / core_lists.to_a.length) * 5.0
539
- comp_effort_tally = (comp_effort_tally / core_lists.to_a.length) * 5.0
550
+ res[:care_components][:core] = (target_effort_tally / core_lists.to_a.length) * 5.0
551
+ target_effort_tally = res[:care_components][:core]
552
+ res[:care_components][:comp_core] = (comp_effort_tally / core_lists.to_a.length) * 5.0
553
+ comp_effort_tally = res[:care_components][:comp_core]
540
554
 
541
555
  # TODO: Assemble or allow a battery of word combinations,
542
556
  # and calculate the level of effort for each sequence,
@@ -584,8 +598,10 @@ module AACMetrics::Metrics
584
598
  comp_effort_score = comp_effort_score / words.length
585
599
  res[:sentences] << {sentence: words.join(' '), words: words, effort: target_effort_score, comp_effort: comp_effort_score}
586
600
  end
587
- target_effort_tally += res[:sentences].map{|s| s[:effort] }.sum.to_f / res[:sentences].length.to_f * 3.0
588
- comp_effort_tally += res[:sentences].map{|s| s[:comp_effort] }.sum.to_f / res[:sentences].length.to_f * 3.0
601
+ res[:care_components][:sentences] = res[:sentences].map{|s| s[:effort] }.sum.to_f / res[:sentences].length.to_f * 3.0
602
+ target_effort_tally += res[:care_components][:sentences]
603
+ res[:care_components][:comp_sentences] = res[:sentences].map{|s| s[:comp_effort] }.sum.to_f / res[:sentences].length.to_f * 3.0
604
+ comp_effort_tally += res[:care_components][:comp_sentences]
589
605
 
590
606
  res[:fringe_words] = []
591
607
  fringe.each do |word|
@@ -596,6 +612,7 @@ module AACMetrics::Metrics
596
612
  if !effort
597
613
  synonym_words.each{|w| effort ||= target_efforts[w] }
598
614
  end
615
+ # puts "!#{word}" unless effort
599
616
  effort ||= spelling_effort(word)
600
617
  target_effort_score += effort
601
618
 
@@ -607,8 +624,10 @@ module AACMetrics::Metrics
607
624
  comp_effort_score += effort
608
625
  res[:fringe_words] << {word: word, effort: target_effort_score, comp_effort: comp_effort_score}
609
626
  end
610
- target_effort_tally += res[:fringe_words].map{|s| s[:effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0
611
- comp_effort_tally += res[:fringe_words].map{|s| s[:comp_effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0
627
+ res[:care_components][:fringe] = res[:fringe_words].map{|s| s[:effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0
628
+ target_effort_tally += res[:care_components][:fringe]
629
+ res[:care_components][:comp_fringe] = res[:fringe_words].map{|s| s[:comp_effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0
630
+ comp_effort_tally += res[:care_components][:comp_fringe]
612
631
 
613
632
  res[:common_fringe_words] = []
614
633
  common_fringe.each do |word|
@@ -630,16 +649,23 @@ module AACMetrics::Metrics
630
649
  comp_effort_score += effort
631
650
  res[:common_fringe_words] << {word: word, effort: target_effort_score, comp_effort: comp_effort_score}
632
651
  end
633
- target_effort_tally += res[:common_fringe_words].map{|s| s[:effort] }.sum.to_f / res[:common_fringe_words].length.to_f * 1.0
634
- comp_effort_tally += res[:common_fringe_words].map{|s| s[:comp_effort] }.sum.to_f / res[:common_fringe_words].length.to_f * 1.0
652
+ res[:care_components][:common_fringe] = res[:common_fringe_words].map{|s| s[:effort] }.sum.to_f / res[:common_fringe_words].length.to_f * 1.0
653
+ target_effort_tally += res[:care_components][:common_fringe]
654
+ res[:care_components][:comp_common_fringe] = res[:common_fringe_words].map{|s| s[:comp_effort] }.sum.to_f / res[:common_fringe_words].length.to_f * 1.0
655
+ comp_effort_tally += res[:care_components][:comp_common_fringe]
635
656
 
636
657
  target_effort_tally += 70 # placeholder value for future added calculations
637
658
  comp_effort_tally += 70
638
659
 
660
+ # puts target_effort_tally
661
+ # puts comp_effort_tally
662
+ # puts (target_effort_tally - comp_effort_tally).abs
663
+ # puts JSON.pretty_generate(res[:care_components])
664
+ # raise 'arf'
639
665
 
640
666
 
641
- res[:target_effort_score] = target_effort_tally
642
- res[:comp_effort_score] = comp_effort_tally
667
+ res[:target_effort_score] = [0.0, 350.0 - target_effort_tally].max
668
+ res[:comp_effort_score] = [0.0, 350.0 - comp_effort_tally].max
643
669
  # puts "CONSIDER MAKING EASIER"
644
670
  res[:high_effort_words] = too_hard
645
671
  # puts too_hard.join(' ')