daidai 0.4.0 → 0.4.1
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 +19 -0
- data/lib/daidai/conjugator.rb +15 -7
- data/lib/daidai/deinflector.rb +19 -10
- data/lib/daidai/resources/japanese-transforms.json +35 -0
- data/lib/daidai/tables.rb +30 -16
- data/lib/daidai/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: db69ab57e999cf426fae355e349a9ac7996f16aee50d0549685750f67eba5506
|
|
4
|
+
data.tar.gz: 231041ea623c8241b63419bfc1df196bea7ef0bba3148c3804fdbaada56e8636
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73bdb4da2b4218cf00a5970ebbaf3135381807078ba7a908278059b982cda1744d4ea27747a497b46dd34ebbe9804a56f9a74a054b0a645ad93d000afb308de5
|
|
7
|
+
data.tar.gz: 221db22e41578b09a0e976a6999c4ca6989529ff2fac0ebfc9871e249be208c73cd62d0ac20ea057509064e7a323d009ff8e72f8de6402f564d37b9bb4c6b9a2
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.1] - 2026-11-18
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- ある no longer has a potential. The JMdictDB table gave it あれる, which is
|
|
14
|
+
荒れる, so あれている could deinflect to ある. Its short causative あらす and
|
|
15
|
+
あらされる go too: they are 荒らす and 荒らされる. Short causatives are now
|
|
16
|
+
checked against the conjugation table like every other generated form.
|
|
17
|
+
- The negatives of 愛する and the other vs-s verbs deinflect to their verb.
|
|
18
|
+
The table gave only 愛さない, which no rule reached, and the rules reached
|
|
19
|
+
only 愛しない, which the table did not list, so every negative of the class
|
|
20
|
+
failed, 察しない and 達しない included. Both shapes are now accepted. The
|
|
21
|
+
godan one is read only after the kanji, because in kana ださない is 出す and
|
|
22
|
+
かさない is 貸す.
|
|
23
|
+
- Conjugating a vs-s verb lists both negatives. Given a reading whose stem has
|
|
24
|
+
a 促音, 撥音 or long vowel, the サ変 negative comes first (察しない, 反しない,
|
|
25
|
+
有しない), as 田野村忠温's corpus counts show. Otherwise the godan one does
|
|
26
|
+
(愛さない, 略さない).
|
|
27
|
+
|
|
9
28
|
## [0.4.0] - 2026-09-09
|
|
10
29
|
|
|
11
30
|
### Added
|
data/lib/daidai/conjugator.rb
CHANGED
|
@@ -28,6 +28,13 @@ module Daidai
|
|
|
28
28
|
COPULA_POS = 15 # the copula だ — na-adjectives conjugate through it
|
|
29
29
|
SURU_POS = 48 # vs-i (する) — `vs` nouns conjugate by appending する
|
|
30
30
|
|
|
31
|
+
# A vs-s stem whose reading has a 促音, 撥音 or long vowel keeps the サ変
|
|
32
|
+
# negative (察しない, 反しない, 有しない); any other takes the godan one
|
|
33
|
+
# (愛さない, 略さない, 課さない). 田野村忠温 measured this in newspaper and web
|
|
34
|
+
# corpora (NINJAL 国立国語研究所論集, 2001 and 2009). 対する breaks it: たい has
|
|
35
|
+
# none of the three, yet nine in ten of its negatives are 対しない.
|
|
36
|
+
SAHEN_STEM = /[っんー]|[うくすつぬふむゆるぐずづぶぷゅおこそとのほもよろごぞどぼぽょ]う|[えけせてねへめれげぜでべぺ]い/
|
|
37
|
+
|
|
31
38
|
class << self
|
|
32
39
|
# True if any of `pos` (a JMdict code or array of codes) can be conjugated.
|
|
33
40
|
def conjugatable?(pos)
|
|
@@ -46,7 +53,8 @@ module Daidai
|
|
|
46
53
|
reading = reading.to_s
|
|
47
54
|
return nil if kanji.nil? && reading.empty?
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
sahen_first = code == "vs-s" && reading.delete_suffix("する").match?(SAHEN_STEM)
|
|
57
|
+
forms = build(strat, kanji, reading, sahen_first: sahen_first)
|
|
50
58
|
if strat[:kind] == :na_adjective
|
|
51
59
|
forms << Form.new(name: :adverbial, negative: false, polite: false, onum: 1,
|
|
52
60
|
kanji: kanji && "#{kanji}に", reading: reading.empty? ? nil : "#{reading}に")
|
|
@@ -57,8 +65,9 @@ module Daidai
|
|
|
57
65
|
private
|
|
58
66
|
|
|
59
67
|
# Walk every (conjugation, quadrant, onum) row defined for this pos and
|
|
60
|
-
# construct the inflected kanji + reading.
|
|
61
|
-
|
|
68
|
+
# construct the inflected kanji + reading. `sahen_first` puts a vs-s
|
|
69
|
+
# verb's サ変 negatives (察しない) ahead of its godan ones (察さない).
|
|
70
|
+
def build(strat, kanji, reading, sahen_first: false)
|
|
62
71
|
if strat[:append]
|
|
63
72
|
kanji = (kanji || reading) + strat[:append]
|
|
64
73
|
reading += strat[:append]
|
|
@@ -66,10 +75,9 @@ module Daidai
|
|
|
66
75
|
|
|
67
76
|
Tables.conj.keys.sort.flat_map do |conj_id|
|
|
68
77
|
QUADRANTS.flat_map do |negative, polite|
|
|
69
|
-
(1..9).filter_map
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
rows = (1..9).filter_map { |onum| Tables.conjo[[ strat[:pos_id], conj_id, negative, polite, onum ]] }
|
|
79
|
+
rows = rows.partition { |row| row.euphr == "し" }.sum([]) if sahen_first && negative && !polite
|
|
80
|
+
rows.each.with_index(1).filter_map do |row, onum|
|
|
73
81
|
kf = inflect(strat, kanji, row)
|
|
74
82
|
rf = inflect(strat, reading, row)
|
|
75
83
|
next if kf.nil? && rf.nil?
|
data/lib/daidai/deinflector.rb
CHANGED
|
@@ -18,18 +18,26 @@ module Daidai
|
|
|
18
18
|
Array(pos_codes).any? do |code|
|
|
19
19
|
next true if code.to_s == "vs" && Array(word_classes).include?("vs-noun")
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
when /\Av1(?:-|\z)/ then "v1"
|
|
23
|
-
when /\Av5/ then "v5"
|
|
24
|
-
when /\Avs(?:-|\z)/ then "vs"
|
|
25
|
-
when "adj-ix" then "adj-i"
|
|
26
|
-
when "cop" then "copula"
|
|
27
|
-
else code.to_s
|
|
28
|
-
end
|
|
29
|
-
Array(word_classes).include?(word_class) && compatible_irregular_form?(code.to_s)
|
|
21
|
+
Array(word_classes).intersect?(classes_for(code.to_s)) && compatible_irregular_form?(code.to_s)
|
|
30
22
|
end
|
|
31
23
|
end
|
|
32
24
|
|
|
25
|
+
# The deinflection classes a JMdict code accepts. A vs-s verb also takes the
|
|
26
|
+
# godan negative (愛さない), but only after its kanji: in kana, ださない is
|
|
27
|
+
# 出す and かさない is 貸す.
|
|
28
|
+
def classes_for(code)
|
|
29
|
+
case code
|
|
30
|
+
when /\Av1(?:-|\z)/ then %w[v1]
|
|
31
|
+
when /\Av5/ then %w[v5]
|
|
32
|
+
when "vs-s" then term.match?(/\p{Han}する\z/) ? %w[vs vs-s] : %w[vs]
|
|
33
|
+
when /\Avs(?:-|\z)/ then %w[vs]
|
|
34
|
+
when "adj-ix" then %w[adj-i]
|
|
35
|
+
when "cop" then %w[copula]
|
|
36
|
+
else [ code ]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
private :classes_for
|
|
40
|
+
|
|
33
41
|
def compatible_irregular_form?(code)
|
|
34
42
|
return true unless base_surface && Deinflector::IRREGULAR_POS.include?(code) &&
|
|
35
43
|
Deinflector::GENERATED_RULES.include?(inflections.last)
|
|
@@ -64,7 +72,8 @@ module Daidai
|
|
|
64
72
|
module Deinflector
|
|
65
73
|
DATA_FILE = File.expand_path("resources/japanese-transforms.json", __dir__)
|
|
66
74
|
IRREGULAR_POS = %w[v5k-s v5u-s v5r-i v5aru v1-s adj-ix vs-s].freeze
|
|
67
|
-
GENERATED_RULES =
|
|
75
|
+
GENERATED_RULES = [ "-た", "-て", "-ます", "negative", "-ば", "-たら", "-たり", "potential", "passive",
|
|
76
|
+
"causative", "short causative", "volitional", "imperative" ].freeze
|
|
68
77
|
|
|
69
78
|
# Friendly English labels for the deinflection rule names #deinflect emits.
|
|
70
79
|
# The underlying names (ported from Yomitan) are terse and sometimes symbolic
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"v5",
|
|
29
29
|
"vk",
|
|
30
30
|
"vs",
|
|
31
|
+
"vs-s",
|
|
31
32
|
"vz"
|
|
32
33
|
]
|
|
33
34
|
},
|
|
@@ -90,6 +91,11 @@
|
|
|
90
91
|
"isDictionaryForm": true,
|
|
91
92
|
"subConditions": null
|
|
92
93
|
},
|
|
94
|
+
"vs-s": {
|
|
95
|
+
"name": "Suru verb, special class, by its godan negative (愛さない)",
|
|
96
|
+
"isDictionaryForm": true,
|
|
97
|
+
"subConditions": null
|
|
98
|
+
},
|
|
93
99
|
"vz": {
|
|
94
100
|
"name": "Zuru verb",
|
|
95
101
|
"isDictionaryForm": true,
|
|
@@ -3117,6 +3123,15 @@
|
|
|
3117
3123
|
"inflected": "さず",
|
|
3118
3124
|
"deinflected": "す"
|
|
3119
3125
|
},
|
|
3126
|
+
{
|
|
3127
|
+
"type": "suffix",
|
|
3128
|
+
"conditionsIn": [],
|
|
3129
|
+
"conditionsOut": [
|
|
3130
|
+
"vs-s"
|
|
3131
|
+
],
|
|
3132
|
+
"inflected": "さず",
|
|
3133
|
+
"deinflected": "する"
|
|
3134
|
+
},
|
|
3120
3135
|
{
|
|
3121
3136
|
"type": "suffix",
|
|
3122
3137
|
"conditionsIn": [],
|
|
@@ -3267,6 +3282,15 @@
|
|
|
3267
3282
|
"inflected": "さぬ",
|
|
3268
3283
|
"deinflected": "す"
|
|
3269
3284
|
},
|
|
3285
|
+
{
|
|
3286
|
+
"type": "suffix",
|
|
3287
|
+
"conditionsIn": [],
|
|
3288
|
+
"conditionsOut": [
|
|
3289
|
+
"vs-s"
|
|
3290
|
+
],
|
|
3291
|
+
"inflected": "さぬ",
|
|
3292
|
+
"deinflected": "する"
|
|
3293
|
+
},
|
|
3270
3294
|
{
|
|
3271
3295
|
"type": "suffix",
|
|
3272
3296
|
"conditionsIn": [],
|
|
@@ -5509,6 +5533,17 @@
|
|
|
5509
5533
|
"inflected": "さない",
|
|
5510
5534
|
"deinflected": "す"
|
|
5511
5535
|
},
|
|
5536
|
+
{
|
|
5537
|
+
"type": "suffix",
|
|
5538
|
+
"conditionsIn": [
|
|
5539
|
+
"adj-i"
|
|
5540
|
+
],
|
|
5541
|
+
"conditionsOut": [
|
|
5542
|
+
"vs-s"
|
|
5543
|
+
],
|
|
5544
|
+
"inflected": "さない",
|
|
5545
|
+
"deinflected": "する"
|
|
5546
|
+
},
|
|
5512
5547
|
{
|
|
5513
5548
|
"type": "suffix",
|
|
5514
5549
|
"conditionsIn": [
|
data/lib/daidai/tables.rb
CHANGED
|
@@ -17,17 +17,38 @@ module Daidai
|
|
|
17
17
|
# load so the vendored CSVs stay byte-identical to upstream (keeping
|
|
18
18
|
# `rake daidai:check_resources` green) while daidai still emits the right
|
|
19
19
|
# form. Keyed by JMdict code + [conj_id, negative?, polite?, onum] so a
|
|
20
|
-
# pos-id renumber upstream can't silently misapply the fix;
|
|
21
|
-
#
|
|
20
|
+
# pos-id renumber upstream can't silently misapply the fix; each value is
|
|
21
|
+
# the whole row as it should read, added when upstream has none.
|
|
22
22
|
#
|
|
23
23
|
# • v5u negative conditional (買う → 買わなかったら): upstream conjo.csv stores
|
|
24
24
|
# "わかったら", dropping the な. Every other class is correct here (v5u-s
|
|
25
25
|
# even has わなかったら), so this one cell is a typo. Without it every
|
|
26
26
|
# godan-u verb's negative ~tara comes out as 買わかったら / 使わかったら / ….
|
|
27
|
+
# • vs-s negatives: upstream gives only the godan negative (愛さない), which
|
|
28
|
+
# is wrong for 察する, 達する, 反する and 有する (察しない). The サ変 one
|
|
29
|
+
# is added beside it, and the te-form pairs なくて with ないで in each.
|
|
27
30
|
CONJO_ERRATA = {
|
|
28
|
-
[ "v5u", 11, true, false, 1 ] => { okuri: "わなかったら" }
|
|
31
|
+
[ "v5u", 11, true, false, 1 ] => { stem: 1, okuri: "わなかったら" },
|
|
32
|
+
[ "vs-s", 1, true, false, 2 ] => { stem: 1, okuri: "ない", euphr: "し" },
|
|
33
|
+
[ "vs-s", 2, true, false, 2 ] => { stem: 1, okuri: "なかった", euphr: "し" },
|
|
34
|
+
[ "vs-s", 3, true, false, 2 ] => { stem: 1, okuri: "ないで", euphr: "さ" },
|
|
35
|
+
[ "vs-s", 3, true, false, 3 ] => { stem: 1, okuri: "なくて", euphr: "し" },
|
|
36
|
+
[ "vs-s", 3, true, false, 4 ] => { stem: 1, okuri: "ないで", euphr: "し" },
|
|
37
|
+
[ "vs-s", 4, true, false, 2 ] => { stem: 1, okuri: "なければ", euphr: "し" },
|
|
38
|
+
[ "vs-s", 11, true, false, 2 ] => { stem: 1, okuri: "なかったら", euphr: "し" },
|
|
39
|
+
[ "vs-s", 12, true, false, 2 ] => { stem: 1, okuri: "なかったり", euphr: "し" }
|
|
29
40
|
}.freeze
|
|
30
41
|
|
|
42
|
+
# Upstream rows that are no form of the class, as JMdict code + [conj_id,
|
|
43
|
+
# onum]. Each goes in every polarity and formality.
|
|
44
|
+
#
|
|
45
|
+
# • ある has no potential (国際交流基金 lists it among the verbs without
|
|
46
|
+
# one): あれる is 荒れる. Its short causative あらす is 荒らす, and
|
|
47
|
+
# あらされる is 荒らされる.
|
|
48
|
+
CONJO_REMOVED = [
|
|
49
|
+
[ "v5r-i", 5, 1 ], [ "v5r-i", 7, 2 ], [ "v5r-i", 8, 2 ]
|
|
50
|
+
].freeze
|
|
51
|
+
|
|
31
52
|
class << self
|
|
32
53
|
# conjugation id (Integer) => human name ("Past (~ta)", …)
|
|
33
54
|
def conj
|
|
@@ -61,22 +82,15 @@ module Daidai
|
|
|
61
82
|
|
|
62
83
|
private
|
|
63
84
|
|
|
64
|
-
# Overlay CONJO_ERRATA onto the freshly-loaded table,
|
|
65
|
-
# code to its pos id.
|
|
66
|
-
# fixed it, or restructured) is skipped silently — the errata is advisory.
|
|
85
|
+
# Overlay CONJO_ERRATA and CONJO_REMOVED onto the freshly-loaded table,
|
|
86
|
+
# resolving each JMdict code to its pos id.
|
|
67
87
|
def apply_conjo_errata(table)
|
|
68
|
-
CONJO_ERRATA.each do |(code, conj, neg, fml, onum),
|
|
88
|
+
CONJO_ERRATA.each do |(code, conj, neg, fml, onum), row|
|
|
69
89
|
pos_id = pos_ids[code] or next
|
|
70
|
-
|
|
71
|
-
row = table[key] or next
|
|
72
|
-
table[key] = Okurigana.new(
|
|
73
|
-
stem: fix.fetch(:stem, row.stem),
|
|
74
|
-
okuri: fix.fetch(:okuri, row.okuri),
|
|
75
|
-
euphr: fix.fetch(:euphr, row.euphr),
|
|
76
|
-
euphk: fix.fetch(:euphk, row.euphk)
|
|
77
|
-
)
|
|
90
|
+
table[[ pos_id, conj, neg, fml, onum ]] = Okurigana.new(**row)
|
|
78
91
|
end
|
|
79
|
-
|
|
92
|
+
removed = CONJO_REMOVED.filter_map { |code, conj, onum| [ pos_ids[code], conj, onum ] if pos_ids[code] }
|
|
93
|
+
table.reject { |(pos_id, conj, _neg, _fml, onum), _row| removed.include?([ pos_id, conj, onum ]) }
|
|
80
94
|
end
|
|
81
95
|
|
|
82
96
|
def read(file, headers: true)
|
data/lib/daidai/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: daidai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- davafons
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: csv
|