word_aligner 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/lib/word_aligner.rb +1 -0
- data/lib/word_error_rate_collection.rb +55 -0
- data/spec/lib/word_aligner/aligner_spec.rb +1 -0
- data/spec/lib/word_error_rate_collection.rb_spec.rb +22 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c32d9ee5728f79dcb8f723768c832ec8807a321d
|
4
|
+
data.tar.gz: f51260981c579aac86155c91e2b11184d5663929
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64d4796c1231a2a758d744bde20177c2bf867e4ad8134f576ebb9e3a0fb1cd43e49f3ab4b797b151f1c24cc4ed71e0441c2e68b1b79dc2759f64cfcb844305a7
|
7
|
+
data.tar.gz: 9b97b27165cee5f997f4fd4a057e33342e71d37415e115b5295a524697f8ff1459b4b0d8a85541a6ae838832587f8bd141e025b0213174049c2ddea76917e407
|
data/README.md
CHANGED
@@ -31,11 +31,14 @@ $ bundle
|
|
31
31
|
|
32
32
|
error_rate.correct => 2
|
33
33
|
error_rate.errors => 1
|
34
|
-
error_rate.
|
35
|
-
error_rate.
|
36
|
-
error_rate.
|
34
|
+
error_rate.percentage_correct => 66.0
|
35
|
+
error_rate.percentage_incorrect => 33.0
|
36
|
+
error_rate.percentage_accurate => 66.0
|
37
37
|
```
|
38
38
|
|
39
|
+
There is also ```WordErrorRateCollection``` if you need to calculate
|
40
|
+
the word error rate for multiple hypotheses.
|
41
|
+
|
39
42
|
## Contributing
|
40
43
|
|
41
44
|
1. Fork it
|
data/lib/word_aligner.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
class WordErrorRateCollection
|
2
|
+
|
3
|
+
attr_reader :entries
|
4
|
+
|
5
|
+
def initialize(entries)
|
6
|
+
@entries = entries
|
7
|
+
end
|
8
|
+
|
9
|
+
def correct_words
|
10
|
+
entries.map(&:correct_words).inject(0, :+)
|
11
|
+
end
|
12
|
+
|
13
|
+
def incorrect_words
|
14
|
+
entries.map(&:incorrect_words).inject(0, :+)
|
15
|
+
end
|
16
|
+
|
17
|
+
def words
|
18
|
+
entries.map(&:words).inject(0, :+)
|
19
|
+
end
|
20
|
+
|
21
|
+
def percentage_correct
|
22
|
+
percent_rate(correct_words)
|
23
|
+
end
|
24
|
+
|
25
|
+
def percentage_incorrect
|
26
|
+
percent_rate(incorrect_words)
|
27
|
+
end
|
28
|
+
|
29
|
+
def percentage_accurate
|
30
|
+
100 - percentage_incorrect
|
31
|
+
end
|
32
|
+
|
33
|
+
def aligned_transcription
|
34
|
+
'TOTAL'
|
35
|
+
end
|
36
|
+
|
37
|
+
def aligned_hypothesis
|
38
|
+
'TOTAL'
|
39
|
+
end
|
40
|
+
|
41
|
+
def method_missing(name)
|
42
|
+
'N/A'
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_partial_path
|
46
|
+
'word_error_rates/word_error_rate'
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def percent_rate(value)
|
52
|
+
value * 100.0 / [words, 1].max
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WordErrorRateCollection do
|
4
|
+
|
5
|
+
word_error_rates = []
|
6
|
+
word_error_rates << WordAligner.align('hello and welcome', 'hullo and wulcome')
|
7
|
+
word_error_rates << WordAligner.align('good morning', 'good lulz')
|
8
|
+
|
9
|
+
subject { WordErrorRateCollection.new(word_error_rates) }
|
10
|
+
|
11
|
+
its(:entries) { should eq word_error_rates }
|
12
|
+
its(:aligned_transcription) { should eq 'TOTAL' }
|
13
|
+
its(:aligned_hypothesis) { should eq 'TOTAL' }
|
14
|
+
|
15
|
+
its(:correct_words) { should eq 2 }
|
16
|
+
its(:incorrect_words) { should eq 3 }
|
17
|
+
its(:words) { should eq 5 }
|
18
|
+
|
19
|
+
its(:percentage_correct) { should be_within(0.1).of(40) }
|
20
|
+
its(:percentage_incorrect) { should be_within(0.1).of(60) }
|
21
|
+
its(:percentage_accurate) { should be_within(0.1).of(40) }
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: word_aligner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej
|
@@ -100,8 +100,10 @@ files:
|
|
100
100
|
- lib/word_aligner.rb
|
101
101
|
- lib/word_aligner/aligner.rb
|
102
102
|
- lib/word_aligner/word_error_rate.rb
|
103
|
+
- lib/word_error_rate_collection.rb
|
103
104
|
- spec/lib/word_aligner/aligner_spec.rb
|
104
105
|
- spec/lib/word_aligner/word_error_rate_spec.rb
|
106
|
+
- spec/lib/word_error_rate_collection.rb_spec.rb
|
105
107
|
- spec/lib/word_aligner_spec.rb
|
106
108
|
- spec/sample_data/grab_for_comparision.rb
|
107
109
|
- spec/sample_data/regression/sentences.yml
|