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 +4 -4
- data/lib/aac-metrics/loader.rb +16 -0
- data/lib/aac-metrics/metrics.rb +48 -4
- data/lib/aac-metrics.rb +1 -1
- data/sets/common_words.en.json +1 -1
- data/sets/fringe.en.json +2048 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57db00976963f424efaab981a2b5066280b2de8dd8d3b241301ba3880fe1ce5c
|
4
|
+
data.tar.gz: fc386c30321ad3f94f03b00bfde72c19ea20dfebf400f6cc8322c841c5b5950b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b9778b4e5a1dce3c1571bdd3038025b7ca6acec1dc9359cc4a04c5183dfd6640fd11fc06651d3059a5561f20d5f22974e6fa35c72d6b6273ee326b38c09612b
|
7
|
+
data.tar.gz: a2762f3a27e48b3445495d0ff16e46da23d80bd4d8e4a08f347df957fd3b595bc93f7697c769b92ba61bd633d57ec07b8df83c0bc2a1d374b763e48be9506724
|
data/lib/aac-metrics/loader.rb
CHANGED
@@ -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]
|
data/lib/aac-metrics/metrics.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
435
|
-
|
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
data/sets/common_words.en.json
CHANGED