utanone 0.1.2 → 0.1.3
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/utanone/uta.rb +18 -8
- data/lib/utanone/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6897c3a5635555cc9ce0bba7bf439d9345979a3d64740a78f71060edf1c0f0d7
|
4
|
+
data.tar.gz: 8115d2a37a1170baabd0e6085695b6b7be904f1f71d4891d47c8eba138330b27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f3d0ac53578864d8aebc66a864d791722db00ae59b2dcb6833cbfa0e50c311bbe9acd32f9564dd64b0e680ae28cf5c7f3b70456ec02c5b75d3ac07e479af2f3
|
7
|
+
data.tar.gz: aae866c6c37f280c5c4b13a6a25f037eeb0e6bf4f6ee09e7e178965cb15fc352331288dce8717af07474fce028ddbf5c95eda6b3253edff4a5623be43e68c9dd
|
data/CHANGELOG.md
CHANGED
data/lib/utanone/uta.rb
CHANGED
@@ -8,6 +8,7 @@ module Utanone
|
|
8
8
|
|
9
9
|
EXCLUDING_COUNTING_RUBY_BY_TANKA = /ァ|ィ|ォ|ャ|ュ|ョ/
|
10
10
|
EXCLUDING_COUNTING_LEXICAL_CATEGORIES = %w[記号].freeze
|
11
|
+
HIRAGANA_AND_KATAKANA = /\A[ぁ-んァ-ヶー-]+\z/
|
11
12
|
|
12
13
|
def initialize(str, ref_uta = nil)
|
13
14
|
@original_str = str
|
@@ -78,14 +79,7 @@ module Utanone
|
|
78
79
|
next if result.is_eos?
|
79
80
|
|
80
81
|
morpheme = separated_element(result)
|
81
|
-
|
82
|
-
if ref_uta
|
83
|
-
# ref_utaとして参照するUtaオブジェクトが渡されている場合は読みを参照するUtaオブジェクトから取得する
|
84
|
-
ref_morpheme = ref_uta.parsed_morphemes.find { _1[:word] == morpheme[:word] }
|
85
|
-
morpheme[:ruby] = ref_morpheme[:ruby] if ref_morpheme
|
86
|
-
end
|
87
|
-
|
88
|
-
raise Utanone::ParseError unless morpheme[:ruby]
|
82
|
+
morpheme[:ruby] = correct_ruby(morpheme, ref_uta)
|
89
83
|
|
90
84
|
array << morpheme
|
91
85
|
end
|
@@ -121,6 +115,22 @@ module Utanone
|
|
121
115
|
}
|
122
116
|
end
|
123
117
|
|
118
|
+
def correct_ruby(morpheme, ref_uta)
|
119
|
+
if ref_uta
|
120
|
+
# ref_utaとして参照するUtaオブジェクトが渡されている場合は読みを参照するUtaオブジェクトから取得する
|
121
|
+
ref_morpheme = ref_uta.parsed_morphemes.find { _1[:word] == morpheme[:word] }
|
122
|
+
morpheme[:ruby] = ref_morpheme[:ruby] if ref_morpheme
|
123
|
+
end
|
124
|
+
|
125
|
+
if morpheme[:ruby]
|
126
|
+
morpheme[:ruby]
|
127
|
+
else
|
128
|
+
raise Utanone::ParseError unless HIRAGANA_AND_KATAKANA.match?(morpheme[:word])
|
129
|
+
|
130
|
+
convert_kana(morpheme[:word])
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
124
134
|
def natto
|
125
135
|
@natto ||= Natto::MeCab.new
|
126
136
|
end
|
data/lib/utanone/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utanone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yuriko1211
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mecab
|