Module: AACMetrics::Metrics
- Defined in:
- lib/aac-metrics/metrics.rb
Overview
Effort algorithms for scanning/eyes
Constant Summary collapse
- SQRT2 =
Math.sqrt(2)
- BUTTON_SIZE_MULTIPLIER =
0.09- FIELD_SIZE_MULTIPLIER =
0.005- VISUAL_SCAN_MULTIPLIER =
0.015- BOARD_CHANGE_PROCESSING_EFFORT =
1.0- DISTANCE_MULTIPLIER =
0.4- DISTANCE_THRESHOLD_TO_SKIP_VISUAL_SCAN =
0.1- SKIPPED_VISUAL_SCAN_DISTANCE_MULTIPLIER =
0.5- SAME_LOCATION_AS_PRIOR_DISCOUNT =
0.1- RECOGNIZABLE_SEMANTIC_FROM_PRIOR_DISCOUNT =
0.5- RECOGNIZABLE_SEMANTIC_FROM_OTHER_DISCOUNT =
0.6- RECOGNIZABLE_CLONE_FROM_PRIOR_DISCOUNT =
0.33- RECOGNIZABLE_CLONE_FROM_OTHER_DISCOUNT =
0.4- REUSED_SEMANTIC_FROM_OTHER_DISCOUNT =
0.0025- REUSED_CLONE_FROM_OTHER_DISCOUNT =
0.005
Class Method Summary collapse
-
.analyze(obfset, output = true, include_obfset = false) ⇒ Object
A.
- .analyze_and_compare(obfset, compset, include_obfset = false) ⇒ Object
- .button_size_effort(rows, cols) ⇒ Object
- .distance_effort(x, y, entry_x, entry_y) ⇒ Object
- .field_size_effort(button_count) ⇒ Object
- .spelling_effort(word) ⇒ Object
- .visual_scan_effort(prior_buttons) ⇒ Object
Class Method Details
.analyze(obfset, output = true, include_obfset = false) ⇒ Object
-
When navigating from one board to the next, grid locations
with the same clone_id or semantic_id should result in a discount to overall search based more on the number of uncloned/unsemantic buttons than the number of total buttons (perhaps also factoring in the percent of board with that id present in the full board set)
-
When selecting a button with a semantic_id or clone_id,
a discount to both search and selection should be applied based on the percent of boards that contain the same id at that grid location
-
When selecting a button with a semantic_id or clone_id,
if the same id was present on the previous board, an additional discount to search and selection should be applied D When selecting a button with a semantic_id or clone_id, apply a steep discount to the button in the same location as the link used to get there if they share an id
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/aac-metrics/metrics.rb', line 31 def self.analyze(obfset, output=true, include_obfset=false) locale = nil = [] set_refs = {} grid = {} if obfset.is_a?(Hash) && obfset['buttons'] locale = obfset['locale'] || 'en' set_refs = obfset['reference_counts'] grid = obfset['grid'] = [] obfset['buttons'].each do |btn| << { id: btn['id'], label: btn['label'], level: btn['level'], effort: btn['effort'], semantic_id: btn['semantic_id'], clone_id: btn['clone_id'] } end total_boards = obfset['total_boards'] else visited_board_ids = {} to_visit = [{board: obfset[0], level: 0, entry_x: 1.0, entry_y: 1.0}] set_refs = {} cell_refs = {} rows_tally = 0.0 cols_tally = 0.0 root_rows = nil root_cols = nil # Gather repeated words/concepts obfset.each do |board| # try to figure out the average grid size for board set root_rows ||= board['grid']['rows'] root_cols ||= board['grid']['columns'] rows_tally += board['grid']['rows'] cols_tally += board['grid']['columns'] # determine frequency within the board set # for each semantic_id and clone_id if board['clone_ids'] board['clone_ids'].each do |id| set_refs[id] ||= 0 set_refs[id] += 1 end end board['grid']['rows'].times do |row_idx| board['grid']['columns'].times do |col_idx| id = (board['grid']['order'][row_idx] || [])[col_idx] cell_refs["#{row_idx}.#{col_idx}"] ||= 0.0 cell_refs["#{row_idx}.#{col_idx}"] += id ? 1.0 : 0.25 end end if board['semantic_ids'] board['semantic_ids'].each do |id| set_refs[id] ||= 0 set_refs[id] += 1 end end end # If the average grid size is much different than the root # grid size, only then use the average as the size for this board set if (rows_tally / obfset.length.to_f - root_rows).abs > 3 || (cols_tally / obfset.length.to_f - root_cols).abs > 3 root_rows = (rows_tally / obfset.length.to_f).floor root_cols = (cols_tally / obfset.length.to_f).floor end set_pcts = {} set_refs.each do |id, cnt| loc = id.split(/-/)[1] set_pcts[id] = cnt.to_f / (cell_refs[loc] || obfset.length).to_f end locale = obfset[0]['locale'] = {} while to_visit.length > 0 board = to_visit.shift visited_board_ids[board[:board]['id']] = board[:level] puts board[:board]['id'] if output btn_height = 1.0 / board[:board]['grid']['rows'].to_f btn_width = 1.0 / board[:board]['grid']['columns'].to_f board_effort = 0 # add effort for level of complexity when new board is rendered = (board[:board]['grid']['rows'], board[:board]['grid']['columns']) board_effort += # add effort for number of visible buttons field_size = field_size_effort(board[:board]['grid']['order'].flatten.length) board_effort += field_size # decrease effort here for every button on the board # whose semantic_id or clone_id is repeated in the board set # -0.0025 (* pct of matching boards) for semantic_id # -0.005 (* pct of matching boards) for clone_id reuse_discount = 0.0 board[:board]['grid']['rows'].times do |row_idx| board[:board]['grid']['columns'].times do |col_idx| = (board[:board]['grid']['order'][row_idx] || [])[col_idx] = board[:board]['buttons'].detect{|b| b['id'] == } if && ['clone_id'] && set_pcts[['clone_id']] reuse_discount += REUSED_CLONE_FROM_OTHER_DISCOUNT * set_pcts[['clone_id']] elsif && ['semantic_id'] && set_pcts[['semantic_id']] reuse_discount += REUSED_SEMANTIC_FROM_OTHER_DISCOUNT * set_pcts[['semantic_id']] end end end board_effort -= reuse_discount = 0 # Calculate the percent of links to this board # that had or were linked by clone_ids or semantic_ids board_pcts = {} obfset.each do |brd| brd['buttons'].each do |link_btn| # For every board that links to this board if link_btn['load_board'] && link_btn['load_board']['id'] == board[:board]['id'] board_pcts['all'] ||= 0 board_pcts['all'] += 1 # Count how many of those links have a clone_id or semantic_id if link_btn['clone_id'] board_pcts[link_btn['clone_id']] ||= 0 board_pcts[link_btn['clone_id']] += 1 end if link_btn['semantic_id'] board_pcts[link_btn['semantic_id']] ||= 0 board_pcts[link_btn['semantic_id']] += 1 end # Also count all the clone_ids and semantic_ids # anywhere on the boards that link to this one (brd['clone_ids'] || []).uniq.each do |cid| board_pcts["upstream-#{cid}"] ||= 0 board_pcts["upstream-#{cid}"] += 1 end (brd['semantic_ids'] || []).uniq.each do |sid| board_pcts["upstream-#{sid}"] ||= 0 board_pcts["upstream-#{sid}"] += 1 end end end end board_pcts.each do |id, cnt| board_pcts[id] = board_pcts[id].to_f / board_pcts['all'].to_f end board[:board]['grid']['rows'].times do |row_idx| board[:board]['grid']['columns'].times do |col_idx| = (board[:board]['grid']['order'][row_idx] || [])[col_idx] = board[:board]['buttons'].detect{|b| b['id'] == } # prior_buttons += 0.1 if !button next unless x = (btn_width / 2) + (btn_width * col_idx) y = (btn_height / 2) + (btn_height * row_idx) # prior_buttons = (row_idx * board[:board]['grid']['columns']) + col_idx # calculate the percentage of links that point to this button # and match on semantic_id or clone_id effort = 0 # Additional discount on board search effort, # remember that semantic_id and clone_id are # keyed to the same grid location, so matches only # apply to that specific location # - if this button's semantic_id or clone_id # was also present anywhere on the prior board # board_effort * 0.5 for semantic_id # board_effort * 0.33 for clone_id # - if this button's semantic_id or clone_id # is directly used to navigate to this board # board_effort * 0.1 for semantic_id # board_effort * 0.1 for clone_id = board_effort if board_pcts[['semantic_id']] # TODO: Pull out these magic numbers = [, * SAME_LOCATION_AS_PRIOR_DISCOUNT / board_pcts[['semantic_id']]].min elsif board_pcts["upstream-#{['semantic_id']}"] = [, * RECOGNIZABLE_SEMANTIC_FROM_PRIOR_DISCOUNT / board_pcts["upstream-#{['semantic_id']}"]].min end if board_pcts[['clone_id']] = [, * SAME_LOCATION_AS_PRIOR_DISCOUNT / board_pcts[['clone_id']]].min elsif board_pcts["upstream-#{['clone_id']}"] = [, * RECOGNIZABLE_CLONE_FROM_PRIOR_DISCOUNT / board_pcts["upstream-#{['clone_id']}"]].min end effort += # add effort for percent distance from entry point distance = distance_effort(x, y, board[:entry_x], board[:entry_y]) # TODO: decrease effective distance if the semantic_id or clone_id: # - are used on other boards in the set (semi) # distance * 0.5 (* pct of matching boards) for semantic_id # distance * 0.33 (* pct of matching boards) for clone_id # - was also present on the prior board (total) # distance * 0.5 for semantic_id # distance * 0.33 for clone_id # - is directly used to navigate to this board # distance * 0.1 * (pct of links that match) for semantic_id # distance * 0.1 * (pct of links that match) for clone_id if board_pcts[['semantic_id']] distance = [distance, distance * SAME_LOCATION_AS_PRIOR_DISCOUNT / board_pcts[['semantic_id']]].min elsif board_pcts["upstream-#{['semantic_id']}"] distance = [distance, distance * RECOGNIZABLE_SEMANTIC_FROM_PRIOR_DISCOUNT / board_pcts["upstream-#{['semantic_id']}"]].min elsif set_pcts[['semantic_id']] distance = [distance, distance * RECOGNIZABLE_SEMANTIC_FROM_OTHER_DISCOUNT / set_pcts[['semantic_id']]].min end if board_pcts[['clone_id']] distance = [distance, distance * SAME_LOCATION_AS_PRIOR_DISCOUNT / board_pcts[['clone_id']]].min elsif board_pcts["upstream-#{['clone_id']}"] distance = [distance, distance * RECOGNIZABLE_CLONE_FROM_PRIOR_DISCOUNT / board_pcts["upstream-#{['clone_id']}"]].min elsif set_pcts[['clone_id']] distance = [distance, distance * RECOGNIZABLE_CLONE_FROM_OTHER_DISCOUNT / set_pcts[['clone_id']]].min end effort += distance if distance > DISTANCE_THRESHOLD_TO_SKIP_VISUAL_SCAN || (board[:entry_x] == 1.0 && board[:entry_y] == 1.0) # add small effort for every prior (visible) button when visually scanning visual_scan = visual_scan_effort() effort += visual_scan else # ..unless it's right by the previous button, then # add tiny effort for local scan effort += distance * SKIPPED_VISUAL_SCAN_DISTANCE_MULTIPLIER end # add cumulative effort from previous sequence effort += board[:prior_effort] || 0 += 1 if ['load_board'] try_visit = false # For linked buttons, only traverse if # the board hasn't been visited, or if # we're not visiting it at a lower level if visited_board_ids[['load_board']['id']] == nil try_visit = true elsif visited_board_ids[['load_board']['id']] > board[:level] + 1 try_visit = true end if to_visit.detect{|b| b[:board]['id'] == ['load_board']['id'] && b[:level] <= board[:level] + 1 } try_visit = false end if try_visit next_board = obfset.detect{|brd| brd['id'] == ['load_board']['id'] } change_effort = BOARD_CHANGE_PROCESSING_EFFORT if next_board to_visit.push({ board: next_board, level: board[:level] + 1, prior_effort: effort + change_effort, entry_x: x, entry_y: y, entry_clone_id: ['clone_id'], entry_semantic_id: ['semantic_id'] }) end end else word = ['label'] existing = [word] if !existing || effort < existing[:effort] #board[:level] < existing[:level] if board_pcts[['clone_id']] effort -= [BOARD_CHANGE_PROCESSING_EFFORT, BOARD_CHANGE_PROCESSING_EFFORT * 0.3 / board_pcts[['clone_id']]].min elsif board_pcts[['semantic_id']] effort -= [BOARD_CHANGE_PROCESSING_EFFORT, BOARD_CHANGE_PROCESSING_EFFORT * 0.5 / board_pcts[['semantic_id']]].min end [word] = { id: "#{['id']}::#{board[:board]['id']}", label: word, level: board[:level], effort: effort, } end end ['effort'] = effort end end end = .to_a.map(&:last) total_boards = visited_board_ids.keys.length end = .sort_by{|b| [b[:effort] || 1, b[:label] || ""] } clusters = {} .each do |btn| clusters[btn[:level]] ||= [] clusters[btn[:level]] << btn end res = { analysis_version: AACMetrics::VERSION, locale: locale, total_boards: total_boards, total_buttons: .length, reference_counts: set_refs, grid: { rows: root_rows, columns: root_cols }, buttons: , levels: clusters } if include_obfset res[:obfset] = obfset end res end |
.analyze_and_compare(obfset, compset, include_obfset = false) ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
# File 'lib/aac-metrics/metrics.rb', line 364 def self.analyze_and_compare(obfset, compset, include_obfset=false) target = AACMetrics::Metrics.analyze(obfset, false, include_obfset) res = {}.merge(target) compare = AACMetrics::Metrics.analyze(compset, false) res[:comp_boards] = compare[:total_boards] res[:comp_buttons] = compare[:total_buttons] res[:comp_grid] = compare[:grid] compare_words = [] = {} comp_efforts = {} comp_levels = {} compare[:buttons].each do |btn| compare_words << btn[:label] [btn[:label]] = btn comp_efforts[btn[:label]] = btn[:effort] comp_levels[btn[:label]] = btn[:level] end sortable_efforts = {} target_efforts = {} target_levels = {} target_words = [] # Track effort scores for each button in the set, # used to sort and for assessing priority # TODO: keep a list of expected effort scores for # very frequent core words and use that when available res[:buttons].each{|b| target_words << b[:label] target_efforts[b[:label]] = b[:effort] target_levels[b[:label]] = b[:level] sortable_efforts[b[:label]] = b[:effort] comp = [b[:label]] if comp b[:comp_level] = comp[:level] b[:comp_effort] = comp[:effort] end } # Effort scores are the mean of thw scores from the # two sets, or just a singular value if in only one set compare[:buttons].each{|b| if sortable_efforts[b[:label]] sortable_efforts[b[:label]] += b[:effort] sortable_efforts[b[:label]] /= 2 else sortable_efforts[b[:label]] ||= b[:effort] end } core_lists = AACMetrics::Loader.core_lists(target[:locale]) common_words_obj = AACMetrics::Loader.common_words(target[:locale]) synonyms = AACMetrics::Loader.synonyms(target[:locale]) sentences = AACMetrics::Loader.sentences(target[:locale]) fringe = AACMetrics::Loader.fringe_words(target[:locale]) common_fringe = AACMetrics::Loader.common_fringe_words(target[:locale]) common_words_obj['efforts'].each{|w, e| sortable_efforts[w] ||= e } common_words = common_words_obj['words'] # Track which words are significantly harder or easier than expected too_easy = [] too_hard = [] target[:buttons].each do |btn| if btn[:effort] && common_words_obj['efforts'][btn[:label]] if btn[:effort] < common_words_obj['efforts'][btn[:label]] - 5 too_easy << btn[:label] elsif btn[:effort] > common_words_obj['efforts'][btn[:label]] + 3 too_hard << btn[:label] end end end missing = (compare_words - target_words).sort_by{|w| sortable_efforts[w] } missing = missing.select do |word| !synonyms[word] || (synonyms[word] & target_words).length == 0 end extras = (target_words - compare_words).sort_by{|w| sortable_efforts[w] } extras = extras.select do |word| !synonyms[word] || (synonyms[word] & compare_words).length == 0 end # puts "MISSING WORDS (#{missing.length}):" res[:missing_words] = missing # puts missing.join(' ') # puts "EXTRA WORDS (#{extras.length}):" res[:extra_words] = extras # puts extras.join(' ') overlap = (target_words & compare_words & common_words) # puts "OVERLAPPING WORDS (#{overlap.length}):" res[:overlapping_words] = overlap # puts overlap.join(' ') missing = (common_words - target_words) missing = missing.select do |word| !synonyms[word] || (synonyms[word] & target_words).length == 0 end common_effort = 0 comp_effort = 0 common_words.each do |word| effort = target_efforts[word] if !effort && synonyms[word] synonyms[word].each do |syn| effort ||= target_efforts[syn] end end effort ||= 2 + (word.length * 2.5) common_effort += effort effort = comp_efforts[word] if !effort && synonyms[word] synonyms[word].each do |syn| effort ||= comp_efforts[syn] end end effort ||= 2 + (word.length * 2.5) comp_effort += effort end common_effort = common_effort.to_f / common_words.length.to_f comp_effort = comp_effort.to_f / common_words.length.to_f # puts "MISSING FROM COMMON (#{missing.length})" res[:missing] = { :common => {name: "Common Word List", list: missing} } res[:cores] = { :common => {name: "Common Word List", list: common_words, average_effort: common_effort, comp_effort: comp_effort} } target_effort_tally = 0.0 comp_effort_tally = 0.0 # For each core list, find any missing words, and compute # the average level of effort for all words in the set, # using a fallback effort metric if the word isn't in the # board set # puts missing.join(' ') core_lists.each do |list| missing = [] comp_missing = [] list_effort = 0 comp_effort = 0 list['words'].each do |word| words = [word] + (synonyms[word] || []) # Check if any words from the core list are missing in the set if (target_words & words).length == 0 missing << word end if (compare_words & words).length == 0 comp_missing << word end # Calculate the effort for the target and comp sets effort = target_efforts[word] if !effort words.each{|w| effort ||= target_efforts[w] } end # Fallback penalty for missing word effort ||= spelling_effort(word) list_effort += effort effort = comp_efforts[word] if !effort words.each{|w| effort ||= comp_efforts[w] } end effort ||= spelling_effort(word) comp_effort += effort end if missing.length > 0 # puts "MISSING FROM #{list['id']} (#{missing.length}):" res[:missing][list['id']] = {name: list['name'], list: missing, average_effort: list_effort} # puts missing.join(' ') end list_effort = list_effort.to_f / list['words'].length.to_f comp_effort = comp_effort.to_f / list['words'].length.to_f target_effort_tally += list_effort comp_effort_tally += comp_effort res[:cores][list['id']] = {name: list['name'], list: list['words'], average_effort: list_effort, comp_effort: comp_effort} end target_effort_tally = (target_effort_tally / core_lists.to_a.length) * 5.0 comp_effort_tally = (comp_effort_tally / core_lists.to_a.length) * 5.0 # TODO: Assemble or allow a battery of word combinations, # and calculate the level of effort for each sequence, # as well as an average level of effort across combinations. res[:sentences] = [] sentences.each do |words| target_effort_score = 0.0 comp_effort_score = 0.0 words.each_with_index do |word, idx| synonym_words = [word] + (synonyms[word] || []) effort = target_efforts[word] || target_efforts[word.downcase] level = target_levels[word] || target_levels[word.downcase] if !effort synonym_words.each do |w| if !effort && target_efforts[w] effort = target_efforts[w] level = target_levels[w] end end end effort ||= spelling_effort(word) if level && level > 0 && idx > 0 effort += BOARD_CHANGE_PROCESSING_EFFORT end ee = effort target_effort_score += effort effort = comp_efforts[word] || comp_efforts[word.downcase] level = comp_levels[word] || comp_levels[word.downcase] if !effort synonym_words.each do |w| if !effort && comp_efforts[w] effort = comp_efforts[w] level = comp_levels[w] end end end effort ||= spelling_effort(word) if level && level > 0 && idx > 0 effort += BOARD_CHANGE_PROCESSING_EFFORT end comp_effort_score += effort end target_effort_score = target_effort_score / words.length comp_effort_score = comp_effort_score / words.length res[:sentences] << {sentence: words.join(' '), words: words, effort: target_effort_score, comp_effort: comp_effort_score} end target_effort_tally += res[:sentences].map{|s| s[:effort] }.sum.to_f / res[:sentences].length.to_f * 3.0 comp_effort_tally += res[:sentences].map{|s| s[:comp_effort] }.sum.to_f / res[:sentences].length.to_f * 3.0 res[:fringe_words] = [] fringe.each do |word| target_effort_score = 0.0 comp_effort_score = 0.0 synonym_words = [word] + (synonyms[word] || []) effort = target_efforts[word] || target_efforts[word.downcase] if !effort synonym_words.each{|w| effort ||= target_efforts[w] } end effort ||= spelling_effort(word) target_effort_score += effort effort = comp_efforts[word] || comp_efforts[word.downcase] if !effort synonym_words.each{|w| effort ||= comp_efforts[w] } end effort ||= spelling_effort(word) comp_effort_score += effort res[:fringe_words] << {word: word, effort: target_effort_score, comp_effort: comp_effort_score} end target_effort_tally += res[:fringe_words].map{|s| s[:effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0 comp_effort_tally += res[:fringe_words].map{|s| s[:comp_effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0 res[:common_fringe_words] = [] common_fringe.each do |word| target_effort_score = 0.0 comp_effort_score = 0.0 synonym_words = [word] + (synonyms[word] || []) effort = target_efforts[word] || target_efforts[word.downcase] if !effort synonym_words.each{|w| effort ||= target_efforts[w] } end effort ||= spelling_effort(word) target_effort_score += effort effort = comp_efforts[word] || comp_efforts[word.downcase] if !effort synonym_words.each{|w| effort ||= comp_efforts[w] } end effort ||= spelling_effort(word) comp_effort_score += effort res[:common_fringe_words] << {word: word, effort: target_effort_score, comp_effort: comp_effort_score} end target_effort_tally += res[:common_fringe_words].map{|s| s[:effort] }.sum.to_f / res[:common_fringe_words].length.to_f * 1.0 comp_effort_tally += res[:common_fringe_words].map{|s| s[:comp_effort] }.sum.to_f / res[:common_fringe_words].length.to_f * 1.0 target_effort_tally += 70 # placeholder value for future added calculations comp_effort_tally += 70 res[:target_effort_score] = target_effort_tally res[:comp_effort_score] = comp_effort_tally # puts "CONSIDER MAKING EASIER" res[:high_effort_words] = too_hard # puts too_hard.join(' ') # puts "CONSIDER LESS PRIORITY" res[:low_effort_words] = too_easy # puts too_easy.join(' ') res end |
.button_size_effort(rows, cols) ⇒ Object
344 345 346 |
# File 'lib/aac-metrics/metrics.rb', line 344 def self.(rows, cols) BUTTON_SIZE_MULTIPLIER * (rows + cols) / 2 end |
.distance_effort(x, y, entry_x, entry_y) ⇒ Object
356 357 358 |
# File 'lib/aac-metrics/metrics.rb', line 356 def self.distance_effort(x, y, entry_x, entry_y) Math.sqrt((x - entry_x) ** 2 + (y - entry_y) ** 2) / SQRT2 * DISTANCE_MULTIPLIER end |
.field_size_effort(button_count) ⇒ Object
348 349 350 |
# File 'lib/aac-metrics/metrics.rb', line 348 def self.field_size_effort() FIELD_SIZE_MULTIPLIER * end |
.spelling_effort(word) ⇒ Object
360 361 362 |
# File 'lib/aac-metrics/metrics.rb', line 360 def self.spelling_effort(word) 10 + (word.length * 2.5) end |
.visual_scan_effort(prior_buttons) ⇒ Object
352 353 354 |
# File 'lib/aac-metrics/metrics.rb', line 352 def self.visual_scan_effort() * VISUAL_SCAN_MULTIPLIER end |