daidai 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38b5d131989c0801d446ed50e9ab3399fef4813bb017a62304a0fed9629922a1
4
- data.tar.gz: c5eafa61481b4291fc945ce43354a221c6093a9dd44a68d2535e6a2d6b2c8ba0
3
+ metadata.gz: 9753915b3a898b4c12330ac07c319cb213259d7e71c6ff88d9351796885500d8
4
+ data.tar.gz: 79ac3b04d8362a91f4cd9cb4c5347a1dc5ee5ebfafdeb54674ef03d191d4ad3d
5
5
  SHA512:
6
- metadata.gz: f307a1904436405e4a06298a583fe7638b8578d57d68a7e4535457437417f8713b7c1ea71b4d54e5a6c0806c801f86719e494a42ba84dc71871db4857b29bf04
7
- data.tar.gz: 45cc7171d85e261559e9074945274bd6d9e16ac3a435f6a5a0ea4b77b5248c2272545547b4ebce19d05974528a6cd67f6c7b7f09ec94a9864aa5a5eef5c2786d
6
+ metadata.gz: 5c4b2c9ea1fb7b4066530257c54563324a3ecff9d0e64b1e3cb3b91ffd9760bffbff1ab85b3db9760a71260c24bb4b109e94e771dff46f379c1462b71a4309db
7
+ data.tar.gz: df3af68ca1fa55f8980c6133a4fb407c1c07dc6b58aaef8634f0e69890f11fd08c17fd51a2a4a4d04922da48c5926ff62571b7d429eb6dc1d39a928acb68381f
data/CHANGELOG.md CHANGED
@@ -6,6 +6,30 @@ follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2026-09-09
10
+
11
+ ### Added
12
+
13
+ - Na-adjective adverbial forms, including 静かに, with an `adverbial` conjugation and deinflection label.
14
+
15
+ ### Fixed
16
+
17
+ - Copula past and polite forms report their grammatical chains instead of the suru-verb label. The te-form で resolves to the copula だ without conjugating the past auxiliary.
18
+
19
+ - Written humble forms such as 言って差し上げた and 読んで差し上げた deinflect to their main verb, just like their kana spellings.
20
+
21
+ - Honorific imperatives such as ください and 下さい deinflect to their irregular verb bases, including the kana and kanji spellings of the honorific family.
22
+
23
+ - Na-adjective conjugation includes the adverbial form, such as 静かに, with its reading.
24
+
25
+ - Copula で deinflects to だ as a te-form without treating the past auxiliary as a copula.
26
+ - Copula deinflection chains label past and politeness correctly instead of
27
+ calling だった and でした suru verbs.
28
+
29
+ - Automatic honorific resolution preserves kana and kanji spellings, including
30
+ 下さる and おっしゃる, and recovers inflected spellings such as 仰有います
31
+ before accepting a tokenizer split.
32
+
9
33
  ## [0.3.0] - 2026-09-07
10
34
 
11
35
  ### Added
@@ -47,6 +47,10 @@ module Daidai
47
47
  return nil if kanji.nil? && reading.empty?
48
48
 
49
49
  forms = build(strat, kanji, reading)
50
+ if strat[:kind] == :na_adjective
51
+ forms << Form.new(name: :adverbial, negative: false, polite: false, onum: 1,
52
+ kanji: kanji && "#{kanji}に", reading: reading.empty? ? nil : "#{reading}に")
53
+ end
50
54
  forms.empty? ? nil : Word.new(word: kanji || reading, pos: code, kind: strat[:kind], forms: forms)
51
55
  end
52
56
 
@@ -80,7 +80,7 @@ module Daidai
80
80
  "potential" => "potential", "potential or passive" => "potential / passive",
81
81
  "causative" => "causative", "short causative" => "short causative",
82
82
  "volitional" => "volitional", "volitional slang" => "volitional (slang)",
83
- "imperative" => "imperative", "continuative" => "continuative",
83
+ "imperative" => "imperative", "continuative" => "continuative", "adverbial" => "adverbial (-ni)",
84
84
  "-たい" => "desiderative (-tai)", "-たら" => "conditional (-tara)",
85
85
  "-たり" => "representative (-tari)", "-ば" => "provisional (-ba)",
86
86
  "-ゃ" => "conditional contraction (-ya)", "-ちゃ" => "contracted (-cha)",
data/lib/daidai/kabosu.rb CHANGED
@@ -36,19 +36,29 @@ module Daidai
36
36
 
37
37
  # Dictionary-form overrides for verbs whose JMdict subclass Sudachi's 活用型
38
38
  # can't distinguish (irregular okurigana inside an otherwise-regular row).
39
+ HONORIFIC_READINGS = {
40
+ "くださる" => "くださる", "下さる" => "くださる",
41
+ "なさる" => "なさる", "為さる" => "なさる",
42
+ "いらっしゃる" => "いらっしゃる",
43
+ "おっしゃる" => "おっしゃる", "仰る" => "おっしゃる", "仰有る" => "おっしゃる",
44
+ "ござる" => "ござる", "御座る" => "ござる"
45
+ }.freeze
46
+
39
47
  LEMMA_POS = {
40
48
  "行く" => "v5k-s", "逝く" => "v5k-s", "往く" => "v5k-s",
41
49
  "有る" => "v5r-i", "在る" => "v5r-i", "ある" => "v5r-i",
42
50
  "問う" => "v5u-s",
43
- "くださる" => "v5aru", "なさる" => "v5aru", "いらっしゃる" => "v5aru",
44
51
  "いい" => "adj-ix"
45
- }.freeze
52
+ }.merge(HONORIFIC_READINGS.transform_values { "v5aru" }).freeze
46
53
 
47
54
  class << self
48
55
  # Resolve `text` to { word:, pos:, reading: } from its first inflecting
49
56
  # morpheme, or nil when nothing conjugatable is found. Raises
50
57
  # MissingDependency when kabosu/a dictionary isn't installed.
51
58
  def resolve(text)
59
+ honorific = honorific_entry(text)
60
+ return honorific if honorific
61
+
52
62
  morphemes = tokenizer.tokenize(text).to_a
53
63
  index = morphemes.index { |m| inflecting?(m.part_of_speech) }
54
64
  return nil unless index
@@ -82,6 +92,16 @@ module Daidai
82
92
 
83
93
  private
84
94
 
95
+ def honorific_entry(text)
96
+ lemma = text if HONORIFIC_READINGS.key?(text)
97
+ if !lemma && HONORIFIC_READINGS.keys.any? { |word| text.start_with?(word.delete_suffix("る")) }
98
+ lemma = Daidai.deinflect(text).find do |candidate|
99
+ HONORIFIC_READINGS.key?(candidate.term) && candidate.matches_pos?([ "v5aru" ])
100
+ end&.term
101
+ end
102
+ { word: lemma, pos: "v5aru", reading: HONORIFIC_READINGS.fetch(lemma) } if lemma
103
+ end
104
+
85
105
  def from_conjugation_type(pos)
86
106
  case pos[0]
87
107
  when "動詞"
@@ -147,6 +147,18 @@
147
147
  }
148
148
  },
149
149
  "transforms": {
150
+ "adverbial": {
151
+ "name": "adverbial",
152
+ "rules": [
153
+ {
154
+ "type": "suffix",
155
+ "conditionsIn": [],
156
+ "conditionsOut": ["adj-na"],
157
+ "inflected": "に",
158
+ "deinflected": ""
159
+ }
160
+ ]
161
+ },
150
162
  "-なら": {
151
163
  "name": "-なら",
152
164
  "rules": [
@@ -162,35 +174,6 @@
162
174
  "suru": {
163
175
  "name": "suru",
164
176
  "rules": [
165
- {
166
- "type": "suffix",
167
- "conditionsIn": [
168
- "copula"
169
- ],
170
- "conditionsOut": [
171
- "copula"
172
- ],
173
- "inflected": "です",
174
- "deinflected": "だ"
175
- },
176
- {
177
- "type": "suffix",
178
- "conditionsIn": [],
179
- "conditionsOut": [
180
- "copula"
181
- ],
182
- "inflected": "だった",
183
- "deinflected": "だ"
184
- },
185
- {
186
- "type": "suffix",
187
- "conditionsIn": [],
188
- "conditionsOut": [
189
- "copula"
190
- ],
191
- "inflected": "でした",
192
- "deinflected": "です"
193
- },
194
177
  {
195
178
  "type": "suffix",
196
179
  "conditionsIn": ["vs"],
@@ -2680,6 +2663,13 @@
2680
2663
  "name": "-て",
2681
2664
  "description": "て-form.\nIt has a myriad of meanings. Primarily, it is a conjunctive particle that connects two clauses together.\nUsage: Attach て to the continuative form (連用形) of verbs after euphonic change form, くて to the stem of i-adjectives.",
2682
2665
  "rules": [
2666
+ {
2667
+ "type": "suffix",
2668
+ "conditionsIn": ["-て"],
2669
+ "conditionsOut": ["copula"],
2670
+ "inflected": "で",
2671
+ "deinflected": "だ"
2672
+ },
2683
2673
  {
2684
2674
  "type": "suffix",
2685
2675
  "conditionsIn": [
@@ -4812,6 +4802,96 @@
4812
4802
  "name": "imperative",
4813
4803
  "description": "1. To give orders.\n2. (As あれ) Represents the fact that it will never change no matter the circumstances.\n3. Express a feeling of hope.",
4814
4804
  "rules": [
4805
+ {
4806
+ "type": "suffix",
4807
+ "conditionsIn": [],
4808
+ "conditionsOut": [
4809
+ "v5"
4810
+ ],
4811
+ "inflected": "ください",
4812
+ "deinflected": "くださる"
4813
+ },
4814
+ {
4815
+ "type": "suffix",
4816
+ "conditionsIn": [],
4817
+ "conditionsOut": [
4818
+ "v5"
4819
+ ],
4820
+ "inflected": "下さい",
4821
+ "deinflected": "下さる"
4822
+ },
4823
+ {
4824
+ "type": "suffix",
4825
+ "conditionsIn": [],
4826
+ "conditionsOut": [
4827
+ "v5"
4828
+ ],
4829
+ "inflected": "なさい",
4830
+ "deinflected": "なさる"
4831
+ },
4832
+ {
4833
+ "type": "suffix",
4834
+ "conditionsIn": [],
4835
+ "conditionsOut": [
4836
+ "v5"
4837
+ ],
4838
+ "inflected": "為さい",
4839
+ "deinflected": "為さる"
4840
+ },
4841
+ {
4842
+ "type": "suffix",
4843
+ "conditionsIn": [],
4844
+ "conditionsOut": [
4845
+ "v5"
4846
+ ],
4847
+ "inflected": "いらっしゃい",
4848
+ "deinflected": "いらっしゃる"
4849
+ },
4850
+ {
4851
+ "type": "suffix",
4852
+ "conditionsIn": [],
4853
+ "conditionsOut": [
4854
+ "v5"
4855
+ ],
4856
+ "inflected": "おっしゃい",
4857
+ "deinflected": "おっしゃる"
4858
+ },
4859
+ {
4860
+ "type": "suffix",
4861
+ "conditionsIn": [],
4862
+ "conditionsOut": [
4863
+ "v5"
4864
+ ],
4865
+ "inflected": "仰い",
4866
+ "deinflected": "仰る"
4867
+ },
4868
+ {
4869
+ "type": "suffix",
4870
+ "conditionsIn": [],
4871
+ "conditionsOut": [
4872
+ "v5"
4873
+ ],
4874
+ "inflected": "仰有い",
4875
+ "deinflected": "仰有る"
4876
+ },
4877
+ {
4878
+ "type": "suffix",
4879
+ "conditionsIn": [],
4880
+ "conditionsOut": [
4881
+ "v5"
4882
+ ],
4883
+ "inflected": "ござい",
4884
+ "deinflected": "ござる"
4885
+ },
4886
+ {
4887
+ "type": "suffix",
4888
+ "conditionsIn": [],
4889
+ "conditionsOut": [
4890
+ "v5"
4891
+ ],
4892
+ "inflected": "御座い",
4893
+ "deinflected": "御座る"
4894
+ },
4815
4895
  {
4816
4896
  "type": "suffix",
4817
4897
  "conditionsIn": [],
@@ -5793,6 +5873,20 @@
5793
5873
  "name": "-た",
5794
5874
  "description": "1. Indicates a reality that has happened in the past.\n2. Indicates the completion of an action.\n3. Indicates the confirmation of a matter.\n4. Indicates the speaker's confidence that the action will definitely be fulfilled.\n5. Indicates the events that occur before the main clause are represented as relative past.\n6. Indicates a mild imperative/command.\nUsage: Attach た to the continuative form (連用形) of verbs after euphonic change form, かった to the stem of i-adjectives.",
5795
5875
  "rules": [
5876
+ {
5877
+ "type": "suffix",
5878
+ "conditionsIn": [],
5879
+ "conditionsOut": ["copula"],
5880
+ "inflected": "だった",
5881
+ "deinflected": "だ"
5882
+ },
5883
+ {
5884
+ "type": "suffix",
5885
+ "conditionsIn": [],
5886
+ "conditionsOut": ["copula"],
5887
+ "inflected": "でした",
5888
+ "deinflected": "です"
5889
+ },
5796
5890
  {
5797
5891
  "type": "suffix",
5798
5892
  "conditionsIn": [
@@ -6229,6 +6323,13 @@
6229
6323
  "name": "-ます",
6230
6324
  "description": "Polite conjugation of verbs and adjectives.\nUsage: Attach ます to the continuative form (連用形) of verbs.",
6231
6325
  "rules": [
6326
+ {
6327
+ "type": "suffix",
6328
+ "conditionsIn": ["copula"],
6329
+ "conditionsOut": ["copula"],
6330
+ "inflected": "です",
6331
+ "deinflected": "だ"
6332
+ },
6232
6333
  {
6233
6334
  "type": "suffix",
6234
6335
  "conditionsIn": [
@@ -11572,6 +11673,28 @@
11572
11673
  ],
11573
11674
  "inflected": "でさしあげる",
11574
11675
  "deinflected": "で"
11676
+ },
11677
+ {
11678
+ "type": "suffix",
11679
+ "conditionsIn": [
11680
+ "v1"
11681
+ ],
11682
+ "conditionsOut": [
11683
+ "-て"
11684
+ ],
11685
+ "inflected": "て差し上げる",
11686
+ "deinflected": "て"
11687
+ },
11688
+ {
11689
+ "type": "suffix",
11690
+ "conditionsIn": [
11691
+ "v1"
11692
+ ],
11693
+ "conditionsOut": [
11694
+ "-て"
11695
+ ],
11696
+ "inflected": "で差し上げる",
11697
+ "deinflected": "で"
11575
11698
  }
11576
11699
  ]
11577
11700
  },
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Daidai
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/daidai/word.rb CHANGED
@@ -16,7 +16,8 @@ module Daidai
16
16
  imperative: "Imperative",
17
17
  conditional: "Conditional (~tara)",
18
18
  alternative: "Alternative (~tari)",
19
- stem: "Continuative (~i)"
19
+ stem: "Continuative (~i)",
20
+ adverbial: "Adverbial"
20
21
  }.freeze
21
22
 
22
23
  # conjo.csv conjugation id (1..13) => form name, in the same order as FORMS.
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - davafons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-07 00:00:00.000000000 Z
11
+ date: 2026-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv