aac-metrics 0.1.2 → 0.1.4

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: 5cfa37f885dec40c12ac7cbb86c44ac49ceec1138866b3de2e52b84facdddb87
4
- data.tar.gz: e29f98ec3c9aa3840a513787003a5db196dd09b81699c3a81b252439929e4dcd
3
+ metadata.gz: 5a2c7146372a916bfc65d6d4d50dda6b2a7a27aaf16fc59f3786e7dc38d87f49
4
+ data.tar.gz: ea1f5629b498e2f79e4bd9cd5d5d03085f4088da10f351fc1f52187b05744cda
5
5
  SHA512:
6
- metadata.gz: 3e54f361e67a70f8c68f85469ffcc0c9da6c8269928b707b2e6e4b5c353e5bc19f64de3d93d50c7c37304822924bf8ca862e35e3f6a4ed692ad2781c444403bb
7
- data.tar.gz: c12274971262bf327f9d2e6c29286bd1147fed6e5cf3d7a022a869d9810669e796fff20bfabcf13b3e973984a480a936e33468c4d4b2b7ad8f82737bf4b1b33d
6
+ metadata.gz: 178c2851f81ecb92e0d97a77a9553ecabcc97baca6fc4d717e8ea2b081e7318cbeb5552a876af896618d979dd7ff4277b2a24c5e32cd6359345f8a760b36eee3
7
+ data.tar.gz: 63d7a6cf112e6fc53f7630cf478a37d57374d4b52c934d2c215614b307555486bb34de34316b7255daa2884d51e887c0f380abfdeb85218035d5c4c34df2d68a
@@ -357,6 +357,22 @@ module AACMetrics::Loader
357
357
  @@sentences[locale] = res
358
358
  end
359
359
 
360
+ def self.fringe_words(locale)
361
+ @@fringe_words ||= {}
362
+ return @@fringe_words[locale] if @@fringe_words[locale]
363
+ locale = locale.split(/-|_/)[0]
364
+ path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'sets', "fringe.#{locale}.json"))
365
+ all_words = []
366
+ list = JSON.parse(File.read(path))
367
+ list.each do |set|
368
+ set['categories'].each do |cat|
369
+ all_words += cat['words']
370
+ end
371
+ end
372
+ all_words.uniq!
373
+ @@synonyms[locale] = all_words
374
+ end
375
+
360
376
  def self.base_words(locale)
361
377
  @@base_words ||= {}
362
378
  return @@base_words[locale] if @@base_words[locale]
@@ -2,6 +2,9 @@
2
2
  # Scores for average effort level for word sets (spelling if that's th only way)
3
3
  # Effort scores for sentence corpus
4
4
  # Effort algorithms for scanning/eyes
5
+ # TODO: manual way to flag button as conceptually
6
+ # related to the same-locaed button on the
7
+ # prior board, allowing for a discounted penalty
5
8
  module AACMetrics::Metrics
6
9
  # TODO:
7
10
  # 1. When navigating from one board to the next, grid locations
@@ -21,11 +24,12 @@ module AACMetrics::Metrics
21
24
  locale = nil
22
25
  buttons = []
23
26
  refs = {}
24
- total_boards = 1
27
+ grid = {}
25
28
 
26
29
  if obfset.is_a?(Hash) && obfset['buttons']
27
30
  locale = obfset['locale'] || 'en'
28
31
  refs = obfset['reference_counts']
32
+ grid = obfset['grid']
29
33
  buttons = []
30
34
  obfset['buttons'].each do |btn|
31
35
  buttons << {
@@ -42,7 +46,15 @@ module AACMetrics::Metrics
42
46
  visited_board_ids = {}
43
47
  to_visit = [{board: obfset[0], level: 0, entry_x: 1.0, entry_y: 1.0}]
44
48
  refs = {}
49
+ rows_tally = 0.0
50
+ cols_tally = 0.0
51
+ root_rows = nil
52
+ root_cols = nil
45
53
  obfset.each do |board|
54
+ root_rows ||= board['grid']['rows']
55
+ root_cols ||= board['grid']['columns']
56
+ rows_tally += board['grid']['rows']
57
+ cols_tally += board['grid']['columns']
46
58
  # determine frequency within the board set
47
59
  # for each semantic_id and clone_id
48
60
  if board['clone_ids']
@@ -58,6 +70,10 @@ module AACMetrics::Metrics
58
70
  end
59
71
  end
60
72
  end
73
+ if (rows_tally / obfset.length.to_f - root_rows).abs > 3 || (cols_tally / obfset.length.to_f - root_cols).abs > 3
74
+ root_rows = (rows_tally / obfset.length.to_f).floor
75
+ root_cols = (cols_tally / obfset.length.to_f).floor
76
+ end
61
77
  pcts = {}
62
78
  refs.each do |id, cnt|
63
79
  pcts[id] = cnt.to_f / obfset.length.to_f
@@ -191,6 +207,10 @@ module AACMetrics::Metrics
191
207
  total_boards: total_boards,
192
208
  total_buttons: buttons.length,
193
209
  reference_counts: refs,
210
+ grid: {
211
+ rows: root_rows,
212
+ columns: root_cols
213
+ },
194
214
  buttons: buttons,
195
215
  levels: clusters
196
216
  }
@@ -236,14 +256,17 @@ module AACMetrics::Metrics
236
256
  compare_words = []
237
257
  compare_buttons = {}
238
258
  comp_efforts = {}
259
+ comp_levels = {}
239
260
  compare[:buttons].each do |btn|
240
261
  compare_words << btn[:label]
241
262
  compare_buttons[btn[:label]] = btn
242
263
  comp_efforts[btn[:label]] = btn[:effort]
264
+ comp_levels[btn[:label]] = btn[:level]
243
265
  end
244
266
 
245
267
  sortable_efforts = {}
246
268
  target_efforts = {}
269
+ target_levels = {}
247
270
  target_words = []
248
271
  # Track effort scores for each button in the set,
249
272
  # used to sort and for assessing priority
@@ -252,6 +275,7 @@ module AACMetrics::Metrics
252
275
  res[:buttons].each{|b|
253
276
  target_words << b[:label]
254
277
  target_efforts[b[:label]] = b[:effort]
278
+ target_levels[b[:label]] = b[:level]
255
279
  sortable_efforts[b[:label]] = b[:effort]
256
280
  comp = compare_buttons[b[:label]]
257
281
  if comp
@@ -274,6 +298,7 @@ module AACMetrics::Metrics
274
298
  common_words_obj = AACMetrics::Loader.common_words(target[:locale])
275
299
  synonyms = AACMetrics::Loader.synonyms(target[:locale])
276
300
  sentences = AACMetrics::Loader.sentences(target[:locale])
301
+ fringe = AACMetrics::Loader.fringe_words(target[:locale])
277
302
  common_words_obj['efforts'].each{|w, e| sortable_efforts[w] ||= e }
278
303
  common_words = common_words_obj['words']
279
304
 
@@ -393,7 +418,6 @@ module AACMetrics::Metrics
393
418
  res[:cores][list['id']] = {name: list['name'], list: list['words'], average_effort: list_effort, comp_effort: comp_effort}
394
419
  end
395
420
  target_effort_tally = (target_effort_tally / core_lists.to_a.length) * 5.0
396
-
397
421
  comp_effort_tally = (comp_effort_tally / core_lists.to_a.length) * 5.0
398
422
 
399
423
  # TODO: Assemble or allow a battery of word combinations,
@@ -401,29 +425,42 @@ module AACMetrics::Metrics
401
425
  # as well as an average level of effort across combinations.
402
426
  res[:sentences] = []
403
427
  sentences.each do |words|
404
- puts " #{words.join(' ')}"
405
- BOARD_CHANGE_PROCESSING_EFFORT
406
428
  target_effort_score = 0.0
407
429
  comp_effort_score = 0.0
408
430
  words.each_with_index do |word, idx|
409
431
  synonym_words = [word] + (synonyms[word] || [])
410
432
  effort = target_efforts[word] || target_efforts[word.downcase]
433
+ level = target_levels[word] || target_levels[word.downcase]
411
434
  if !effort
412
- synonym_words.each{|w| effort ||= target_efforts[w] }
435
+ synonym_words.each do |w|
436
+ if !effort && target_efforts[w]
437
+ effort = target_efforts[w]
438
+ level = target_levels[w]
439
+ end
440
+ end
413
441
  end
414
442
  effort ||= spelling_effort(word)
415
- effort += (idx == 0) ? 0.0 : BOARD_CHANGE_PROCESSING_EFFORT
443
+ if level && level > 0 && idx > 0
444
+ effort += BOARD_CHANGE_PROCESSING_EFFORT
445
+ end
416
446
  ee = effort
417
447
  target_effort_score += effort
418
448
 
419
449
  effort = comp_efforts[word] || comp_efforts[word.downcase]
450
+ level = comp_levels[word] || comp_levels[word.downcase]
420
451
  if !effort
421
- synonym_words.each{|w| effort ||= comp_efforts[w] }
452
+ synonym_words.each do |w|
453
+ if !effort && comp_efforts[w]
454
+ effort = comp_efforts[w]
455
+ level = comp_levels[w]
456
+ end
457
+ end
422
458
  end
423
459
  effort ||= spelling_effort(word)
424
- effort += (idx == 0) ? 0.0 : BOARD_CHANGE_PROCESSING_EFFORT
460
+ if level && level > 0 && idx > 0
461
+ effort += BOARD_CHANGE_PROCESSING_EFFORT
462
+ end
425
463
  comp_effort_score += effort
426
- puts " #{word} #{ee} #{effort}"
427
464
  end
428
465
  target_effort_score = target_effort_score / words.length
429
466
  comp_effort_score = comp_effort_score / words.length
@@ -431,8 +468,32 @@ module AACMetrics::Metrics
431
468
  end
432
469
  target_effort_tally += res[:sentences].map{|s| s[:effort] }.sum.to_f / res[:sentences].length.to_f * 3.0
433
470
  comp_effort_tally += res[:sentences].map{|s| s[:comp_effort] }.sum.to_f / res[:sentences].length.to_f * 3.0
434
- target_effort_tally += 100 # placeholder value for future added calculations
435
- comp_effort_tally += 100
471
+
472
+ res[:fringe_words] = []
473
+ fringe.each do |word|
474
+ target_effort_score = 0.0
475
+ comp_effort_score = 0.0
476
+ synonym_words = [word] + (synonyms[word] || [])
477
+ effort = target_efforts[word] || target_efforts[word.downcase]
478
+ if !effort
479
+ synonym_words.each{|w| effort ||= target_efforts[w] }
480
+ end
481
+ effort ||= spelling_effort(word)
482
+ target_effort_score += effort
483
+
484
+ effort = comp_efforts[word] || comp_efforts[word.downcase]
485
+ if !effort
486
+ synonym_words.each{|w| effort ||= comp_efforts[w] }
487
+ end
488
+ effort ||= spelling_effort(word)
489
+ comp_effort_score += effort
490
+ res[:fringe_words] << {word: word, effort: target_effort_score, comp_effort: comp_effort_score}
491
+ end
492
+ target_effort_tally += res[:fringe_words].map{|s| s[:effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0
493
+ comp_effort_tally += res[:fringe_words].map{|s| s[:comp_effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0
494
+
495
+ target_effort_tally += 80 # placeholder value for future added calculations
496
+ comp_effort_tally += 80
436
497
 
437
498
 
438
499
 
data/lib/aac-metrics.rb CHANGED
@@ -43,7 +43,7 @@
43
43
  # thing explainer phrases, lists of words
44
44
 
45
45
  module AACMetrics
46
- VERSION = "0.1"
46
+ VERSION = "0.2"
47
47
  require 'aac-metrics/loader'
48
48
  require 'aac-metrics/metrics'
49
49
  end
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1",
2
+ "version": "0.2",
3
3
  "files": [
4
4
  "l84f-e9fafa55d4.common.en.obfset",
5
5
  "qc60-61bbf6171e.common.en.obfset",