aac-metrics 0.1.2 → 0.1.3

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: 57db00976963f424efaab981a2b5066280b2de8dd8d3b241301ba3880fe1ce5c
4
+ data.tar.gz: fc386c30321ad3f94f03b00bfde72c19ea20dfebf400f6cc8322c841c5b5950b
5
5
  SHA512:
6
- metadata.gz: 3e54f361e67a70f8c68f85469ffcc0c9da6c8269928b707b2e6e4b5c353e5bc19f64de3d93d50c7c37304822924bf8ca862e35e3f6a4ed692ad2781c444403bb
7
- data.tar.gz: c12274971262bf327f9d2e6c29286bd1147fed6e5cf3d7a022a869d9810669e796fff20bfabcf13b3e973984a480a936e33468c4d4b2b7ad8f82737bf4b1b33d
6
+ metadata.gz: 4b9778b4e5a1dce3c1571bdd3038025b7ca6acec1dc9359cc4a04c5183dfd6640fd11fc06651d3059a5561f20d5f22974e6fa35c72d6b6273ee326b38c09612b
7
+ data.tar.gz: a2762f3a27e48b3445495d0ff16e46da23d80bd4d8e4a08f347df957fd3b595bc93f7697c769b92ba61bd633d57ec07b8df83c0bc2a1d374b763e48be9506724
@@ -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
  }
@@ -274,6 +294,7 @@ module AACMetrics::Metrics
274
294
  common_words_obj = AACMetrics::Loader.common_words(target[:locale])
275
295
  synonyms = AACMetrics::Loader.synonyms(target[:locale])
276
296
  sentences = AACMetrics::Loader.sentences(target[:locale])
297
+ fringe = AACMetrics::Loader.fringe_words(target[:locale])
277
298
  common_words_obj['efforts'].each{|w, e| sortable_efforts[w] ||= e }
278
299
  common_words = common_words_obj['words']
279
300
 
@@ -423,7 +444,6 @@ module AACMetrics::Metrics
423
444
  effort ||= spelling_effort(word)
424
445
  effort += (idx == 0) ? 0.0 : BOARD_CHANGE_PROCESSING_EFFORT
425
446
  comp_effort_score += effort
426
- puts " #{word} #{ee} #{effort}"
427
447
  end
428
448
  target_effort_score = target_effort_score / words.length
429
449
  comp_effort_score = comp_effort_score / words.length
@@ -431,8 +451,32 @@ module AACMetrics::Metrics
431
451
  end
432
452
  target_effort_tally += res[:sentences].map{|s| s[:effort] }.sum.to_f / res[:sentences].length.to_f * 3.0
433
453
  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
454
+
455
+ res[:fringe_words] = []
456
+ fringe.each do |word|
457
+ target_effort_score = 0.0
458
+ comp_effort_score = 0.0
459
+ synonym_words = [word] + (synonyms[word] || [])
460
+ effort = target_efforts[word] || target_efforts[word.downcase]
461
+ if !effort
462
+ synonym_words.each{|w| effort ||= target_efforts[w] }
463
+ end
464
+ effort ||= spelling_effort(word)
465
+ target_effort_score += effort
466
+
467
+ effort = comp_efforts[word] || comp_efforts[word.downcase]
468
+ if !effort
469
+ synonym_words.each{|w| effort ||= comp_efforts[w] }
470
+ end
471
+ effort ||= spelling_effort(word)
472
+ comp_effort_score += effort
473
+ res[:fringe_words] << {word: word, effort: target_effort_score, comp_effort: comp_effort_score}
474
+ end
475
+ target_effort_tally += res[:fringe_words].map{|s| s[:effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0
476
+ comp_effort_tally += res[:fringe_words].map{|s| s[:comp_effort] }.sum.to_f / res[:fringe_words].length.to_f * 2.0
477
+
478
+ target_effort_tally += 80 # placeholder value for future added calculations
479
+ comp_effort_tally += 80
436
480
 
437
481
 
438
482
 
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",