text_hyphen 1.0.0

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.
data/test/rebuild.rb ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # rebuild -- text-hyphen -- 16.03.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path("../lib/", File.dirname(__FILE__))
5
+ $: << File.expand_path("../ext/text", File.dirname(__FILE__))
6
+
7
+ install = File.expand_path("../install.rb", File.dirname(__FILE__))
8
+ bld_dir = File.expand_path("../ext/text", File.dirname(__FILE__))
9
+ inst_dir = File.expand_path("..", File.dirname(__FILE__))
10
+ Dir.chdir(bld_dir){
11
+ system("make clean")
12
+ }
13
+ Dir.chdir(inst_dir) {
14
+ system("ruby #{install} config")
15
+ system("ruby #{install} setup")
16
+ }
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env ruby
2
+ # TestDictionary -- text-hyphen -- 16.03.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $: << File.expand_path("../lib", File.dirname(__FILE__))
6
+ $: << File.expand_path("../ext", File.dirname(__FILE__))
7
+
8
+ require 'test/unit'
9
+ require 'rebuild'
10
+ require 'text/hyphen'
11
+
12
+ module Text
13
+ module Hyphen
14
+ class TestDictionary < Test::Unit::TestCase
15
+ def setup
16
+ @dict_path = File.expand_path('data/hyph_de_CH.dic',
17
+ File.dirname(__FILE__))
18
+ end
19
+ def test_initialize__no_args
20
+ assert_raises(ArgumentError) {
21
+ Dictionary.new
22
+ }
23
+ end
24
+ def test_initialize__bogus_path
25
+ assert_raises(Errno::ENOENT) {
26
+ Dictionary.new('/no/such/dictionary.dic')
27
+ }
28
+ end
29
+ def test_initialize__de_CH
30
+ assert_nothing_raised {
31
+ Dictionary.new(@dict_path)
32
+ }
33
+ end
34
+ def test_analyze
35
+ dict = Dictionary.new(@dict_path)
36
+
37
+ expected = [0,0,0]
38
+ result = dict.analyze("hat")
39
+ assert_equal(expected, result)
40
+
41
+ expected = [0,0,0,1,0,0,0,0,0,0,0,0]
42
+ result = dict.analyze("Fensterbrett")
43
+ assert_equal(expected, result)
44
+
45
+ expected = [0,-4,0,0,1,0,0,0,0,0]
46
+ result = dict.analyse("Waschbrett")
47
+ assert_equal(expected, result)
48
+ end
49
+ def test_analyze__none
50
+ dict = Dictionary.new(@dict_path)
51
+ expected = [0,0,0]
52
+ result = dict.analyze("hat")
53
+ assert_equal(expected, result)
54
+ result = dict.analyze("ist")
55
+ assert_equal(expected, result)
56
+ end
57
+ def test_analyze__2
58
+ dict = Dictionary.new(@dict_path)
59
+ expected = [0,0,0,-1,0,1,0,0,1,0,-1,0,0]
60
+ # K u e n s t-l e r-p e c h
61
+ result = dict.analyze("Kuenstlerpech")
62
+ assert_equal(expected, result)
63
+ end
64
+ def test_analyze__2
65
+ dict = Dictionary.new(@dict_path)
66
+ expected = [0,-4,0,0,1,0,0,0,0,0]
67
+ # W a s c h-b r e t t
68
+ result = dict.analyse("Waschbrett")
69
+ assert_equal(expected, result)
70
+ end
71
+ def test_analyze__3
72
+ dict = Dictionary.new(@dict_path)
73
+ expected = [0,0,1,0,0,1,0,1,-4,0,0,0,0,1,0,0,0,0]
74
+ # K a u-s a l-z u- s a m m e n-h a n g
75
+ result = dict.analyse("Kausalzusammenhang")
76
+ assert_equal(expected, result)
77
+ end
78
+ def test_first_chance
79
+ dict = Dictionary.new(@dict_path)
80
+ result = dict.first_chance("Kausalzusammenhang")
81
+ assert_equal(3, result)
82
+
83
+ result = dict.first_chance("ist")
84
+ assert_equal(nil, result)
85
+ end
86
+ def test_hyphenate_first
87
+ dict = Dictionary.new(@dict_path)
88
+ expected = "Kau-salzusammenhang"
89
+ result = dict.hyphenate_first("Kausalzusammenhang")
90
+ assert_equal(expected, result)
91
+
92
+ expected = "ist"
93
+ result = dict.hyphenate_first("ist")
94
+ assert_equal(expected, result)
95
+ end
96
+ def test_last_chance_before
97
+ dict = Dictionary.new(@dict_path)
98
+ result = dict.last_chance_before(7, "Kausalzusammenhang")
99
+ assert_equal(6, result)
100
+
101
+ result = dict.last_chance_before(2, "ist")
102
+ assert_equal(nil, result)
103
+ end
104
+ def test_hyphenate_before
105
+ dict = Dictionary.new(@dict_path)
106
+ expected = "Kausal-zusammenhang"
107
+ result = dict.hyphenate_before(7, "Kausalzusammenhang")
108
+ assert_equal(expected, result)
109
+
110
+ expected = "ist"
111
+ result = dict.hyphenate_before(2, "ist")
112
+ assert_equal(expected, result)
113
+ end
114
+ def test_analyze__4
115
+ dict = Dictionary.new(@dict_path)
116
+ expected = [0,0,0,-1,1,0,0,0,0,0,3,0,0,0,-1,1,-4,0,0,1,0,0,0]
117
+ # D a m p f-w a l z e n-a b z u g- f e n s-t e r
118
+ result = dict.analyse("Dampfwalzenabzugfenster")
119
+ assert_equal(expected, result)
120
+ end
121
+ def test_best_chance
122
+ dict = Dictionary.new(@dict_path)
123
+ result = dict.best_chance("Dampfwalzenabzugfenster")
124
+ assert_equal(11, result)
125
+ end
126
+ def test_hyphenate_best
127
+ dict = Dictionary.new(@dict_path)
128
+ expected = "Dampfwalzen-abzugfenster"
129
+ result = dict.hyphenate_best("Dampfwalzenabzugfenster")
130
+ assert_equal(expected, result)
131
+
132
+ expected = "ist"
133
+ result = dict.hyphenate_best("ist")
134
+ assert_equal(expected, result)
135
+ end
136
+ def test_best_chance_before
137
+ dict = Dictionary.new(@dict_path)
138
+ result = dict.best_chance_before(15, "Dampfwalzenabzugfenster")
139
+ assert_equal(11, result)
140
+ result = dict.best_chance_before(10, "Dampfwalzenabzugfenster")
141
+ assert_equal(5, result)
142
+ end
143
+ def test_hyphenate_best_before
144
+ dict = Dictionary.new(@dict_path)
145
+ expected = "Dampfwalzen-abzugfenster"
146
+ result = dict.hyphenate_best_before(15, "Dampfwalzenabzugfenster")
147
+ assert_equal(expected, result)
148
+
149
+ expected = "Dampf-walzenabzugfenster"
150
+ result = dict.hyphenate_best_before(10, "Dampfwalzenabzugfenster")
151
+ assert_equal(expected, result)
152
+
153
+ expected = "ist"
154
+ result = dict.hyphenate_best("ist")
155
+ assert_equal(expected, result)
156
+ end
157
+ end
158
+ end
159
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: text_hyphen
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Masaomi Hatakeyama, Zeno R.R. Davatz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-22 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hoe
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 47
30
+ segments:
31
+ - 2
32
+ - 8
33
+ - 0
34
+ version: 2.8.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: Ruby bindings to OpenOffice.org Hyphenation-Library.
38
+ email:
39
+ - mhatakeyama@ywesee.com, zdavatz@ywesee.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - LICENCE.txt
47
+ - Manifest.txt
48
+ - README.txt
49
+ files:
50
+ - History.txt
51
+ - LICENCE.txt
52
+ - Manifest.txt
53
+ - README.txt
54
+ - Rakefile
55
+ - ext/text/MANIFEST
56
+ - ext/text/extconf.rb
57
+ - ext/text/text_hyphen.c
58
+ - install.rb
59
+ - lib/text/hyphen.rb
60
+ - redist/libhnj-0.1.1.tar.gz
61
+ - test/data/README_hyph_de_CH.txt
62
+ - test/data/hyph_de_CH.dic
63
+ - test/rebuild.rb
64
+ - test/test_dictionary.rb
65
+ has_rdoc: true
66
+ homepage: http://scm.ywesee.com/?p=text-hyphen/.git;a=summary
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --main
72
+ - README.txt
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project: text_hyphen
96
+ rubygems_version: 1.3.7
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Ruby bindings to OpenOffice.org Hyphenation-Library.
100
+ test_files:
101
+ - test/test_dictionary.rb