braille 0.0.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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/braille.gemspec +35 -0
- data/lib/braille.rb +3 -0
- data/lib/braille/ko.rb +20 -0
- data/lib/braille/ko/char.rb +13 -0
- data/lib/braille/ko/constants.rb +191 -0
- data/lib/braille/ko/convert.rb +7 -0
- data/lib/braille/ko/jaso.rb +66 -0
- data/lib/braille/ko/word.rb +22 -0
- data/lib/braille/version.rb +3 -0
- metadata +106 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2da6b8607edac4508b64eab96895e6865f62fd11
|
|
4
|
+
data.tar.gz: 0d9983bad68a4440b6beb72f87b37bffc9c95d17
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b568098da999c8c79ed7bbbe4c724a0ea278bd81041355da2d242c673a514779aac61694a57144405b26b41825249580d884bb2f86a69c63e21115834ce0fc4e
|
|
7
|
+
data.tar.gz: eb0c7c2b8fcf9398ac4195ff5e8d571db61a737664c11214320f8e2f10947433afef70b9e5629a870b06425262e794d32ad29424a6b2a5355b451fbadb18eba2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at capollux10@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Junwoo Hwang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Braille
|
|
2
|
+
|
|
3
|
+
한글 점역기
|
|
4
|
+
|
|
5
|
+
Braille Translator for Korean
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'braille'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
```console
|
|
18
|
+
$ bundle
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
```console
|
|
24
|
+
$ gem install braille
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
require 'braille'
|
|
31
|
+
|
|
32
|
+
Braille::Ko.translate('저는 줄루입니다') #=> '⠨⠎⠉⠵ ⠨⠯⠐⠍⠕⠃⠉⠕⠊'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
'한국 점자 규정'에 따른 점역 예외 상황들에 대한 대응이 완벽하지 않습니다. 오역이 가능성이 존재하며, 정확한 점역을 위해서는 [국립국어원 한국 점자 규정](http://www.korean.go.kr/front/etcData/etcDataView.do?etc_seq=542&mn_id=46)을 참고해 주시기 바랍니다.
|
|
36
|
+
|
|
37
|
+
## Contributing
|
|
38
|
+
|
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/capollux/braille. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
44
|
+
|
|
45
|
+
## Code of Conduct
|
|
46
|
+
|
|
47
|
+
Everyone interacting in the Braille project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/braille/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "braille"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/braille.gemspec
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "braille/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "braille"
|
|
8
|
+
spec.version = Braille::VERSION
|
|
9
|
+
spec.authors = ["Junwoo Hwang"]
|
|
10
|
+
spec.email = ["capollux10@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Braille Translator"
|
|
13
|
+
spec.homepage = "https://rubygems.org/gems/braille"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
if spec.respond_to?(:metadata)
|
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
20
|
+
else
|
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
22
|
+
"public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = "exe"
|
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
35
|
+
end
|
data/lib/braille.rb
ADDED
data/lib/braille/ko.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
require 'braille/ko/constants'
|
|
3
|
+
require 'braille/ko/char'
|
|
4
|
+
require 'braille/ko/jaso'
|
|
5
|
+
require 'braille/ko/word'
|
|
6
|
+
require 'braille/ko/convert'
|
|
7
|
+
|
|
8
|
+
module Braille
|
|
9
|
+
module Ko
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
def translate(input)
|
|
13
|
+
words = input.scan(/[가-힣.,!?]+|[0-9A-Za-z.,!?]+/)
|
|
14
|
+
translated = words.map { |word| Word.new(word).translate }
|
|
15
|
+
translated.join(' ')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#encoding: UTF-8
|
|
2
|
+
module Braille
|
|
3
|
+
|
|
4
|
+
BASE_UNICODE = 44032
|
|
5
|
+
|
|
6
|
+
DEFAULT_CHO = 11
|
|
7
|
+
DEFAULT_JONG = 0
|
|
8
|
+
|
|
9
|
+
# JASO SET
|
|
10
|
+
CHO_SET = ["ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"]
|
|
11
|
+
JUNG_SET = ["ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"]
|
|
12
|
+
JONG_SET = ["", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"]
|
|
13
|
+
|
|
14
|
+
# Braille SET
|
|
15
|
+
CHO = {
|
|
16
|
+
'' => '',
|
|
17
|
+
'ㄱ' => '⠈',
|
|
18
|
+
'ㄲ' => '⠠⠈',
|
|
19
|
+
'ㄴ' => '⠉',
|
|
20
|
+
'ㄷ' => '⠊',
|
|
21
|
+
'ㄸ' => '⠠⠊',
|
|
22
|
+
'ㄹ' => '⠐',
|
|
23
|
+
'ㅁ' => '⠑',
|
|
24
|
+
'ㅂ' => '⠘',
|
|
25
|
+
'ㅃ' => '⠠⠘',
|
|
26
|
+
'ㅅ' => '⠠',
|
|
27
|
+
'ㅆ' => '⠠⠠',
|
|
28
|
+
'ㅇ' => '', # 원래 (⠛)인데 생략
|
|
29
|
+
'ㅈ' => '⠨',
|
|
30
|
+
'ㅉ' => '⠠⠨',
|
|
31
|
+
'ㅊ' => '⠰',
|
|
32
|
+
'ㅋ' => '⠋',
|
|
33
|
+
'ㅌ' => '⠓',
|
|
34
|
+
'ㅍ' => '⠙',
|
|
35
|
+
'ㅎ' => '⠚'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
JUNG = {
|
|
39
|
+
'' => '',
|
|
40
|
+
'ㅏ' => '⠣',
|
|
41
|
+
'ㅑ' => '⠜',
|
|
42
|
+
'ㅓ' => '⠎',
|
|
43
|
+
'ㅕ' => '⠱',
|
|
44
|
+
'ㅗ' => '⠥',
|
|
45
|
+
'ㅛ' => '⠬',
|
|
46
|
+
'ㅜ' => '⠍',
|
|
47
|
+
'ㅠ' => '⠩',
|
|
48
|
+
'ㅡ' => '⠪',
|
|
49
|
+
'ㅣ' => '⠕',
|
|
50
|
+
'ㅐ' => '⠗',
|
|
51
|
+
'ㅔ' => '⠝',
|
|
52
|
+
'ㅒ' => '⠜⠗',
|
|
53
|
+
'ㅖ' => '⠌',
|
|
54
|
+
'ㅘ' => '⠧',
|
|
55
|
+
'ㅙ' => '⠧⠗',
|
|
56
|
+
'ㅚ' => '⠽',
|
|
57
|
+
'ㅝ' => '⠏',
|
|
58
|
+
'ㅞ' => '⠏⠗',
|
|
59
|
+
'ㅟ' => '⠍⠗',
|
|
60
|
+
'ㅢ' => '⠺'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
JONG = {
|
|
64
|
+
'' => '',
|
|
65
|
+
'ㄱ' => '⠁',
|
|
66
|
+
'ㄲ' => '⠁⠁',
|
|
67
|
+
'ㄳ' => '⠁⠄',
|
|
68
|
+
'ㄴ' => '⠒',
|
|
69
|
+
'ㄵ' => '⠒⠅',
|
|
70
|
+
'ㄶ' => '⠒⠴',
|
|
71
|
+
'ㄷ' => '⠔',
|
|
72
|
+
'ㄹ' => '⠂',
|
|
73
|
+
'ㄺ' => '⠂⠁',
|
|
74
|
+
'ㄻ' => '⠂⠢',
|
|
75
|
+
"ㄼ" => '⠂⠃',
|
|
76
|
+
"ㄽ" => '⠂⠄',
|
|
77
|
+
"ㄾ" => '⠂⠦',
|
|
78
|
+
"ㄿ" => '⠂⠲',
|
|
79
|
+
"ㅀ" => '⠂⠴',
|
|
80
|
+
'ㅁ' => '⠢',
|
|
81
|
+
'ㅂ' => '⠃',
|
|
82
|
+
'ㅄ' => '⠃⠄',
|
|
83
|
+
'ㅅ' => '⠄',
|
|
84
|
+
'ㅆ' => '⠌',
|
|
85
|
+
'ㅇ' => '⠶',
|
|
86
|
+
'ㅈ' => '⠅',
|
|
87
|
+
'ㅊ' => '⠆',
|
|
88
|
+
'ㅋ' => '⠖',
|
|
89
|
+
'ㅌ' => '⠦',
|
|
90
|
+
'ㅍ' => '⠲',
|
|
91
|
+
'ㅎ' => '⠴'
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
ABBREVIATIONS = {
|
|
95
|
+
'가' => '⠫',
|
|
96
|
+
'나' => '⠉',
|
|
97
|
+
'다' => '⠊',
|
|
98
|
+
'마' => '⠑',
|
|
99
|
+
'바' => '⠘',
|
|
100
|
+
'사' => '⠇',
|
|
101
|
+
'자' => '⠨',
|
|
102
|
+
'카' => '⠋',
|
|
103
|
+
'타' => '⠓',
|
|
104
|
+
'파' => '⠙',
|
|
105
|
+
'하' => '⠚',
|
|
106
|
+
'것' => '⠸⠎',
|
|
107
|
+
'억' => '⠹', #=> ㅓ ㄱ
|
|
108
|
+
'언' => '⠾', #=> ㅓ ㄴ
|
|
109
|
+
'얼' => '⠞', #=> ㅓ ㄹ
|
|
110
|
+
'연' => '⠡', #=> ㅕ ㄴ
|
|
111
|
+
'열' => '⠳', #=> ㅕ ㄹ
|
|
112
|
+
'영' => '⠻', #=> ㅕ ㅇ
|
|
113
|
+
'옥' => '⠭', #=> ㅗ ㄱ
|
|
114
|
+
'온' => '⠷', #=> ㅗ ㄴ
|
|
115
|
+
'옹' => '⠿', #=> ㅗ ㅇ
|
|
116
|
+
'운' => '⠛', #=> ㅜ ㄴ
|
|
117
|
+
'울' => '⠯', #=> ㅜ ㄹ
|
|
118
|
+
'은' => '⠵', #=> ㅡ ㄴ
|
|
119
|
+
'을' => '⠮', #=> ㅡ ㄹ
|
|
120
|
+
'인' => '⠟', #=> ㅣ ㄴ
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
GROUPS = {
|
|
124
|
+
'그래서' => '⠁⠎',
|
|
125
|
+
'그러나' => '⠁⠉',
|
|
126
|
+
'그러면' => '⠁⠒',
|
|
127
|
+
'그러므로' => '⠁⠢',
|
|
128
|
+
'그런데' => '⠁⠝',
|
|
129
|
+
'그리고' => '⠁⠥',
|
|
130
|
+
'그리하여' => '⠁⠱'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
ALPHABETS = {
|
|
134
|
+
'a' => '⠁',
|
|
135
|
+
'b' => '⠃',
|
|
136
|
+
'c' => '⠉',
|
|
137
|
+
'd' => '⠙',
|
|
138
|
+
'e' => '⠑',
|
|
139
|
+
'f' => '⠋',
|
|
140
|
+
'g' => '⠛',
|
|
141
|
+
'h' => '⠓',
|
|
142
|
+
'i' => '⠊',
|
|
143
|
+
'j' => '⠚',
|
|
144
|
+
'k' => '⠅',
|
|
145
|
+
'l' => '⠇',
|
|
146
|
+
'm' => '⠍',
|
|
147
|
+
'n' => '⠝',
|
|
148
|
+
'o' => '⠕',
|
|
149
|
+
'p' => '⠏',
|
|
150
|
+
'q' => '⠟',
|
|
151
|
+
'r' => '⠗',
|
|
152
|
+
's' => '⠎',
|
|
153
|
+
't' => '⠞',
|
|
154
|
+
'u' => '⠥',
|
|
155
|
+
'v' => '⠧',
|
|
156
|
+
'w' => '⠺',
|
|
157
|
+
'x' => '⠭',
|
|
158
|
+
'y' => '⠽',
|
|
159
|
+
'z' => '⠵'
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
NUMBERS = {
|
|
163
|
+
'1' => '⠁',
|
|
164
|
+
'2' => '⠃',
|
|
165
|
+
'3' => '⠉',
|
|
166
|
+
'4' => '⠙',
|
|
167
|
+
'5' => '⠑',
|
|
168
|
+
'6' => '⠋',
|
|
169
|
+
'7' => '⠛',
|
|
170
|
+
'8' => '⠓',
|
|
171
|
+
'9' => '⠊',
|
|
172
|
+
'0' => '⠚',
|
|
173
|
+
',' => '⠂'
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
SPECIAL = {
|
|
177
|
+
:capital => '⠠',
|
|
178
|
+
:number => '⠼',
|
|
179
|
+
:alphabet_open => '⠴',
|
|
180
|
+
:alphabet_close => '⠲',
|
|
181
|
+
:on => '⠿'
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
PUNCTUATION = {
|
|
185
|
+
'.' => '⠲',
|
|
186
|
+
',' => '⠐',
|
|
187
|
+
'!' => '⠖',
|
|
188
|
+
'?' => '⠦'
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Braille
|
|
2
|
+
module Ko
|
|
3
|
+
class Jaso
|
|
4
|
+
attr_reader :syllable
|
|
5
|
+
|
|
6
|
+
def initialize(syllable="")
|
|
7
|
+
@syllable = syllable # syllable은 오로지 한글 음절만 오도록 한다.
|
|
8
|
+
|
|
9
|
+
# 여러 글자가 들어왔을 경우 첫 한 음절만 가져오도록 or 전부다 처리하도록, Exception 처리
|
|
10
|
+
|
|
11
|
+
base_syllable = @syllable.unpack("U").shift - BASE_UNICODE
|
|
12
|
+
|
|
13
|
+
@jong = (base_syllable) % 28
|
|
14
|
+
@jung = ((base_syllable - @jong) / 28) % 21
|
|
15
|
+
@cho = (((base_syllable - @jong) / 28) - @jung) / 21
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def cho
|
|
19
|
+
CHO_SET[@cho]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def jung
|
|
23
|
+
JUNG_SET[@jung]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def jong
|
|
27
|
+
JONG_SET[@jong]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def translated_cho
|
|
31
|
+
CHO[CHO_SET[@cho]]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def translated_jung
|
|
35
|
+
JUNG[JUNG_SET[@jung]]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def translated_jong
|
|
39
|
+
JONG[JONG_SET[@jong]]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def translate
|
|
43
|
+
if ABBREVIATIONS.has_key?(assemble(@cho, @jung, DEFAULT_JONG))
|
|
44
|
+
if JONG_SET[@jong] == "ㅆ" && assemble(@cho, @jung, DEFAULT_JONG) == "파" # '팠' 예외처리
|
|
45
|
+
[self.translated_cho, self.translated_jung, self.translated_jong]
|
|
46
|
+
else
|
|
47
|
+
[ABBREVIATIONS[assemble(@cho, @jung, DEFAULT_JONG)], self.translated_jong]
|
|
48
|
+
end
|
|
49
|
+
elsif ABBREVIATIONS.has_key?(assemble(DEFAULT_CHO, @jung, @jong))
|
|
50
|
+
[self.translated_cho, ABBREVIATIONS[assemble(DEFAULT_CHO, @jung, @jong)]]
|
|
51
|
+
elsif ABBREVIATIONS.has_key?(@syllable)
|
|
52
|
+
[ABBREVIATIONS[@syllable]]
|
|
53
|
+
else
|
|
54
|
+
[self.translated_cho, self.translated_jung, self.translated_jong]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def assemble(cho, jung, jong)
|
|
61
|
+
[BASE_UNICODE + (cho * 21 * 28) + (jung * 28) + jong].pack("U")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#encoding: utf-8
|
|
2
|
+
module Braille
|
|
3
|
+
module Ko
|
|
4
|
+
class Word
|
|
5
|
+
attr_reader :word
|
|
6
|
+
|
|
7
|
+
def initialize(word)
|
|
8
|
+
@word = word
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def translate
|
|
12
|
+
if GROUPS.has_key?(@word)
|
|
13
|
+
GROUPS[@word]
|
|
14
|
+
else
|
|
15
|
+
syllables = @word.scan(/[가-힣]/)
|
|
16
|
+
syllables.map {|s| Jaso.new(s).translate }.join('')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: braille
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Junwoo Hwang
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-11-05 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.15'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
57
|
+
- capollux10@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".rspec"
|
|
64
|
+
- ".travis.yml"
|
|
65
|
+
- CODE_OF_CONDUCT.md
|
|
66
|
+
- Gemfile
|
|
67
|
+
- LICENSE.txt
|
|
68
|
+
- README.md
|
|
69
|
+
- Rakefile
|
|
70
|
+
- bin/console
|
|
71
|
+
- bin/setup
|
|
72
|
+
- braille.gemspec
|
|
73
|
+
- lib/braille.rb
|
|
74
|
+
- lib/braille/ko.rb
|
|
75
|
+
- lib/braille/ko/char.rb
|
|
76
|
+
- lib/braille/ko/constants.rb
|
|
77
|
+
- lib/braille/ko/convert.rb
|
|
78
|
+
- lib/braille/ko/jaso.rb
|
|
79
|
+
- lib/braille/ko/word.rb
|
|
80
|
+
- lib/braille/version.rb
|
|
81
|
+
homepage: https://rubygems.org/gems/braille
|
|
82
|
+
licenses:
|
|
83
|
+
- MIT
|
|
84
|
+
metadata:
|
|
85
|
+
allowed_push_host: https://rubygems.org
|
|
86
|
+
post_install_message:
|
|
87
|
+
rdoc_options: []
|
|
88
|
+
require_paths:
|
|
89
|
+
- lib
|
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
requirements: []
|
|
101
|
+
rubyforge_project:
|
|
102
|
+
rubygems_version: 2.5.2
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 4
|
|
105
|
+
summary: Braille Translator
|
|
106
|
+
test_files: []
|