translit_kit 0.9
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +86 -0
- data/Rakefile +29 -0
- data/lib/hebrewword.rb +60 -0
- data/lib/permuter.rb +97 -0
- data/lib/phoneme_maps.rb +80 -0
- data/lib/phoneme_maps/long.json +41 -0
- data/lib/phoneme_maps/short.json +39 -0
- data/lib/phoneme_maps/single.json +40 -0
- data/lib/phonemizer.rb +170 -0
- data/lib/readme.md +120 -0
- data/lib/translit_kit.rb +2 -0
- data/lib/translit_kit/version.rb +3 -0
- data/lib/transliterator.rb +115 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +15 -0
- data/test/dummy/config/boot.rb +3 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +23 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +85939 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/hebrewword_test.rb +45 -0
- data/test/permuter_test.rb +53 -0
- data/test/phoneme_maps_test.rb +29 -0
- data/test/phonemizer_test.rb +209 -0
- data/test/test_helper.rb +29 -0
- data/test/transliterator_test.rb +75 -0
- metadata +155 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'hebrewword'
|
3
|
+
require 'phonemizer'
|
4
|
+
|
5
|
+
class HebrewWordTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
test "correctly stores the hebrew word" do
|
8
|
+
@heb = HebrewWord.new "שׁבּת"
|
9
|
+
assert_equal @heb.raw, "שׁבּת"
|
10
|
+
assert_equal @heb.to_s, "שׁבּת"
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
test "should transliterate a word" do
|
15
|
+
@heb = HebrewWord.new "בְּרֵאשִׁית"
|
16
|
+
assert_equal ["bereishis"], @heb.transliterate(:single)
|
17
|
+
|
18
|
+
@heb = HebrewWord.new "תְּשׁוּבָה"
|
19
|
+
assert_equal ["teshuvoh"], @heb.transliterate(:single)
|
20
|
+
|
21
|
+
@heb = HebrewWord.new "אַברָהָם"
|
22
|
+
assert_equal ["avroom", "avroam", "avroem", "avrohom", "avroham", "avrohem", "avraom", "avraam", "avraem", "avrahom", "avraham", "avrahem", "avreom", "avream", "avreem", "avrehom", "avreham", "avrehem"],
|
23
|
+
@heb.transliterate(:short)
|
24
|
+
end
|
25
|
+
|
26
|
+
test "should reject unknown phoneme_map names" do
|
27
|
+
@heb = HebrewWord.new "אַברָהָם"
|
28
|
+
assert_raises(RuntimeError) { @heb.transliterate(:blah) }
|
29
|
+
end
|
30
|
+
|
31
|
+
test "`phonemes` is delegated to the Phonemizer class" do
|
32
|
+
@heb = HebrewWord.new "אַברָהָם"
|
33
|
+
assert_equal @heb.phonemes, Phonemizer.new(@heb.raw).phonemes
|
34
|
+
end
|
35
|
+
|
36
|
+
test "method `t` alias for `transliterate`" do
|
37
|
+
@heb = HebrewWord.new "אַברָהָם"
|
38
|
+
assert_equal @heb.transliterate(:single), @heb.t(:single)
|
39
|
+
end
|
40
|
+
|
41
|
+
test "`inspect` function outputs correct translit counts" do
|
42
|
+
@heb = HebrewWord.new "אַברָהָם"
|
43
|
+
assert_equal @heb.inspect, "אַברָהָם: Permutations: #{@heb.transliterate(:single).length} single | #{@heb.transliterate(:short).length} short | #{@heb.transliterate(:long).length} long"
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'permuter'
|
3
|
+
|
4
|
+
class PermuterTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
setup do
|
7
|
+
@p = Permuter.new
|
8
|
+
end
|
9
|
+
|
10
|
+
test "should return [] if no arrays added" do
|
11
|
+
assert_equal [], @p.permutations
|
12
|
+
end
|
13
|
+
|
14
|
+
test "should add arrays to internal list" do
|
15
|
+
assert @p.empty?
|
16
|
+
@p.add_array []
|
17
|
+
assert @p.any?
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should remove arrays from internal list" do
|
21
|
+
@p.add_array []
|
22
|
+
assert @p.any?
|
23
|
+
@p.clear
|
24
|
+
assert @p.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
test "should produce single permutation if arrays have only one entry" do
|
28
|
+
@p.add_array [1]
|
29
|
+
@p.add_array [2]
|
30
|
+
@p.add_array [3]
|
31
|
+
assert_equal @p.permutations.length, 1
|
32
|
+
end
|
33
|
+
|
34
|
+
test "should produce all permutations for integer arrays" do
|
35
|
+
2.times { @p.add_array [0,1] }
|
36
|
+
assert_equal @p.permutations, ["00", "01", "10", "11"]
|
37
|
+
@p.clear
|
38
|
+
|
39
|
+
3.times { @p.add_array [1,2,3] }
|
40
|
+
assert_equal @p.permutations, ["111", "112", "113", "121", "122", "123", "131", "132", "133", "211", "212", "213", "221", "222", "223", "231", "232", "233", "311", "312", "313", "321", "322", "323", "331", "332", "333"]
|
41
|
+
end
|
42
|
+
|
43
|
+
test "should produce permutations for Latin letters" do
|
44
|
+
3.times { @p.add_array %w[a b c] }
|
45
|
+
assert_equal @p.permutations, ["aaa", "aab", "aac", "aba", "abb", "abc", "aca", "acb", "acc", "baa", "bab", "bac", "bba", "bbb", "bbc", "bca", "bcb", "bcc", "caa", "cab", "cac", "cba", "cbb", "cbc", "cca", "ccb", "ccc"]
|
46
|
+
end
|
47
|
+
|
48
|
+
test "should produce permutations for Hebrew letters" do
|
49
|
+
3.times { @p.add_array %w[ג ב א] }
|
50
|
+
assert_equal @p.permutations, ["גגג", "גגב", "גגא", "גבג", "גבב", "גבא", "גאג", "גאב", "גאא", "בגג", "בגב", "בגא", "בבג", "בבב", "בבא", "באג", "באב", "באא", "אגג", "אגב", "אגא", "אבג", "אבב", "אבא", "אאג", "אאב", "אאא"]
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'phoneme_maps'
|
3
|
+
|
4
|
+
class PhonemeMapsTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@p = PhonemeMaps.new
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
test "should load files in directory without blowing up" do
|
12
|
+
# Fetch all the filenames
|
13
|
+
filenames = Dir.new(@p.directory).entries.select {|f| f.include? '.json'}
|
14
|
+
# Strip the '.json' extension and convert to symbols
|
15
|
+
symbols = filenames.map {|f| f.sub(".json", '').to_sym }
|
16
|
+
|
17
|
+
assert_nothing_raised do
|
18
|
+
symbols.each {|s| @p.load s}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
test "should reject unknown file list names" do
|
23
|
+
assert_raises (RuntimeError) {@p.load :pan_galactic_gargle_blaster}
|
24
|
+
end
|
25
|
+
|
26
|
+
test "should reject malformed JSON files" do
|
27
|
+
assert_raises (RuntimeError) {@p.validate_json "{'missing_brace': true"}
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'phonemizer'
|
3
|
+
|
4
|
+
class PhonemizerTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
|
7
|
+
# STORAGE
|
8
|
+
|
9
|
+
test"correctly stores the hebrew word" do
|
10
|
+
@phon = Phonemizer.new "שׁבּת"
|
11
|
+
assert_equal @phon.raw, "שׁבּת"
|
12
|
+
end
|
13
|
+
|
14
|
+
# UNCHANGED CHARACTERS
|
15
|
+
|
16
|
+
test "should pass normal characters unchanged" do
|
17
|
+
@phon = Phonemizer.new "א"
|
18
|
+
assert_equal ["א"], @phon.phonemes
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should pass standard nekudos unchanged" do
|
22
|
+
@phon = Phonemizer.new "ְ ֶ ֻ ָ ַ ֵ ִ "
|
23
|
+
assert_equal ["ְ", "ֶ", "ֻ", "ָ", "ַ", "ֵ", "ִ"], @phon.phonemes
|
24
|
+
end
|
25
|
+
|
26
|
+
# Word splitting
|
27
|
+
|
28
|
+
test "should seperate letters" do
|
29
|
+
@phon = Phonemizer.new "אבג"
|
30
|
+
assert_equal ["א", "ב", "ג"], @phon.phonemes
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should seperate letters and nekudos" do
|
34
|
+
@phon = Phonemizer.new "דָג"
|
35
|
+
assert_equal ["ד", "ָ", "ג"], @phon.phonemes
|
36
|
+
end
|
37
|
+
|
38
|
+
# Altered characters
|
39
|
+
|
40
|
+
test "should strip spaces" do
|
41
|
+
utf8_en_space = [160].pack "U"
|
42
|
+
utf8_he_space = [32].pack "U"
|
43
|
+
|
44
|
+
@phon = Phonemizer.new utf8_en_space
|
45
|
+
assert_equal [], @phon.phonemes
|
46
|
+
|
47
|
+
@phon = Phonemizer.new utf8_he_space
|
48
|
+
assert_equal [], @phon.phonemes
|
49
|
+
end
|
50
|
+
|
51
|
+
# Normalize exotic characters
|
52
|
+
|
53
|
+
# Final Letters
|
54
|
+
test "should normalize final letters" do
|
55
|
+
@phon = Phonemizer.new "םןץףך"
|
56
|
+
assert_equal ["מ", "נ", "צ", "פ", "כ"], @phon.phonemes
|
57
|
+
end
|
58
|
+
|
59
|
+
test "should raise an error when final-letter normalizer is given a standard letter" do
|
60
|
+
@phon = Phonemizer.new ''
|
61
|
+
"אבגדהוזחטיכלמנסעפקרשתצ".split('').each do |letter|
|
62
|
+
assert_raises (RuntimeError) {@phon.send :normalize_final_letter, letter}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
# CHATAF nekudos
|
68
|
+
|
69
|
+
test "should normalize CHATAF nekudos" do
|
70
|
+
@phon = Phonemizer.new " ֲ ֳ ֱ"
|
71
|
+
assert_equal ["ַ", "ָ", "ֶ"], @phon.phonemes
|
72
|
+
end
|
73
|
+
|
74
|
+
test "should raise an error when the CHATAF-nekuda normalizer is given a standard nekuda" do
|
75
|
+
@phon = Phonemizer.new ''
|
76
|
+
["ְ", "ֶ", "ֻ", "ָ", "ַ", "ֵ", "ִ"].each do |nekuda|
|
77
|
+
assert_raises (RuntimeError) {@phon.send :deCHATAFize, nekuda}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# 'Full' nekudos
|
82
|
+
|
83
|
+
test "should normalize a full chirik ( אִי –> אִ)" do
|
84
|
+
@phon = Phonemizer.new "אִי"
|
85
|
+
assert_equal ["א", "ִ"], @phon.phonemes
|
86
|
+
end
|
87
|
+
|
88
|
+
test "should normalize a full TZEIREI ( אֵי –> אֵ )" do
|
89
|
+
@phon = Phonemizer.new "אֵי"
|
90
|
+
assert_equal ["א", "ֵ"], @phon.phonemes
|
91
|
+
end
|
92
|
+
|
93
|
+
test "should normalize a full CHOLOM ( וֹ –> ֹ )" do
|
94
|
+
@phon = Phonemizer.new "וֹ"
|
95
|
+
assert_equal ["ֹ"], @phon.phonemes
|
96
|
+
end
|
97
|
+
|
98
|
+
# Bad seperations
|
99
|
+
|
100
|
+
test "should not separate a shin and its dot (שׁ) " do
|
101
|
+
@phon = Phonemizer.new "שׁ"
|
102
|
+
assert_equal ["שׁ"], @phon.phonemes
|
103
|
+
end
|
104
|
+
|
105
|
+
test "should not seperate a CHES and PATACH when they end the word (חַ)" do
|
106
|
+
# As in פותחַ
|
107
|
+
@phon = Phonemizer.new "חַ"
|
108
|
+
assert_equal ["חַ"], @phon.phonemes
|
109
|
+
|
110
|
+
@phon = Phonemizer.new "חַחַ"
|
111
|
+
assert_equal ["ח", "ַ", "חַ"], @phon.phonemes
|
112
|
+
end
|
113
|
+
|
114
|
+
# DAGESH!
|
115
|
+
|
116
|
+
test "should strip DAGESH from unchanging letters" do
|
117
|
+
@phon = Phonemizer.new "אּבּגּדּהּוּזּחּטּיּכּלּמּנּסּעּפּצּקּרּשּשּׁתּ"
|
118
|
+
assert_equal ["בּ", "וּ", "כּ", "פּ", "תּ"], @phon.phonemes.select {|l| l.chars.include? "ּ"}
|
119
|
+
end
|
120
|
+
|
121
|
+
test "should not separate a DAGESH from its letter" do
|
122
|
+
@phon = Phonemizer.new "בּוּכּפּתּ"
|
123
|
+
assert_equal ["בּ", "וּ", "כּ", "פּ", "תּ"], @phon.phonemes
|
124
|
+
end
|
125
|
+
|
126
|
+
test "should not separate a DAGESH from its letter even separated by nekuda" do
|
127
|
+
@phon = Phonemizer.new "בַּ"
|
128
|
+
assert_equal ["בּ","ַ"], @phon.phonemes
|
129
|
+
end
|
130
|
+
|
131
|
+
test "should move DAGESH to correct letter" do
|
132
|
+
@phon = Phonemizer.new "פבּ"
|
133
|
+
assert_equal ["פ","בּ"], @phon.phonemes
|
134
|
+
end
|
135
|
+
|
136
|
+
test "should move DAGESH even when proceeded by nekuda" do
|
137
|
+
@phon = Phonemizer.new "פָבּ"
|
138
|
+
assert_equal ["פ", "ָ", "בּ"], @phon.phonemes
|
139
|
+
end
|
140
|
+
|
141
|
+
test "should move DAGESH even when followed by nekuda" do
|
142
|
+
@phon = Phonemizer.new "בָּא"
|
143
|
+
assert_equal ["בּ", "ָ", "א"], @phon.phonemes
|
144
|
+
end
|
145
|
+
|
146
|
+
test "should move DAGESH even when proceeded by SHIN ( שׁ )" do
|
147
|
+
@phon = Phonemizer.new "שׁבּ"
|
148
|
+
assert_equal ["שׁ", "בּ"], @phon.phonemes
|
149
|
+
end
|
150
|
+
|
151
|
+
test "should move DAGESH to VAV" do
|
152
|
+
@phon = Phonemizer.new "אוּ"
|
153
|
+
assert_equal ["א", "וּ"], @phon.phonemes
|
154
|
+
end
|
155
|
+
|
156
|
+
test "should raise error if DAGESH has no preceding letter (Orphaned DAGESH)" do
|
157
|
+
@phon = Phonemizer.new 'ּ'
|
158
|
+
assert_raises (RuntimeError) { @phon.phonemes }
|
159
|
+
end
|
160
|
+
|
161
|
+
# ==========================
|
162
|
+
# The internal index-finding helper method
|
163
|
+
|
164
|
+
test "should correctly identify the previous letter in raw hebrew string" do
|
165
|
+
# 'Returns the correct index'
|
166
|
+
word = "שַׁבָּת"
|
167
|
+
# word.chars.each_with_index {|c,i| puts "[#{i}]: \"#{c}\""}
|
168
|
+
#[0]: "ש"
|
169
|
+
#[1]: "ׁ"
|
170
|
+
#[2]: "ַ"
|
171
|
+
#[3]: "ב"
|
172
|
+
#[4]: "ּ"
|
173
|
+
#[5]: "ָ"
|
174
|
+
#[6]: "ת"
|
175
|
+
|
176
|
+
@phon = Phonemizer.new ""
|
177
|
+
|
178
|
+
assert_equal 6, @phon.send(:previous_letter_index, 6, word)
|
179
|
+
assert_equal 3, @phon.send(:previous_letter_index, 5, word)
|
180
|
+
assert_equal 3, @phon.send(:previous_letter_index, 4, word)
|
181
|
+
assert_equal 3, @phon.send(:previous_letter_index, 3, word)
|
182
|
+
assert_equal 0, @phon.send(:previous_letter_index, 2, word)
|
183
|
+
assert_equal 0, @phon.send(:previous_letter_index, 1, word)
|
184
|
+
assert_equal 0, @phon.send(:previous_letter_index, 0, word)
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
test "should correctly identify the previous letter" do
|
189
|
+
@phon = Phonemizer.new ""
|
190
|
+
|
191
|
+
# "Returns nil when no previous Hebrew chars"
|
192
|
+
assert_nil @phon.send(:previous_letter_index, 0, "abc")
|
193
|
+
|
194
|
+
# "Returns the index given if the index is a char"
|
195
|
+
assert_equal 0, @phon.send(:previous_letter_index, 0, "א")
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
# Full test cases
|
200
|
+
|
201
|
+
test "should break word into phonemes" do
|
202
|
+
@phon = Phonemizer.new "שַׁבָּת"
|
203
|
+
assert_equal ["שׁ", "ַ", "בּ", "ָ", "ת"], @phon.phonemes
|
204
|
+
|
205
|
+
@phon = Phonemizer.new "בְּרֵאשִׁית"
|
206
|
+
assert_equal ["בּ", "ְ", "ר", "ֵ", "א", "שׁ", "ִ", "ת"], @phon.phonemes
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|