tenji 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 764be0cb138fea3b2d31777f61d2f5658dc14ab99f5eeba4fbc89e7cd9414c2c
4
+ data.tar.gz: a81d4ccac660ac397a87d28950de73444206e4209d62640ab7694437091a46b0
5
+ SHA512:
6
+ metadata.gz: 9bc8c3faccc60caa1915be1f548ac447ce7c23d93758de2d6471b250342ab44050ed408f7cac6c9e784cfecfa0704bfdaff2e2609c1f3131265b0d56faea07d0
7
+ data.tar.gz: fd72ab56c085d8978620648994055b838bbb8d82a2dee7c7c2da393a6cf67b669abd807f7a182cd4939f0bd6764dcd1fe43ddbd9dac3cd219ab198de5dca00fc
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,42 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiteralsInInterpolation:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiterals:
8
+ Enabled: true
9
+ EnforcedStyle: single_quotes
10
+
11
+ Layout/LineLength:
12
+ Max: 200
13
+
14
+ Metrics/ClassLength:
15
+ Exclude:
16
+ - "lib/tenji/converter.rb"
17
+
18
+ Metrics/MethodLength:
19
+ CountComments: false
20
+ Max: 20
21
+ Exclude:
22
+ - spec/**/*
23
+ ExcludedMethods:
24
+ - convert_to_tenji
25
+
26
+ Metrics/AbcSize:
27
+ ExcludedMethods:
28
+ - convert_to_tenji
29
+ - braille_mirror
30
+
31
+ Metrics/CyclomaticComplexity:
32
+ ExcludedMethods:
33
+ - convert_to_tenji
34
+ - braille_mirror
35
+
36
+ Metrics/PerceivedComplexity:
37
+ ExcludedMethods:
38
+ - convert_to_tenji
39
+
40
+ Metrics/BlockLength:
41
+ Exclude:
42
+ - "spec/**/*"
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-08-24
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 ayu-0505
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,83 @@
1
+ # Tenji
2
+
3
+ Tenji provides tools for working with Japanese braille.
4
+ The Converter class offers methods to transform plain text
5
+ into braille representations.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```bash
12
+ gem 'tenji'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```bash
18
+ $ bundle install
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```bash
24
+ $ gem install newspaper
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ First, create an instance of the `Converter` class:
30
+
31
+ ```ruby
32
+ # Load the Tenji::Converter
33
+ converter = Tenji::Converter.new
34
+ ```
35
+
36
+ Convert hiragana to tenji(Japanese Braille)
37
+
38
+ ```ruby
39
+ puts converter.convert_to_tenji("こんにちは")
40
+ # => "⠪⠴⠇⠗⠥"
41
+ ```
42
+
43
+ Convert 凸面 to 凹面
44
+
45
+ ```ruby
46
+ puts converter.convert_to_oumen("⠪⠴⠇⠗⠥")
47
+ # => "⠬⠺⠸⠦⠕"
48
+ ```
49
+
50
+ ## Braille Conversion Reference
51
+
52
+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
53
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
54
+ | ⠀ | ⠁ | ⠂ | ⠃ | ⠄ | ⠅ | ⠆ | ⠇ | ⠈ | ⠉ | ⠊ | ⠋ | ⠌ | ⠍ | ⠎ | ⠏ |
55
+ | ⠐ | ⠑ | ⠒ | ⠓ | ⠔ | ⠕ | ⠖ | ⠗ | ⠘ | ⠙ | ⠚ | ⠛ | ⠜ | ⠝ | ⠞ | ⠟ |
56
+ | ⠠ | ⠡ | ⠢ | ⠣ | ⠤ | ⠥ | ⠦ | ⠧ | ⠨ | ⠩ | ⠪ | ⠫ | ⠬ | ⠭ | ⠮ | ⠯ |
57
+ | ⠰ | ⠱ | ⠲ | ⠳ | ⠴ | ⠵ | ⠶ | ⠷ | ⠸ | ⠹ | ⠺ | ⠻ | ⠼ | ⠽ | ⠾ | ⠿ |
58
+
59
+ ```
60
+ # '0 1 2 3 4 5 6 7 8 9 A B C D E F'
61
+ # '⠀ ⠁ ⠂ ⠃ ⠄ ⠅ ⠆ ⠇ ⠈ ⠉ ⠊ ⠋ ⠌ ⠍ ⠎ ⠏'
62
+ # '⠐ ⠑ ⠒ ⠓ ⠔ ⠕ ⠖ ⠗ ⠘ ⠙ ⠚ ⠛ ⠜ ⠝ ⠞ ⠟'
63
+ # '⠠ ⠡ ⠢ ⠣ ⠤ ⠥ ⠦ ⠧ ⠨ ⠩ ⠪ ⠫ ⠬ ⠭ ⠮ ⠯'
64
+ # '⠰ ⠱ ⠲ ⠳ ⠴ ⠵ ⠶ ⠷ ⠸ ⠹ ⠺ ⠻ ⠼ ⠽ ⠾ ⠿'
65
+ ```
66
+
67
+ ## Development
68
+
69
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
70
+
71
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
72
+
73
+ ## Contributing
74
+
75
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tenji. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tenji/blob/main/CODE_OF_CONDUCT.md).
76
+
77
+ ## License
78
+
79
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
80
+
81
+ ## Code of Conduct
82
+
83
+ Everyone interacting in the Tenji project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tenji/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Tenji provides tools for working with Japanese braille.
4
+ # The Converter class offers methods to transform plain text
5
+ # into braille representations.
6
+
7
+ module Tenji
8
+ # Converter is responsible for converting strings(hiragana and katakana) into Japanese braille.
9
+ # Example:
10
+ # converter = Tenji::Converter
11
+ # converter.convert_to_tenji("こんにちは")
12
+ # # => "⠪⠴⠇⠗⠥"
13
+ #
14
+ # If you want to convert Japanese braille (raised dots) into indented dots (mirror form),
15
+ # please use the `convert_to_oumen()` method.
16
+ # converter.convert_to_oumen("⠪⠴⠇⠗⠥")
17
+ # # => "⠬⠺⠸⠦⠕"
18
+ class Converter
19
+ def convert_to_tenji(text)
20
+ normalize_text = normalize(text)
21
+ state = :kana
22
+ result = []
23
+
24
+ normalize_text.each_char.with_index do |char, i| # rubocop:disable Metrics/BlockLength
25
+ prev_char = i.positive? ? normalize_text[i - 1] : nil
26
+ next_char = i < normalize_text.size - 1 ? normalize_text[i + 1] : nil
27
+
28
+ if char == "\n"
29
+ result << char
30
+ next
31
+ end
32
+
33
+ case state
34
+ when :kana
35
+ if char.match?(/[0-9]/)
36
+ # 数字がはじまる合図の数符を入れて、number状態に移行
37
+ result << Tenji::Mapping::SUFU
38
+ state = :number
39
+ redo
40
+ elsif char.match?(/[a-zA-Z]/)
41
+ # アルファベットで書かれた文字の前に外字符を入れて、alphabet状態に移行
42
+ result << Tenji::Mapping::GAIJIFU
43
+ state = :alphabet
44
+ redo
45
+ else
46
+ next if convert_kana_to_braille(char, next_char).nil?
47
+
48
+ # 数字の後があ行・ら行(りゃ,りゅ,りょ除く)の場合は繋ぎ符を入れる
49
+ if prev_char&.match(/[0-90-9]/) && %w[ア イ ウ エ オ ラ リ ル レ ロ].include?(char) && !%w[ャ ュ ョ].include?(next_char) # rubocop:disable Style/IfUnlessModifier
50
+ result << Tenji::Mapping::DAI1_TUNAGIFU
51
+ end
52
+ result << convert_kana_to_braille(char, next_char)
53
+ end
54
+
55
+ when :number
56
+ if Tenji::Mapping::KANA.include?(char)
57
+ state = :kana
58
+ redo
59
+ end
60
+ if char.match?(/[a-zA-Z]/)
61
+ state = :alphabet
62
+ redo
63
+ end
64
+ result << convert_num_to_braille(char)
65
+
66
+ when :alphabet
67
+ if Tenji::Mapping::KANA.include?(char)
68
+ state = :kana
69
+ redo
70
+ end
71
+ if char == /[0-9]/
72
+ state = :number
73
+ redo
74
+ end
75
+
76
+ # 大文字の前に大文字符を入れる。その後に続く単語が全て大文字ならば二つ大文字符を入れる
77
+ result << Tenji::Mapping::OOMOJIFU if !prev_char&.match?(/[A-Z]/) && char.match?(/[A-Z]/) && !next_char&.match?(/[A-Z]/)
78
+ result << Tenji::Mapping::OOMOJIFU * 2 if !prev_char&.match?(/[A-Z]/) && char.match?(/[A-Z]/) && next_char&.match?(/[A-Z]/)
79
+ result << convert_alphabet_to_braille(char)
80
+ end
81
+ end
82
+ result.join
83
+ end
84
+
85
+ def convert_to_oumen(raised_braille)
86
+ raised_braille.chars.map { |char| braille_mirror(char) }.reverse.join
87
+ end
88
+
89
+ private
90
+
91
+ def normalize(text)
92
+ text.each_char.map { |char| to_hankaku(to_kana(char)) }.join
93
+ end
94
+
95
+ def to_kana(char)
96
+ char&.tr('ぁ-んゔ', 'ァ-ンヴ')
97
+ end
98
+
99
+ def to_hankaku(char)
100
+ char&.tr('0-9.,?!', '0-9.,?!')
101
+ end
102
+
103
+ def convert_kana_to_braille(char, next_char)
104
+ return if %w[ャ ュ ョ].include?(char) || %w[ァ ィ ゥ ェ ォ ュ].include?(char)
105
+
106
+ is_yoon = %w[キ シ チ ニ ヒ ミ リ ギ ジ ヂ ビ ピ].include?(char) && %w[ャ ュ ョ].include?(next_char)
107
+ is_tokusyuon = %w[ァ ィ ゥ ェ ォ ュ ョ].include?(next_char) && Tenji::Mapping::TOKUSYUON[next_char].include?(char)
108
+ if is_yoon || is_tokusyuon
109
+ one_kana = char << next_char
110
+ Tenji::Mapping::KANA[one_kana]
111
+ else
112
+ Tenji::Mapping::KANA[char]
113
+ end
114
+ end
115
+
116
+ def convert_num_to_braille(char)
117
+ Tenji::Mapping::NUNBER[char]
118
+ end
119
+
120
+ def convert_alphabet_to_braille(char)
121
+ lowercase = char.downcase
122
+ Tenji::Mapping::ALPHABET[lowercase]
123
+ end
124
+
125
+ def braille_mirror(char)
126
+ code_point = char.ord
127
+ return char unless (0x2800..0x283F).cover?(code_point)
128
+
129
+ dots = code_point - 0x2800
130
+ mirrored = 0
131
+ mirrored |= 0x08 if dots & 0x01 != 0 # 1→4
132
+ mirrored |= 0x10 if dots & 0x02 != 0 # 2→5
133
+ mirrored |= 0x20 if dots & 0x04 != 0 # 3→6
134
+ mirrored |= 0x01 if dots & 0x08 != 0 # 4→1
135
+ mirrored |= 0x02 if dots & 0x10 != 0 # 5→2
136
+ mirrored |= 0x04 if dots & 0x20 != 0 # 6→3
137
+
138
+ (0x2800 + mirrored).chr(Encoding::UTF_8)
139
+ end
140
+ end
141
+ end
142
+
143
+ # TODO: リリース前に削除すること
144
+ # '0 1 2 3 4 5 6 7 8 9 A B C D E F'
145
+ # '⠀ ⠁ ⠂ ⠃ ⠄ ⠅ ⠆ ⠇ ⠈ ⠉ ⠊ ⠋ ⠌ ⠍ ⠎ ⠏'
146
+ # '⠐ ⠑ ⠒ ⠓ ⠔ ⠕ ⠖ ⠗ ⠘ ⠙ ⠚ ⠛ ⠜ ⠝ ⠞ ⠟'
147
+ # '⠠ ⠡ ⠢ ⠣ ⠤ ⠥ ⠦ ⠧ ⠨ ⠩ ⠪ ⠫ ⠬ ⠭ ⠮ ⠯'
148
+ # '⠰ ⠱ ⠲ ⠳ ⠴ ⠵ ⠶ ⠷ ⠸ ⠹ ⠺ ⠻ ⠼ ⠽ ⠾ ⠿'
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tenji
4
+ module Mapping
5
+ KANA = {
6
+ # 清音
7
+ 'ア' => '⠁', 'イ' => '⠃', 'ウ' => '⠉', 'エ' => '⠋', 'オ' => '⠊',
8
+ 'カ' => '⠡', 'キ' => '⠣', 'ク' => '⠩', 'ケ' => '⠫', 'コ' => '⠪',
9
+ 'サ' => '⠱', 'シ' => '⠳', 'ス' => '⠹', 'セ' => '⠻', 'ソ' => '⠺',
10
+ 'タ' => '⠕', 'チ' => '⠗', 'ツ' => '⠝', 'テ' => '⠟', 'ト' => '⠞',
11
+ 'ナ' => '⠅', 'ニ' => '⠇', 'ヌ' => '⠍', 'ネ' => '⠏', 'ノ' => '⠎',
12
+ 'ハ' => '⠥', 'ヒ' => '⠧', 'フ' => '⠭', 'ヘ' => '⠯', 'ホ' => '⠮',
13
+ 'マ' => '⠵', 'ミ' => '⠷', 'ム' => '⠽', 'メ' => '⠿', 'モ' => '⠾',
14
+ 'ヤ' => '⠌', 'ユ' => '⠬', 'ヨ' => '⠜',
15
+ 'ラ' => '⠑', 'リ' => '⠓', 'ル' => '⠙', 'レ' => '⠛', 'ロ' => '⠚',
16
+ 'ワ' => '⠄', 'ヰ' => '⠆', 'ヱ' => '⠖', 'ヲ' => '⠔',
17
+ 'ン' => '⠴', 'ッ' => '⠂', 'ー' => '⠒',
18
+
19
+ # 濁音
20
+ 'ガ' => '⠐⠡', 'ギ' => '⠐⠣', 'グ' => '⠐⠩', 'ゲ' => '⠐⠫', 'ゴ' => '⠐⠪',
21
+ 'ザ' => '⠐⠱', 'ジ' => '⠐⠳', 'ズ' => '⠐⠹', 'ゼ' => '⠐⠻', 'ゾ' => '⠐⠺',
22
+ 'ダ' => '⠐⠕', 'ヂ' => '⠐⠗', 'ヅ' => '⠐⠝', 'デ' => '⠐⠟', 'ド' => '⠐⠞',
23
+ 'バ' => '⠐⠥', 'ビ' => '⠐⠧', 'ブ' => '⠐⠭', 'ベ' => '⠐⠯', 'ボ' => '⠐⠮',
24
+
25
+ # 半濁音
26
+ 'パ' => '⠠⠥', 'ピ' => '⠠⠧', 'プ' => '⠠⠭', 'ペ' => '⠠⠯', 'ポ' => '⠠⠮', 'ヴ' => '⠐⠉',
27
+
28
+ # 拗音、拗濁音、拗半濁音
29
+ 'キャ' => '⠈⠡', 'キュ' => '⠈⠩', 'キョ' => '⠈⠪',
30
+ 'シャ' => '⠈⠱', 'シュ' => '⠈⠹', 'ショ' => '⠈⠺',
31
+ 'チャ' => '⠈⠕', 'チュ' => '⠈⠝', 'チョ' => '⠈⠞',
32
+ 'ニャ' => '⠈⠅', 'ニュ' => '⠈⠍', 'ニョ' => '⠈⠎',
33
+ 'ヒャ' => '⠈⠥', 'ヒュ' => '⠈⠭', 'ヒョ' => '⠈⠮',
34
+ 'ミャ' => '⠈⠵', 'ミュ' => '⠈⠽', 'ミョ' => '⠈⠾',
35
+ 'リャ' => '⠈⠑', 'リュ' => '⠈⠙', 'リョ' => '⠈⠚',
36
+ 'ギャ' => '⠘⠡', 'ギュ' => '⠘⠩', 'ギョ' => '⠘⠪',
37
+ 'ジャ' => '⠘⠱', 'ジュ' => '⠘⠹', 'ジョ' => '⠘⠺',
38
+ 'ヂャ' => '⠘⠕', 'ヂュ' => '⠘⠝', 'ヂョ' => '⠘⠞',
39
+ 'ビャ' => '⠘⠥', 'ビュ' => '⠘⠭', 'ビョ' => '⠘⠮',
40
+ 'ピャ' => '⠨⠥', 'ピュ' => '⠨⠭', 'ピョ' => '⠨⠮',
41
+
42
+ # 特殊音
43
+ 'イェ' => '⠈⠋', 'キェ' => '⠈⠫', 'シェ' => '⠈⠻', 'ジェ' => '⠘⠻', 'チェ' => '⠈⠟', 'ニェ' => '⠈⠏', 'ヒェ' => '⠈⠯',
44
+ 'ウィ' => '⠢⠃', 'ウェ' => '⠢⠋', 'ウォ' => '⠢⠊',
45
+ 'クァ' => '⠢⠡', 'クィ' => '⠢⠣', 'クェ' => '⠢⠫', 'クォ' => '⠢⠪',
46
+ 'グァ' => '⠲⠡', 'グィ' => '⠲⠣', 'グェ' => '⠲⠫', 'グォ' => '⠲⠪',
47
+ 'ツァ' => '⠢⠕', 'ツィ' => '⠢⠗', 'ツェ' => '⠢⠟', 'ツォ' => '⠢⠞',
48
+ 'ファ' => '⠢⠥', 'フィ' => '⠢⠧', 'フェ' => '⠢⠯', 'フォ' => '⠢⠮',
49
+ 'ヴァ' => '⠲⠥', 'ヴィ' => '⠲⠧', 'ヴェ' => '⠲⠯', 'ヴォ' => '⠲⠮',
50
+ 'スィ' => '⠈⠳', 'ズィ' => '⠘⠳', 'ティ' => '⠈⠗', 'ディ' => '⠘⠗',
51
+ 'トゥ' => '⠢⠝', 'ドゥ' => '⠲⠝',
52
+ 'テュ' => '⠨⠝', 'デュ' => '⠸⠝', 'フュ' => '⠨⠬', 'ヴュ' => '⠸⠬', 'フョ' => '⠨⠜', 'ヴョ' => '⠸⠜',
53
+
54
+ # 空白、ブランク(スペースではなく、点字における無点の文字コード U+2800)
55
+ ' ' => '⠀', ' ' => '⠀',
56
+
57
+ # 句点、読点、疑問符、感嘆符
58
+ '。' => '⠲', '、' => '⠰', '?' => '⠢', '!' => '⠖'
59
+ }.freeze
60
+
61
+ TOKUSYUON = {
62
+ 'ァ' => %w[ク グ ツ フ ヴ],
63
+ 'ィ' => %w[ウ ク グ ツ フ ブ ス ズ テ デ ヴ],
64
+ 'ゥ' => %w[ト ド],
65
+ 'ェ' => %w[イ キ シ ジ チ ニ ヒ ウ ク グ ツ フ ヴ],
66
+ 'ォ' => %w[ウ ク グ ツ フ ヴ],
67
+ 'ュ' => %w[テ デ フ ヴ],
68
+ 'ョ' => %w[フ ヴ]
69
+ }.freeze
70
+
71
+ NUNBER = {
72
+ '1' => '⠁', '2' => '⠃', '3' => '⠉', '4' => '⠙', '5' => '⠑',
73
+ '6' => '⠋', '7' => '⠛', '8' => '⠓', '9' => '⠊', '0' => '⠚',
74
+
75
+ # 小数点、位取り点、アポストロフィー
76
+ '.' => '⠂', ',' => '⠄', '’' => '⠄', '\'' => '⠄'
77
+ }.freeze
78
+ SUFU = '⠼'
79
+ DAI1_TUNAGIFU = '⠤'
80
+
81
+ ALPHABET = {
82
+ 'a' => '⠁', 'b' => '⠃', 'c' => '⠉', 'd' => '⠙', 'e' => '⠑',
83
+ 'f' => '⠋', 'g' => '⠛', 'h' => '⠓', 'i' => '⠊', 'j' => '⠚',
84
+ 'k' => '⠅', 'l' => '⠇', 'm' => '⠍', 'n' => '⠝', 'o' => '⠕',
85
+ 'p' => '⠏', 'q' => '⠟', 'r' => '⠗', 's' => '⠎', 't' => '⠞',
86
+ 'u' => '⠥', 'v' => '⠧', 'w' => '⠺', 'x' => '⠭', 'y' => '⠽', 'z' => '⠵'
87
+ }.freeze
88
+
89
+ GAIJIFU = '⠰'
90
+ OOMOJIFU = '⠠'
91
+ end
92
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tenji
4
+ VERSION = '0.1.0'
5
+ end
data/lib/tenji.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'tenji/version'
4
+ require_relative 'tenji/mapping'
5
+ require_relative 'tenji/converter'
6
+
7
+ module Tenji
8
+ class Error < StandardError; end
9
+
10
+ class Braille
11
+ end
12
+ end
data/sig/tenji.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Tenji
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tenji
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ayu-0505
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Tenji provides a straightforward way to convert Japanese Hiragana or
13
+ Katakana text into Japanese Braille. It is designed to be lightweight and easy to
14
+ use in Ruby applications.
15
+ email:
16
+ - amehuri.boshi.sh@icloud.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - CHANGELOG.md
24
+ - CODE_OF_CONDUCT.md
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - lib/tenji.rb
29
+ - lib/tenji/converter.rb
30
+ - lib/tenji/mapping.rb
31
+ - lib/tenji/version.rb
32
+ - sig/tenji.rbs
33
+ homepage: https://github.com/ayu-0505/tenji
34
+ licenses:
35
+ - MIT
36
+ metadata:
37
+ homepage_uri: https://github.com/ayu-0505/tenji
38
+ source_code_uri: https://github.com/ayu-0505/tenji
39
+ changelog_uri: https://github.com/ayu-0505/tenji/CHANGELOG.md
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.6.7
55
+ specification_version: 4
56
+ summary: Tenji is a simple Ruby gem that converts Japanese Hiragana or Katakana into
57
+ Japanese Braille.
58
+ test_files: []