air18n 0.1.29 → 0.1.30
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.
|
@@ -370,10 +370,10 @@ module Air18n
|
|
|
370
370
|
compare_to = translation_pair[:previous_translation].size
|
|
371
371
|
else
|
|
372
372
|
distance = levenshtein_distance_fast(
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
translation_pair[:previous_translation].scan(/[[:alnum:]]+/),
|
|
374
|
+
translation_pair[:translation].scan(/[[:alnum:]]+/),
|
|
375
375
|
1, 0, 1)
|
|
376
|
-
compare_to =
|
|
376
|
+
compare_to = translation_pair[:previous_translation].scan(/[[:alnum:]]+/).size
|
|
377
377
|
end
|
|
378
378
|
|
|
379
379
|
proportion_translated = [distance.to_f / compare_to.to_f, 1.0].min
|
|
@@ -400,7 +400,6 @@ module Air18n
|
|
|
400
400
|
phrase_to_phrase_translations = pt_scope.all.group_by { |pt| [pt.locale, pt.phrase_id] }
|
|
401
401
|
phrase_to_phrase_translations.each do |(locale, phrase_id), phrase_translations|
|
|
402
402
|
phrase_translations.sort_by! { |pt| pt.created_at }
|
|
403
|
-
LoggingHelper.info "Getting previous translation!"
|
|
404
403
|
previous_translation = PhraseTranslation.where("created_at < ?", phrase_translations.first.created_at - 1.second).
|
|
405
404
|
where(:locale => locale).
|
|
406
405
|
where(:phrase_id => phrase_id).
|
|
@@ -453,6 +452,8 @@ module Air18n
|
|
|
453
452
|
# Break text into words for purposes of word count.
|
|
454
453
|
# First uses to_s to convert text to a string; so for a nil input, returns
|
|
455
454
|
# empty array.
|
|
455
|
+
# Should only be used for English text, because it only looks at words
|
|
456
|
+
# composed of regexp "\w".
|
|
456
457
|
def self.segment(text)
|
|
457
458
|
text.to_s.scan(/\w+/)
|
|
458
459
|
end
|
data/lib/air18n/version.rb
CHANGED
|
@@ -513,6 +513,23 @@ describe Air18n::PhraseTranslation do
|
|
|
513
513
|
words_translated, words_verified = Air18n::PhraseTranslation.word_counts_from_translation_pair(pair)
|
|
514
514
|
words_translated.should == 1 # 3 / 17 * 5 = 0.88, rounds to 1
|
|
515
515
|
words_verified.should == 4
|
|
516
|
+
|
|
517
|
+
# Test that Greek works. There was once a bug where word segmentation
|
|
518
|
+
# didn't work for non-Latin alphabets.
|
|
519
|
+
pair = {
|
|
520
|
+
:translation=>"ακύρωση",
|
|
521
|
+
:previous_translation=>"ακύρωση",
|
|
522
|
+
:was_stale=>false,
|
|
523
|
+
:locale=>"el",
|
|
524
|
+
:user_id=>2895375,
|
|
525
|
+
:previous_user_id=>2462280,
|
|
526
|
+
:datetime=>Date.new(2012, 11, 2),
|
|
527
|
+
:source_word_count=>1,
|
|
528
|
+
:phrase_key=>"cancel"
|
|
529
|
+
}
|
|
530
|
+
words_translated, words_verified = Air18n::PhraseTranslation.word_counts_from_translation_pair(pair)
|
|
531
|
+
words_translated.should == 0
|
|
532
|
+
words_verified.should == 1
|
|
516
533
|
end
|
|
517
534
|
|
|
518
535
|
it 'should compute correct monthly activities' do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: air18n
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.30
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -13,7 +13,7 @@ authors:
|
|
|
13
13
|
autorequire:
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
|
-
date: 2012-11-
|
|
16
|
+
date: 2012-11-14 00:00:00.000000000 Z
|
|
17
17
|
dependencies:
|
|
18
18
|
- !ruby/object:Gem::Dependency
|
|
19
19
|
name: i18n
|