lyrics_japanese 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d1583ce84cb6867fc94a0ebc3123cf019d0a842aa487f831e637e23098f6e358
4
+ data.tar.gz: 6cb3bd9953ad8b7966aa6f458281ea6d0654c80a8a143f9112075b2ab0dde400
5
+ SHA512:
6
+ metadata.gz: 44517440ef38f09b4ee311b5da7b02c1a2205680b083904c96cb6a9303f1217424fd1ec2d30d0a7a6e0ba8329927f8cb2eaffe57d0e3612a5b1b85629e1e0b97
7
+ data.tar.gz: 621da5266146e08a266a17496f6685a448da3efa000dd792421d260987d4707d4f5b72d7358135a5b7a394e49367ecdc2f8ed88c976efd76050f47d4f2bcb078
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,34 @@
1
+ # ** Default values of all configuration are written in**
2
+ # https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml
3
+ #
4
+ # Detail examples of each configuration are
5
+ # https://rubocop.readthedocs.io/en/latest/cops_layout
6
+ #
7
+ # General guide-line is
8
+ # https://github.com/rubocop-hq/ruby-style-guide
9
+
10
+ require:
11
+ - rubocop-performance
12
+ - rubocop-rspec
13
+
14
+ AllCops:
15
+ TargetRubyVersion: 2.5
16
+ NewCops: enable
17
+
18
+ Layout/EndAlignment:
19
+ Enabled: true
20
+ AutoCorrect: true
21
+
22
+ Layout/LineLength:
23
+ Enabled: true
24
+ AutoCorrect: false
25
+ Max: 120
26
+
27
+ Metrics/BlockLength:
28
+ Enabled: true
29
+ Max: 30
30
+ ExcludedMethods: ['describe', 'context']
31
+
32
+ Metrics/MethodLength:
33
+ Enabled: true
34
+ Max: 30
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## [v1.0.0](https://github.com/shinyaohtani/lyrics_japanese/tree/v1.0.0) (2020-05-15)
4
+
5
+ [Full Changelog](https://github.com/shinyaohtani/lyrics_japanese/compare/95359c051a51f5562156e52fdcb80aeb0aae6b93...v1.0.0)
6
+
7
+ - First release
8
+
9
+
10
+
11
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
@@ -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 @shinyaohtani. 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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in lyrics_japanese.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,142 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lyrics_japanese (1.0.0)
5
+ natto (>= 1.2.0)
6
+ yaml (>= 0.1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.0.3)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2, >= 2.2.2)
17
+ addressable (2.7.0)
18
+ public_suffix (>= 2.0.2, < 5.0)
19
+ ast (2.4.0)
20
+ async (1.24.2)
21
+ console (~> 1.0)
22
+ nio4r (~> 2.3)
23
+ timers (~> 4.1)
24
+ async-http (0.51.2)
25
+ async (~> 1.23)
26
+ async-io (~> 1.28)
27
+ async-pool (~> 0.2)
28
+ protocol-http (~> 0.18.0)
29
+ protocol-http1 (~> 0.12.0)
30
+ protocol-http2 (~> 0.13.0)
31
+ async-http-faraday (0.9.0)
32
+ async-http (~> 0.42)
33
+ faraday
34
+ async-io (1.28.0)
35
+ async (~> 1.14)
36
+ async-pool (0.2.0)
37
+ async (~> 1.8)
38
+ byebug (11.1.3)
39
+ coderay (1.1.2)
40
+ concurrent-ruby (1.1.6)
41
+ console (1.8.2)
42
+ diff-lcs (1.3)
43
+ faraday (1.0.1)
44
+ multipart-post (>= 1.2, < 3)
45
+ faraday-http-cache (2.2.0)
46
+ faraday (>= 0.8)
47
+ ffi (1.12.2)
48
+ github_changelog_generator (1.15.2)
49
+ activesupport
50
+ async-http-faraday
51
+ faraday-http-cache
52
+ multi_json
53
+ octokit (~> 4.6)
54
+ rainbow (>= 2.2.1)
55
+ rake (>= 10.0)
56
+ retriable (~> 3.0)
57
+ i18n (1.8.2)
58
+ concurrent-ruby (~> 1.0)
59
+ method_source (1.0.0)
60
+ minitest (5.14.0)
61
+ multi_json (1.14.1)
62
+ multipart-post (2.1.1)
63
+ natto (1.2.0)
64
+ ffi (>= 1.9.0)
65
+ nio4r (2.5.2)
66
+ octokit (4.18.0)
67
+ faraday (>= 0.9)
68
+ sawyer (~> 0.8.0, >= 0.5.3)
69
+ parallel (1.19.1)
70
+ parser (2.7.1.2)
71
+ ast (~> 2.4.0)
72
+ protocol-hpack (1.4.2)
73
+ protocol-http (0.18.0)
74
+ protocol-http1 (0.12.0)
75
+ protocol-http (~> 0.18)
76
+ protocol-http2 (0.13.3)
77
+ protocol-hpack (~> 1.4)
78
+ protocol-http (~> 0.18)
79
+ pry (0.13.1)
80
+ coderay (~> 1.1)
81
+ method_source (~> 1.0)
82
+ pry-byebug (3.9.0)
83
+ byebug (~> 11.0)
84
+ pry (~> 0.13.0)
85
+ public_suffix (4.0.5)
86
+ rainbow (3.0.0)
87
+ rake (12.3.3)
88
+ retriable (3.1.2)
89
+ rexml (3.2.4)
90
+ rspec (3.9.0)
91
+ rspec-core (~> 3.9.0)
92
+ rspec-expectations (~> 3.9.0)
93
+ rspec-mocks (~> 3.9.0)
94
+ rspec-core (3.9.2)
95
+ rspec-support (~> 3.9.3)
96
+ rspec-expectations (3.9.2)
97
+ diff-lcs (>= 1.2.0, < 2.0)
98
+ rspec-support (~> 3.9.0)
99
+ rspec-mocks (3.9.1)
100
+ diff-lcs (>= 1.2.0, < 2.0)
101
+ rspec-support (~> 3.9.0)
102
+ rspec-support (3.9.3)
103
+ rubocop (0.83.0)
104
+ parallel (~> 1.10)
105
+ parser (>= 2.7.0.1)
106
+ rainbow (>= 2.2.2, < 4.0)
107
+ rexml
108
+ ruby-progressbar (~> 1.7)
109
+ unicode-display_width (>= 1.4.0, < 2.0)
110
+ rubocop-performance (1.5.2)
111
+ rubocop (>= 0.71.0)
112
+ rubocop-rspec (1.39.0)
113
+ rubocop (>= 0.68.1)
114
+ ruby-progressbar (1.10.1)
115
+ sawyer (0.8.2)
116
+ addressable (>= 2.3.5)
117
+ faraday (> 0.8, < 2.0)
118
+ thread_safe (0.3.6)
119
+ timers (4.3.0)
120
+ tzinfo (1.2.7)
121
+ thread_safe (~> 0.1)
122
+ unicode-display_width (1.7.0)
123
+ yaml (0.1.0)
124
+ zeitwerk (2.3.0)
125
+
126
+ PLATFORMS
127
+ ruby
128
+
129
+ DEPENDENCIES
130
+ bundler (~> 2.0)
131
+ github_changelog_generator (>= 1.15.0)
132
+ lyrics_japanese!
133
+ pry (>= 0.12.2)
134
+ pry-byebug (>= 3.9.0)
135
+ rake (~> 12.0)
136
+ rspec (~> 3.0)
137
+ rubocop (>= 0.80.1)
138
+ rubocop-performance (>= 1.5.2)
139
+ rubocop-rspec (>= 1.38.1)
140
+
141
+ BUNDLED WITH
142
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Shinya Ohtani
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,55 @@
1
+ # LyricsJapanese
2
+
3
+ This is a helper script for entering Japanese lyrics into music scores.
4
+ Convert natural Japanese sentences into word-spacing notes
5
+ for musical notes.
6
+ example:
7
+ ```
8
+ "恋しちゃおう 夢見ちゃおう 恋のダンスサイト" is converted to
9
+ "こ い し ちゃ お う ゆ め み ちゃ お う こ い の ダ ン ス サ イ ト"
10
+ ```
11
+ This format can be directly put into the lyrics window
12
+ of DAW software "Digital Performer" by Mark of the unicorn.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'lyrics_japanese'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle install
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install lyrics_japanese
29
+
30
+ ## Usage
31
+
32
+ TODO: Write usage instructions here
33
+
34
+ ## Development
35
+
36
+ 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.
37
+
38
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome!
43
+ 1. Fork it ( https://github.com/shinyaohtani/lyrics_japanese )
44
+ 1. Create your feature branch (git checkout -b my-new-feature)
45
+ 1. Commit your changes (git commit -am 'Add some feature')
46
+ 1. Push to the branch (git push origin my-new-feature)
47
+ 1. Create a new Pull Request
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+
53
+ ## Code of Conduct
54
+
55
+ Everyone interacting in the MasterDelivery project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/shinyaohtani/lyrics_japanese/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,61 @@
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
+ task default: :spec
9
+ require 'github_changelog_generator/task'
10
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
11
+ config.base = 'CHANGELOG.md'
12
+ config.future_release = "v#{LyricsJapanese::VERSION}"
13
+ config.project = 'lyrics_japanese'
14
+ config.user = 'shinyaohtani'
15
+ config.verbose = false
16
+
17
+ # other changelog options (values are default)
18
+ #
19
+ # -- labels
20
+ #:config.breaking_labels = ["backwards-incompatible", "Backwards incompatible", "breaking"]
21
+ #:config.bug_labels = ["bug", "Bug", "Type: Bug"]
22
+ #:config.deprecated_labels = ["deprecated", "Deprecated", "Type: Deprecated"]
23
+ #:config.enhancement_labels = ["enhancement", "Enhancement", "Type: Enhancement"]
24
+ #:config.exclude_labels = ['duplicate', 'question', 'invalid', 'wontfix',
25
+ #: 'Duplicate', 'Question', 'Invalid', 'Wontfix',
26
+ #: 'Meta: Exclude From Changelog']
27
+ #:config.removed_labels = ["removed", "Removed", "Type: Removed"]
28
+ #:config.security_labels = ["security", "Security", "Type: Security"]
29
+ #:config.summary_labels = ["Release summary", "release-summary", "Summary", "summary"]
30
+ # -- prefix
31
+ #:config.breaking_prefix = "**Breaking changes:**"
32
+ #:config.bug_prefix = "**Fixed bugs:**"
33
+ #:config.deprecated_prefix = "**Deprecated:**"
34
+ #:config.enhancement_prefix = "**Implemented enhancements:**"
35
+ #:config.header = "# Changelog"
36
+ #:config.issue_prefix = "**Closed issues:**"
37
+ #:config.merge_prefix = "**Merged pull requests:**"
38
+ #:config.removed_prefix = "**Removed:**"
39
+ #:config.security_prefix = "**Security fixes:**"
40
+ #:config.summary_prefix = ""
41
+ # -- others
42
+ #:config.add_issues_wo_labels = true
43
+ #:config.add_pr_wo_labels = true
44
+ #:config.add_sections = {}
45
+ #:config.author = true
46
+ #:config.compare_link = true
47
+ #:config.configure_sections = {}
48
+ #:config.date_format = "%Y-%m-%d"
49
+ #:config.filter_issues_by_milestone = true
50
+ #:config.http_cache = true
51
+ #:config.issue_line_labels = []
52
+ #:config.issues = true
53
+ #:config.max_issues = nil
54
+ #:config.output = "CHANGELOG.md"
55
+ #:config.pulls = true
56
+ #:config.require = []
57
+ #:config.simple_list = false
58
+ #:config.ssl_ca_file = nil
59
+ #:config.unreleased = true
60
+ #:config.unreleased_label = "Unreleased"
61
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'lyrics_japanese'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ require 'pry'
12
+ Pry.start
13
+
14
+ # require 'irb'
15
+ # IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'cli_lyrics_japanese'
5
+
6
+ cli_lj = LyricsJapanese::CliLyricsJapanese.new
7
+ cli_lj.parse_options
8
+ cli_lj.run
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # converter module from path to url
4
+ module LyricsJapanese
5
+ require 'lyrics_japanese'
6
+ require 'optparse'
7
+ require 'pathname'
8
+
9
+ # command line wrapper
10
+ class CliLyricsJapanese
11
+ attr_accessor :params
12
+
13
+ def initialize
14
+ @params = {}
15
+ end
16
+
17
+ def parse_options
18
+ OptionParser.new do |opts|
19
+ opts = define_options(opts)
20
+ opts.parse!(ARGV, into: @params)
21
+ end
22
+ end
23
+
24
+ def run
25
+ text = []
26
+ if !ARGV.empty?
27
+ File.open(ARGV[0]) do |file|
28
+ text = file.each_line.to_a
29
+ end
30
+ else
31
+ text = STDIN.each_line.to_a
32
+ end
33
+ lines = LyricsJapanese.new.to_lyricruby(text, ' ')
34
+ puts lines.join("\n")
35
+ end
36
+
37
+ def define_options(opts)
38
+ opts.version = VERSION
39
+ opts.on_tail('-h', '--help', 'Show this message') do
40
+ puts opts
41
+ exit
42
+ end
43
+ opts.on_tail('-V', '--version', 'Show version') do
44
+ puts opts.ver
45
+ exit
46
+ end
47
+ opts.banner = <<~BANNER
48
+
49
+ #{opts.ver}
50
+ #{DESCRIPTION}
51
+ Usage: #{opts.program_name}
52
+ BANNER
53
+ opts
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LyricsJapanese
4
+ VERSION = '1.0.0'
5
+ DESCRIPTION = <<~DESC
6
+ This is a helper script for entering Japanese lyrics into
7
+ music scores. lyrics_japanes converts natural Japanese sentences
8
+ into word-spacing notes for musical notes.
9
+ example:
10
+ "恋しちゃおう 夢見ちゃおう 恋のダンスサイト" is converted to
11
+ "こ い し ちゃ お う ゆ め み ちゃ お う こ い の ダ ン ス サ イ ト"
12
+ This format can be directly put into the lyrics window
13
+ of DAW software "Digital Performer" by Mark of the unicorn.
14
+ DESC
15
+ REPOSITORY_URL = 'https://github.com/shinyaohtani/lyrics_japanese'
16
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lyrics_japanese/version'
4
+
5
+ # rubocop:disable Style/AsciiComments
6
+
7
+ # 文字列クラスにちょっとメソッド追加
8
+ class String
9
+ def to_hiragana
10
+ tr('ァ-ン', 'ぁ-ん')
11
+ end
12
+
13
+ def katakana?
14
+ !(self =~ /\p{Katakana}|[ー-]/).nil?
15
+ end
16
+
17
+ # 「うたえー」を「う た え ー」に変換。
18
+ def separate_kana(delim = ' ')
19
+ tmp = +''
20
+ each_char do |ch|
21
+ tmp << ch
22
+ tmp << delim unless ch.ascii_only?
23
+ end
24
+ tmp.chomp(delim)
25
+ end
26
+
27
+ # 「き ゃ き ゅ き ょ」を「きゃ きゅ きょ」に変換。「っ」歌うから残す
28
+ def join_phoneme(delim = ' ')
29
+ gsub(/#{delim}([ぁぃぅぇぉゃゅょァィゥェォャュョー-])/, '\1')
30
+ end
31
+ end
32
+
33
+ # 日本語表記を音符の下に書く表記に変換
34
+ module LyricsJapanese
35
+ require 'natto'
36
+ require 'yaml'
37
+
38
+ # 日本語表記を音符の下に書く表記に変換
39
+ class LyricsJapanese
40
+ @@natto = Natto::MeCab.new # rubocop:disable Style/ClassVars
41
+
42
+ # メインメソッド
43
+ # mecabを使って読みがなに変換。
44
+ # 読みがなにしても文字数が変化しないなら漢字を使う
45
+ # カタカナ語とアルファベットはそのまま出力。
46
+ #
47
+ def to_lyricruby(text, delim = ' ') # rubocop:disable Metrics/AbcSize
48
+ lines = []
49
+ text.each do |sentence|
50
+ words = []
51
+ @@natto.parse(sentence) do |n|
52
+ unless n.is_eos?
53
+ # puts "#{n.surface}\t#{n.feature}"
54
+ rubi = n.surface
55
+ if n.feature.split(',').length > 8 && !n.surface.katakana?
56
+ w7 = n.feature.split(',')[7]
57
+ rubi = w7.to_hiragana if w7.length != n.surface.length
58
+ end
59
+ words << rubi.separate_kana(delim).join_phoneme
60
+ end
61
+ end
62
+ lines << words.join(delim)
63
+ end
64
+ lines
65
+ end
66
+ end
67
+ end
68
+ # rubocop:enable Style/AsciiComments
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/lyrics_japanese/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'lyrics_japanese'
7
+ spec.version = LyricsJapanese::VERSION
8
+ spec.authors = ['Shinya Ohtani (shinyaohtani@github)']
9
+ spec.email = ['shinya_ohtani@yahoo.co.jp']
10
+
11
+ spec.summary = 'Convert natural Japanese sentences into word-spacing notes for musical notes.'
12
+ spec.description = LyricsJapanese::DESCRIPTION
13
+ spec.homepage = LyricsJapanese::REPOSITORY_URL + '/tree/master/README.md'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = LyricsJapanese::REPOSITORY_URL
21
+ spec.metadata['changelog_uri'] = LyricsJapanese::REPOSITORY_URL + '/tree/master/CHANGELOG.md'
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| 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_runtime_dependency 'natto', '>= 1.2.0'
33
+ spec.add_runtime_dependency 'yaml', '>= 0.1.0'
34
+
35
+ spec.add_development_dependency 'bundler', '~> 2.0'
36
+ spec.add_development_dependency 'github_changelog_generator', '>= 1.15.0'
37
+ spec.add_development_dependency 'pry', '>= 0.12.2'
38
+ spec.add_development_dependency 'pry-byebug', '>= 3.9.0'
39
+ spec.add_development_dependency 'rake', '>= 12.3.3'
40
+ spec.add_development_dependency 'rspec', '>= 3.9.0'
41
+ spec.add_development_dependency 'rubocop', '>= 0.80.1'
42
+ spec.add_development_dependency 'rubocop-performance', '>= 1.5.2'
43
+ spec.add_development_dependency 'rubocop-rspec', '>= 1.38.1'
44
+ end
metadata ADDED
@@ -0,0 +1,228 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lyrics_japanese
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Shinya Ohtani (shinyaohtani@github)
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: natto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: yaml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: github_changelog_generator
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.15.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.15.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.12.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.12.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 3.9.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.9.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 12.3.3
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 12.3.3
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.9.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 3.9.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 0.80.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 0.80.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-performance
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 1.5.2
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 1.5.2
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 1.38.1
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 1.38.1
167
+ description: |
168
+ This is a helper script for entering Japanese lyrics into
169
+ music scores. lyrics_japanes converts natural Japanese sentences
170
+ into word-spacing notes for musical notes.
171
+ example:
172
+ "恋しちゃおう 夢見ちゃおう 恋のダンスサイト" is converted to
173
+ "こ い し ちゃ お う ゆ め み ちゃ お う こ い の ダ ン ス サ イ ト"
174
+ This format can be directly put into the lyrics window
175
+ of DAW software "Digital Performer" by Mark of the unicorn.
176
+ email:
177
+ - shinya_ohtani@yahoo.co.jp
178
+ executables:
179
+ - lyrics_japanese
180
+ extensions: []
181
+ extra_rdoc_files: []
182
+ files:
183
+ - ".gitignore"
184
+ - ".rspec"
185
+ - ".rubocop.yml"
186
+ - ".travis.yml"
187
+ - CHANGELOG.md
188
+ - CODE_OF_CONDUCT.md
189
+ - Gemfile
190
+ - Gemfile.lock
191
+ - LICENSE.txt
192
+ - README.md
193
+ - Rakefile
194
+ - bin/console
195
+ - bin/setup
196
+ - exe/lyrics_japanese
197
+ - lib/cli_lyrics_japanese.rb
198
+ - lib/lyrics_japanese.rb
199
+ - lib/lyrics_japanese/version.rb
200
+ - lyrics_japanese.gemspec
201
+ homepage: https://github.com/shinyaohtani/lyrics_japanese/tree/master/README.md
202
+ licenses:
203
+ - MIT
204
+ metadata:
205
+ allowed_push_host: https://rubygems.org
206
+ homepage_uri: https://github.com/shinyaohtani/lyrics_japanese/tree/master/README.md
207
+ source_code_uri: https://github.com/shinyaohtani/lyrics_japanese
208
+ changelog_uri: https://github.com/shinyaohtani/lyrics_japanese/tree/master/CHANGELOG.md
209
+ post_install_message:
210
+ rdoc_options: []
211
+ require_paths:
212
+ - lib
213
+ required_ruby_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ version: 2.3.0
218
+ required_rubygems_version: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ requirements: []
224
+ rubygems_version: 3.1.2
225
+ signing_key:
226
+ specification_version: 4
227
+ summary: Convert natural Japanese sentences into word-spacing notes for musical notes.
228
+ test_files: []