jp-deinflector 0.2.2

A package for deinflecting Japanese words
Documentation
1
2
3
4
5
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
use crate::deinflection_rules::{get_deinflection_rules, MAX_SUFFIX_LENGTH};
use crate::kata_to_hira::kata_to_hira;
use fxhash::FxHashSet;

#[inline]
fn concatenate(a: &str, b: &str) -> String {
    let mut str = String::with_capacity(a.len() + b.len());
    str.push_str(a);
    str.push_str(b);
    str
}

/// The grammatical type of the word, which determines
/// the rules that can be applied for deinflection
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RuleType {
    AdjI,
    Iru,
    V1,
    V5,
    Vk,
    Vs,
    Vz,
}

#[derive(Debug, Clone)]
pub struct DeinflectionRule {
    pub kana_out: &'static str,
    pub rules_in: &'static [RuleType],
    pub rules_out: &'static [RuleType],
}

impl DeinflectionRule {
    fn can_apply_to(&self, word: &DeinflectedWord) -> bool {
        // Case: don't know what type the word might have -> Can apply all rules
        word.get_types().is_empty()
            // Case: Assume word to be one of the types in word.types -> Apply only fitting rules
            || self.rules_in.iter().any(|r| word.types.contains(r))
    }

    /// Applies the rule to `deinflected_word` if its types allow it to
    pub fn apply(&self, deinflected_word: &DeinflectedWord, suffix_len: usize) -> Option<String> {
        if self.can_apply_to(deinflected_word) {
            let word = deinflected_word.get_word();
            debug_assert!(word.len() >= suffix_len);
            let stem = &word[..word.len() - suffix_len];
            Some(concatenate(stem, self.kana_out))
        } else {
            None
        }
    }
}

#[derive(Debug)]
pub struct DeinflectedWord {
    pub word: String,
    pub types: &'static [RuleType],
}

impl DeinflectedWord {
    pub fn new(word: String, types: &'static [RuleType]) -> Self {
        Self { word, types }
    }

    pub fn get_word(&self) -> &str {
        &self.word
    }

    pub fn get_types(&self) -> &'static [RuleType] {
        self.types
    }
}

/// Tracks words that have already been seen to avoid infinite loops
struct SeenWordsTracker {
    seen: FxHashSet<usize>,
}

impl SeenWordsTracker {
    pub fn new() -> Self {
        Self {
            seen: FxHashSet::default(),
        }
    }

    /// Returns true if the word hasn't been seen before
    pub fn check_is_new(&mut self, word: &DeinflectedWord) -> bool {
        let key = fxhash::hash(word.word.as_bytes());
        self.seen.insert(key)
    }
}

/// Returns an iterator over all suffixes of length <= MAX_SUFFIX_LENGTH of the word.
/// Assumes that the word only consists of Japanese characters.
/// (Otherwise there is nothing to deflect anyway, so it doesn't matter if this function breaks)
fn capped_suffixes(word: &str) -> impl Iterator<Item = &str> {
    let max_suffix_bytes = MAX_SUFFIX_LENGTH * 3; // each jap character is 3 bytes
    let start_pos = word.len().saturating_sub(max_suffix_bytes);
    (start_pos..word.len()).step_by(3).map(|i| &word[i..])
}

/// Performs a single deinflect operation, e.g.: 食べさせられたくなかった -> 食べさせられたくない
pub fn deinflect_one_iteration(deinflected_word: &DeinflectedWord) -> Vec<DeinflectedWord> {
    let mut results = Vec::new();
    for suffix in capped_suffixes(deinflected_word.get_word()) {
        if let Some(rules) = get_deinflection_rules(suffix) {
            for rule in rules.iter() {
                if let Some(deinflected) = rule.apply(deinflected_word, suffix.len()) {
                    results.push(DeinflectedWord::new(deinflected, rule.rules_out));
                }
            }
        }
    }

    results
}

/// Returns a list of possible deinflections for the given word.
/// It doesn't guarantee that the returned deinflections are actual Japanese words, but if
/// the words would exist, they would be deinflected correctly.
///
/// # Examples
/// ```
/// use jp_deinflector::deinflect;
/// let deinflections = deinflect("食べさせられなかった");
/// assert!(deinflections.iter().any(|w| w == "食べる"));
///
/// let deinflections = deinflect("待った");
/// assert!(deinflections.iter().any(|w| w == "待つ"));
/// assert!(deinflections.iter().any(|w| w == "待う"));
/// assert!(deinflections.iter().any(|w| w == "待る"));
/// ```
pub fn deinflect(word: &str) -> Vec<String> {
    let initial = DeinflectedWord::new(kata_to_hira(word), &[]);
    let mut deinflections = deinflect_one_iteration(&initial);

    let mut seen_checker = SeenWordsTracker::new();
    seen_checker.check_is_new(&initial);

    let mut i = 0;
    while i < deinflections.len() {
        let current = &deinflections[i];
        if seen_checker.check_is_new(current) {
            let new_deinflections = deinflect_one_iteration(current);
            deinflections.extend(new_deinflections);
        }
        i += 1;
    }

    deinflections
        .into_iter()
        .map(|deinflection| deinflection.word)
        .collect()
}

#[cfg(test)]
mod tests {
    use super::*;

    fn assert_deinflects_to(input: &str, expected: &str) {
        let result = deinflect(input);
        let deinflected = result.iter().map(|s| &**s).collect::<Vec<&str>>();
        assert!(
            deinflected.contains(&expected),
            "Input '{}' did not deinflect to '{}'. Results: {:?}",
            input,
            expected,
            deinflected
        );
    }

    fn assert_does_not_deinflect_to(input: &str, not_expected: &str) {
        let results = deinflect(input);
        let deinflected: Vec<&str> = results.iter().map(|s| &**s).collect();
        assert!(
            !deinflected.contains(&not_expected),
            "Input '{}' unexpectedly deinflected to '{}'. Results: {:?}",
            input,
            not_expected,
            deinflected
        );
    }

    #[test]
    fn test_deinflects_ichidan() {
        let cases = [
            "信じない",
            "信じます",
            "信じない",
            "信じます",
            "信じません",
            "信じた",
            "信じなかった",
            "信じました",
            "信じませんでした",
            "信じて",
            "信じなくて",
            "信じられる",
            "信じられない",
            "信じられない",
            "信じさせる",
            "信じさせない",
            "信じさせられる",
            "信じさせられない",
            "信じろ",
            "信じ",
            "信じよう",
            "信じられなかった",
        ];
        for case in cases {
            assert_deinflects_to(case, "信じる");
        }

        let cases = [
            "生きない",
            "生きます",
            "生きません",
            "生きた",
            "生きなかった",
            "生きました",
            "生きませんでした",
            "生きて",
            "生きなくて",
            "生きられる",
            "生きられない",
            "生きられない",
            "生きさせる",
            "生きさせない",
            "生きさせられる",
            "生きさせられない",
            "生きろ",
            "生き",
            "生きよう",
        ];
        for case in cases {
            assert_deinflects_to(case, "生きる");
        }
    }

    #[test]
    fn test_deinflects_godan_ru() {
        let cases = [
            "売らない",
            "売ります",
            "売りません",
            "売った",
            "売らなかった",
            "売りました",
            "売りませんでした",
            "売って",
            "売らなくて",
            "売れる",
            "売れない",
            "売られる",
            "売られない",
            "売らせる",
            "売らせない",
            "売らせられる",
            "売らせられない",
            "売れ",
            "売り",
            "売ろう",
        ];
        for case in cases {
            assert_deinflects_to(case, "売る");
        }
    }

    #[test]
    fn test_deinflects_godan_mu() {
        let cases = [
            "読まない",
            "読みます",
            "読みません",
            "読んだ",
            "読まなかった",
            "読みました",
            "読みませんでした",
            "読んで",
            "読まなくて",
            "読める",
            "読めない",
            "読まれる",
            "読まれない",
            "読ませる",
            "読ませない",
            "読ませられる",
            "読ませられない",
            "読め",
            "読み",
            "読もう",
        ];
        for case in cases {
            assert_deinflects_to(case, "読む");
        }
    }

    #[test]
    fn test_deinflects_godan_bu() {
        let cases = [
            "遊ばない",
            "遊びます",
            "遊びません",
            "遊んだ",
            "遊ばなかった",
            "遊びました",
            "遊びませんでした",
            "遊んで",
            "遊ばなくて",
            "遊べる",
            "遊べない",
            "遊ばれる",
            "遊ばれない",
            "遊ばせる",
            "遊ばせない",
            "遊ばせられる",
            "遊ばせられない",
            "遊べ",
            "遊び",
            "遊ぼう",
        ];
        for case in cases {
            assert_deinflects_to(case, "遊ぶ");
        }
    }

    #[test]
    fn test_deinflects_godan_tsu() {
        let cases = [
            "勝たない",
            "勝ちます",
            "勝ちません",
            "勝った",
            "勝たなかった",
            "勝ちました",
            "勝ちませんでした",
            "勝って",
            "勝たなくて",
            "勝てる",
            "勝てない",
            "勝たれる",
            "勝たれない",
            "勝たせる",
            "勝たせない",
            "勝たせられる",
            "勝たせられない",
            "勝て",
            "勝ち",
            "勝とう",
        ];
        for case in cases {
            assert_deinflects_to(case, "勝つ");
        }
    }

    #[test]
    fn test_deinflects_godan_su() {
        let cases = [
            "誑かさない",
            "誑かします",
            "誑かしません",
            "誑かした",
            "誑かさなかった",
            "誑かしました",
            "誑かしませんでした",
            "誑かして",
            "誑かさなくて",
            "誑かせる",
            "誑かせない",
            "誑かされる",
            "誑かされない",
            "誑かさせる",
            "誑かさせない",
            "誑かさせられる",
            "誑かさせられない",
            "誑かせ",
            "誑かし",
            "誑かそう",
        ];
        for case in cases {
            assert_deinflects_to(case, "誑かす");
        }
    }

    #[test]
    fn test_deinflects_godan_ku() {
        let cases = [
            "叩かない",
            "叩きます",
            "叩きません",
            "叩いた",
            "叩かなかった",
            "叩きました",
            "叩きませんでした",
            "叩いて",
            "叩かなくて",
            "叩ける",
            "叩けない",
            "叩かれる",
            "叩かれない",
            "叩かせる",
            "叩かせない",
            "叩かせられる",
            "叩かせられない",
            "叩け",
            "叩き",
            "叩こう",
        ];
        for case in cases {
            assert_deinflects_to(case, "叩く");
        }
    }

    #[test]
    fn test_deinflects_godan_gu() {
        let cases = [
            "泳がない",
            "泳ぎます",
            "泳ぎません",
            "泳いだ",
            "泳がなかった",
            "泳ぎました",
            "泳ぎませんでした",
            "泳いで",
            "泳がなくて",
            "泳げる",
            "泳げない",
            "泳がれる",
            "泳がれない",
            "泳がせる",
            "泳がせない",
            "泳がせられる",
            "泳がせられない",
            "泳げ",
            "泳ぎ",
            "泳ごう",
        ];
        for case in cases {
            assert_deinflects_to(case, "泳ぐ");
        }
    }

    #[test]
    fn test_deinflects_godan_u() {
        let cases = [
            "買わない",
            "買います",
            "買いません",
            "買った",
            "買わなかった",
            "買いました",
            "買いませんでした",
            "買って",
            "買わなくて",
            "買える",
            "買えない",
            "買われる",
            "買われない",
            "買わせる",
            "買わせない",
            "買わせられる",
            "買わせられない",
            "買え",
            "買い",
            "買おう",
        ];
        for case in cases {
            assert_deinflects_to(case, "買う");
        }
    }

    #[test]
    fn test_deinflects_negations() {
        let test_cases = [
            ("食べる", "食べず"),
            ("行く", "行かず"),
            ("知る", "知らん"),
            ("泣く", "泣かぬ"),
            ("信じる", "信じぬ"),
            // ("落ちる", "落ちまい"),
            // ("消える", "消えまい"),
            // ("知る", "知らせまい"),
            // ("食べる", "食べさせまい"),
            // ("言う", "言われまい"),
        ];
        for (expected, input) in test_cases {
            assert_deinflects_to(input, expected);
        }
    }

    #[test]
    fn test_deinflects_tai() {
        let test_cases = [
            ("遊ぶ", vec!["遊びたい", "遊びたかった", "遊びたければ"]),
            ("食べる", vec!["食べたい"]),
            ("旅行する", vec!["旅行したい"]),
            ("会う", vec!["会わせたい"]),
            ("寝る", vec!["寝させたい"]),
            ("思う", vec!["思われたい"]),
            ("褒める", vec!["褒められたい"]),
        ];
        for (expected, inputs) in test_cases {
            for input in inputs {
                assert_deinflects_to(input, expected);
            }
        }
    }

    #[test]
    fn test_deinflects_nagara() {
        let test_cases = [
            ("走る", "走りながら"),
            ("攪拌する", "攪拌しながら"),
            ("食べる", "食べながら"),
            ("書く", "書きながら"),
        ];
        for (expected, input) in test_cases {
            assert_deinflects_to(input, expected);
        }
    }

    #[test]
    fn test_deinflects_suru_and_compounds() {
        let suru_cases = [
            "しない",
            "します",
            "しません",
            "した",
            "しなかった",
            "しました",
            "しませんでした",
            "して",
            "しなくて",
            "される",
            "されない",
            "させる",
            "させない",
            "させられる",
            "させられない",
            "しろ",
            "",
            "しよう",
        ];
        for case in suru_cases {
            assert_deinflects_to(case, "する");
        }

        let compound_cases = [
            "勉強しない",
            "勉強します",
            "勉強しません",
            "勉強した",
            "勉強しなかった",
            "勉強しました",
            "勉強しませんでした",
            "勉強して",
            "勉強しなくて",
            "勉強される",
            "勉強されない",
            "勉強させる",
            "勉強させない",
            "勉強させられる",
            "勉強させられない",
            "勉強しろ",
            "勉強し",
            "勉強しよう",
        ];
        for case in compound_cases {
            assert_deinflects_to(case, "勉強する");
        }
    }

    #[test]
    fn test_deinflects_conditional_forms() {
        let test_cases = [
            (
                "読む",
                vec!["読めば", "読まなければ", "読んだら", "読まなかったら"],
            ),
            (
                "食べる",
                vec!["食べれば", "食べなければ", "食べたら", "食べなかったら"],
            ),
        ];
        for (expected, inputs) in test_cases {
            for input in inputs {
                assert_deinflects_to(input, expected);
            }
        }
    }

    #[test]
    fn test_deinflects_adverb_forms() {
        assert_deinflects_to("早く", "早い");
    }

    #[test]
    fn test_deinflects_compound_verbs() {
        let tobi_cases = [
            "飛び込まない",
            "飛び込みます",
            "飛び込みません",
            "飛び込んだ",
            "飛び込まなかった",
            "飛び込みました",
            "飛び込みませんでした",
            "飛び込んで",
            "飛び込まなくて",
            "飛び込める",
            "飛び込めない",
        ];
        for case in tobi_cases {
            assert_deinflects_to(case, "飛び込む");
        }

        let kaki_cases = [
            "書き始めない",
            "書き始めます",
            "書き始めません",
            "書き始めた",
            "書き始めなかった",
            "書き始めました",
            "書き始めませんでした",
            "書き始めて",
            "書き始めなくて",
            "書き始められる",
            "書き始められない",
        ];
        for case in kaki_cases {
            assert_deinflects_to(case, "書き始める");
        }
    }

    #[test]
    fn test_wrong_deinflections() {
        assert_does_not_deinflect_to("白ける", "白い");
        assert_does_not_deinflect_to("とぼけた", "とぶ");
        assert_does_not_deinflect_to("ねたんだり", "ねつ");
        assert_does_not_deinflect_to("とぼけた", "とぶ");
    }

    #[test]
    fn test_edge_cases() {
        // Empty string
        let deinflections = deinflect("");
        assert!(deinflections.is_empty());

        // Single character
        let deinflections = deinflect("");
        assert!(deinflections.is_empty());

        // Max length string
        let long_string = "".repeat(1000);
        assert!(deinflect(&long_string).is_empty());
    }

    #[test]
    fn test_chained_inflections() {
        assert_deinflects_to("食べさせられなかった", "食べる");
        assert_deinflects_to("走らされていました", "走る");
    }

    #[test]
    fn test_kuru() {
        let kuru_cases = [
            "来ない",
            "来ます",
            "来ません",
            "来た",
            "来なかった",
            "来ました",
            "来て",
            "来なくて",
            "来られない",
            "来られる",
            "来られない",
            "来させる",
            "来させない",
            "来させられる",
            "来させられない",
            "来い",
        ];
        for case in kuru_cases {
            assert_deinflects_to(case, "来る");
        }
    }

    #[test]
    fn test_deinflects_nai_contractions() {
        let cases = [
            ("覚えなきゃ", "覚える"),
            ("覚えなくちゃ", "覚える"),
            ("覚えなけりゃ", "覚える"),
            ("書かなきゃ", "書く"),
            ("待たなくちゃ", "待つ"),
            ("しなきゃ", "する"),
            ("来なきゃ", "来る"),
            ("高くなきゃ", "高い"),
            ("高くなくちゃ", "高い"),
            ("高くなけりゃ", "高い"),
        ];
        for (input, expected) in cases {
            assert_deinflects_to(input, expected);
        }
    }

    #[test]
    fn test_get_suffixes() {
        let word = "走らされている";
        let suffixes: Vec<&str> = capped_suffixes(word).collect();
        assert_eq!(
            suffixes,
            vec![
                "走らされている",
                "らされている",
                "されている",
                "れている",
                "ている",
                "いる",
                ""
            ]
        );

        let word = "食べさせられなかった";
        let suffixes: Vec<&str> = capped_suffixes(word).collect();
        assert_eq!(
            suffixes,
            vec![
                "せられなかった",
                "られなかった",
                "れなかった",
                "なかった",
                "かった",
                "った",
                ""
            ]
        );
    }

    #[test]
    fn test_matsu() {
        let cases = [
            "待ちます",
            "待った",
            "待ちました",
            "待って",
            "待てる",
            "待たせる",
            "待たせられる",
            "待て",
            "待たない",
            "待ちません",
            "待たなかった",
            "待ちませんでした",
            "待たなくて",
            "待てない",
            "待たれない",
            "待たせない",
            "待たせられない",
            "待つな",
            "待てば",
            "待っちゃう",
            "待っちまう",
            "待ちなさい",
            "待ちそう",
            "待ちすぎる",
            "待ちたい",
            "待ったら",
            "待ったり",
            "待たず",
            "待たぬ",
            "待ち",
            "待ちましょう",
            "待とう",
            "待たされる",
            "待っとく",
            "待っている",
            "待っておる",
            "待ってる",
            "待ってしまう",
        ];

        for case in cases {
            assert_deinflects_to(case, "待つ");
        }
    }

    #[test]
    fn test_suru() {
        let cases = [
            "しない",
            "します",
            "しません",
            "した",
            "しなかった",
            "しました",
            "しませんでした",
            "して",
            "しなくて",
            "される",
            "されない",
            "させる",
            "させない",
            "させられる",
            "させられない",
            "しろ",
            "",
            "しよう",
            "できる",
            "できない",
            "できます",
            "できません",
        ];

        for case in cases {
            assert_deinflects_to(case, "する");
        }
    }

    #[test]
    fn test_containing_katakana() {
        let cases = ["思ッタ", "思イタイ", "思ッテ", "思ワセル", "思ワセラレル"];

        for case in cases {
            assert_deinflects_to(case, "思う");
        }
    }

    #[test]
    fn test_problem_words() {
        assert_deinflects_to("損なわれ", "損なう");
        assert_deinflects_to("阻まれ", "阻む");
    }

    // jp-inflctions unfortunately produces wrong inflections, which is why this is unusable
    // Generate random "verbs" inflect them using 'jp-inflections', and test that they are deinflected correctly
    // proptest! {
    //     #[test]
    //     fn test_godan_inflection_deinflection_roundtrip(base_verb in "(([あ-ん]){1,5}(う|く|ぐ|す|つ|ぬ|ぶ|む|る))"
    //         .prop_filter("not_aru", |v| v != "ある")) {
    //         // Create a base verb
    //         let word = jp_inflections::Word::new(&base_verb, None);
    //         if !word.is_verb() { return Ok(()); }
    //
    //         let verb = match word.into_verb(jp_inflections::VerbType::Godan) {
    //             Ok(v) => v,
    //             Err(_) => return Ok(()),
    //         };
    //
    //         // Generate various inflections
    //         let inflected_forms = vec![
    //         ("dictionary long", verb.dictionary(jp_inflections::WordForm::Long).ok()),
    //
    //         // Negative forms
    //         ("negative short", verb.negative(jp_inflections::WordForm::Short).ok()),
    //         ("negative long", verb.negative(jp_inflections::WordForm::Long).ok()),
    //         ("negative past short", verb.negative_past(jp_inflections::WordForm::Short).ok()),
    //         ("negative past long", verb.negative_past(jp_inflections::WordForm::Long).ok()),
    //
    //         // Te forms
    //         ("te form", verb.te_form().ok()),
    //         ("negative te", verb.negative_te_form().ok()),
    //
    //         // Past forms
    //         ("past short", verb.past(jp_inflections::WordForm::Short).ok()),
    //         ("past long", verb.past(jp_inflections::WordForm::Long).ok()),
    //
    //         // Potential forms
    //         ("potential short", verb.potential(jp_inflections::WordForm::Short).ok()),
    //         ("potential long", verb.potential(jp_inflections::WordForm::Long).ok()),
    //         ("negative potential short", verb.negative_potential(jp_inflections::WordForm::Short).ok()),
    //         ("negative potential long", verb.negative_potential(jp_inflections::WordForm::Long).ok()),
    //
    //         // Passive forms
    //         ("passive", verb.passive().ok()),
    //         ("negative passive", verb.negative_passive().ok()),
    //
    //         // Causative forms
    //         ("causative", verb.causative().ok()),
    //         ("negative causative", verb.negative_causative().ok()),
    //
    //         // Causative-Passive forms
    //         // ("causative passive", verb.causative_passive().ok()),
    //         // ("negative causative passive", verb.negative_causative_passive().ok()),
    //
    //         // Imperative forms
    //         ("imperative", verb.imperative().ok()),
    //         ("negative imperative", verb.imperative_negative().ok()),
    //     ];
    //
    //     for (inflection_type, maybe_inflected) in inflected_forms {
    //         if let Some(inflected) = maybe_inflected {
    //             let deinflections = deinflect(&inflected.kana);
    //             prop_assert!(
    //                 deinflections.iter().map(|d| d.get_word()).any(|w| w == &base_verb),
    //                 "Failed to deinflect '{}' ({}) back to '{}'.\nAll deinflections: {:?}",
    //                 inflected.kana,
    //                 inflection_type,
    //                 base_verb,
    //                 deinflections
    //             );
    //         }
    //     }
    //     }
    // }
}