From e130e48f28d6547e1daff3605d8cdb27919e08a3 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 8 Nov 2013 11:33:07 -0800 Subject: [PATCH] Adding stub for new deinflector and translator Former-commit-id: 9fa5a50ea34281b02423ec4e31bda123f152a96c --- yomi_base/japanese2/__init__.py | 0 yomi_base/japanese2/data/.gitattributes | 1 + yomi_base/japanese2/data/deinflect.json | 2708 +++++++++++++++++++++++ yomi_base/japanese2/data/dictionary.db | 3 + yomi_base/japanese2/deinflect.py | 89 + 5 files changed, 2801 insertions(+) create mode 100644 yomi_base/japanese2/__init__.py create mode 100644 yomi_base/japanese2/data/.gitattributes create mode 100644 yomi_base/japanese2/data/deinflect.json create mode 100644 yomi_base/japanese2/data/dictionary.db create mode 100644 yomi_base/japanese2/deinflect.py diff --git a/yomi_base/japanese2/__init__.py b/yomi_base/japanese2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/yomi_base/japanese2/data/.gitattributes b/yomi_base/japanese2/data/.gitattributes new file mode 100644 index 0000000..0d9f6ef --- /dev/null +++ b/yomi_base/japanese2/data/.gitattributes @@ -0,0 +1 @@ +*.db filter=lfs diff=lfs merge=lfs -text \ No newline at end of file diff --git a/yomi_base/japanese2/data/deinflect.json b/yomi_base/japanese2/data/deinflect.json new file mode 100644 index 0000000..0dbe229 --- /dev/null +++ b/yomi_base/japanese2/data/deinflect.json @@ -0,0 +1,2708 @@ +{ + "-ba": [ + { + "kanaIn": "えば", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "けば", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "げば", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "せば", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "てば", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ねば", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "べば", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "めば", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "れば", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "v5", + "vk", + "vs-" + ] + }, + { + "kanaIn": "ければ", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + } + ], + "-chau": [ + { + "kanaIn": "ちゃう", + "kanaOut": "る", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いじゃう", + "kanaOut": "ぐ", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "いちゃう", + "kanaOut": "く", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きちゃう", + "kanaOut": "くる", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "しちゃう", + "kanaOut": "す", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しちゃう", + "kanaOut": "する", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "っちゃう", + "kanaOut": "う", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "っちゃう", + "kanaOut": "く", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "っちゃう", + "kanaOut": "つ", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "っちゃう", + "kanaOut": "る", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んじゃう", + "kanaOut": "ぬ", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んじゃう", + "kanaOut": "ぶ", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んじゃう", + "kanaOut": "む", + "tagsIn": [ + "v5" + ], + "tagsOut": [ + "v5" + ] + } + ], + "-nasai": [ + { + "kanaIn": "なさい", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いなさい", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きなさい", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きなさい", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎなさい", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しなさい", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しなさい", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちなさい", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "になさい", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びなさい", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みなさい", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "りなさい", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + } + ], + "-sou": [ + { + "kanaIn": "そう", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + }, + { + "kanaIn": "そう", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いそう", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きそう", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きそう", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎそう", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しそう", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しそう", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちそう", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "にそう", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びそう", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みそう", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "りそう", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + } + ], + "-sugiru": [ + { + "kanaIn": "すぎる", + "kanaOut": "い", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "adj-i" + ] + }, + { + "kanaIn": "すぎる", + "kanaOut": "る", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いすぎる", + "kanaOut": "う", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きすぎる", + "kanaOut": "く", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きすぎる", + "kanaOut": "くる", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎすぎる", + "kanaOut": "ぐ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しすぎる", + "kanaOut": "す", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しすぎる", + "kanaOut": "する", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちすぎる", + "kanaOut": "つ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "にすぎる", + "kanaOut": "ぬ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びすぎる", + "kanaOut": "ぶ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みすぎる", + "kanaOut": "む", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "りすぎる", + "kanaOut": "る", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + } + ], + "-tai": [ + { + "kanaIn": "たい", + "kanaOut": "る", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いたい", + "kanaOut": "う", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きたい", + "kanaOut": "く", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きたい", + "kanaOut": "くる", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎたい", + "kanaOut": "ぐ", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "したい", + "kanaOut": "す", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "したい", + "kanaOut": "する", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちたい", + "kanaOut": "つ", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "にたい", + "kanaOut": "ぬ", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びたい", + "kanaOut": "ぶ", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みたい", + "kanaOut": "む", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "りたい", + "kanaOut": "る", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + } + ], + "-tara": [ + { + "kanaIn": "たら", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いたら", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "いだら", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きたら", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "したら", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "したら", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ったら", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ったら", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ったら", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだら", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだら", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだら", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "かったら", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + } + ], + "-tari": [ + { + "kanaIn": "たり", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いたり", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "いだり", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きたり", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "したり", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "したり", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ったり", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ったり", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ったり", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだり", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだり", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだり", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "かったり", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + } + ], + "-te": [ + { + "kanaIn": "て", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いて", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "いで", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きて", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "くて", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + }, + { + "kanaIn": "して", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "して", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "って", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "って", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "って", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "って", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んで", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んで", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んで", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + } + ], + "-zu": [ + { + "kanaIn": "ず", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "かず", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "がず", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "こず", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "さず", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "せず", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "たず", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "なず", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ばず", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "まず", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "らず", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "わず", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + } + ], + "adv": [ + { + "kanaIn": "く", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + } + ], + "causative": [ + { + "kanaIn": "かせる", + "kanaOut": "く", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "がせる", + "kanaOut": "ぐ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "させる", + "kanaOut": "する", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "させる", + "kanaOut": "る", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "たせる", + "kanaOut": "つ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "なせる", + "kanaOut": "ぬ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ばせる", + "kanaOut": "ぶ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ませる", + "kanaOut": "む", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "らせる", + "kanaOut": "る", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "わせる", + "kanaOut": "う", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "こさせる", + "kanaOut": "くる", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "vk" + ] + } + ], + "imperative": [ + { + "kanaIn": "い", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "え", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "け", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "げ", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "せ", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "て", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ね", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "べ", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "め", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "よ", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "れ", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ろ", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "こい", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "しろ", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "せよ", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + } + ], + "imperative negative": [ + { + "kanaIn": "な", + "kanaOut": "", + "tagsIn": [], + "tagsOut": [ + "v1", + "v5", + "vk", + "vs-" + ] + } + ], + "masu stem": [ + { + "kanaIn": "い", + "kanaOut": "いる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "い", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "え", + "kanaOut": "える", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "き", + "kanaOut": "きる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "き", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ぎ", + "kanaOut": "ぎる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "ぎ", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "け", + "kanaOut": "ける", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "げ", + "kanaOut": "げる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "し", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "じ", + "kanaOut": "じる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "せ", + "kanaOut": "せる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "ぜ", + "kanaOut": "ぜる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "ち", + "kanaOut": "ちる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "ち", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "て", + "kanaOut": "てる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "で", + "kanaOut": "でる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "に", + "kanaOut": "にる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "に", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ね", + "kanaOut": "ねる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "ひ", + "kanaOut": "ひる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "び", + "kanaOut": "びる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "び", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "へ", + "kanaOut": "へる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "べ", + "kanaOut": "べる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "み", + "kanaOut": "みる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "み", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "め", + "kanaOut": "める", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "り", + "kanaOut": "りる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + }, + { + "kanaIn": "り", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "れ", + "kanaOut": "れる", + "tagsIn": [], + "tagsOut": [ + "v1" + ] + } + ], + "negative": [ + { + "kanaIn": "ない", + "kanaOut": "る", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "かない", + "kanaOut": "く", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "がない", + "kanaOut": "ぐ", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "くない", + "kanaOut": "い", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "adj-i" + ] + }, + { + "kanaIn": "こない", + "kanaOut": "くる", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "さない", + "kanaOut": "す", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しない", + "kanaOut": "する", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "たない", + "kanaOut": "つ", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "なない", + "kanaOut": "ぬ", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ばない", + "kanaOut": "ぶ", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "まない", + "kanaOut": "む", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "らない", + "kanaOut": "る", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "わない", + "kanaOut": "う", + "tagsIn": [ + "adj-i" + ], + "tagsOut": [ + "v5" + ] + } + ], + "noun": [ + { + "kanaIn": "さ", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + } + ], + "passive": [ + { + "kanaIn": "かれる", + "kanaOut": "く", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "がれる", + "kanaOut": "ぐ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "される", + "kanaOut": "する", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "たれる", + "kanaOut": "つ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "なれる", + "kanaOut": "ぬ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ばれる", + "kanaOut": "ぶ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "まれる", + "kanaOut": "む", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "われる", + "kanaOut": "う", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + } + ], + "passive or causative": [ + { + "kanaIn": "される", + "kanaOut": "す", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + } + ], + "past": [ + { + "kanaIn": "た", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いた", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "いだ", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きた", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "した", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "した", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "った", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "った", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "った", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "った", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだ", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだ", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "んだ", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "かった", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + } + ], + "polite": [ + { + "kanaIn": "ます", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "います", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きます", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きます", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎます", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "します", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "します", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちます", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "にます", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びます", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みます", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ります", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + } + ], + "polite negative": [ + { + "kanaIn": "ません", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いません", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きません", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きません", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎません", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しません", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しません", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちません", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "にません", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びません", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みません", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "りません", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "くありません", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + } + ], + "polite past": [ + { + "kanaIn": "ました", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いました", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きました", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きました", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎました", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しました", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しました", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちました", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "にました", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びました", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みました", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "りました", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + } + ], + "polite past negative": [ + { + "kanaIn": "ませんでした", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いませんでした", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きませんでした", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きませんでした", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎませんでした", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しませんでした", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しませんでした", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちませんでした", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "にませんでした", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びませんでした", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みませんでした", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "りませんでした", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "くありませんでした", + "kanaOut": "い", + "tagsIn": [], + "tagsOut": [ + "adj-i" + ] + } + ], + "polite volitional": [ + { + "kanaIn": "ましょう", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "いましょう", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きましょう", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "きましょう", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "ぎましょう", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しましょう", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "しましょう", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + }, + { + "kanaIn": "ちましょう", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "にましょう", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "びましょう", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "みましょう", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "りましょう", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + } + ], + "potential": [ + { + "kanaIn": "える", + "kanaOut": "う", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ける", + "kanaOut": "く", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "げる", + "kanaOut": "ぐ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "せる", + "kanaOut": "す", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "てる", + "kanaOut": "つ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ねる", + "kanaOut": "ぬ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "べる", + "kanaOut": "ぶ", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "める", + "kanaOut": "む", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "れる", + "kanaOut": "る", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v1", + "v5", + "vk" + ] + }, + { + "kanaIn": "これる", + "kanaOut": "くる", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "vk" + ] + } + ], + "potential or passive": [ + { + "kanaIn": "られる", + "kanaOut": "る", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "v1", + "v5", + "vk" + ] + }, + { + "kanaIn": "こられる", + "kanaOut": "くる", + "tagsIn": [ + "v1" + ], + "tagsOut": [ + "vk" + ] + } + ], + "volitional": [ + { + "kanaIn": "おう", + "kanaOut": "う", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "こう", + "kanaOut": "く", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ごう", + "kanaOut": "ぐ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "そう", + "kanaOut": "す", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "とう", + "kanaOut": "つ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "のう", + "kanaOut": "ぬ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "ぼう", + "kanaOut": "ぶ", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "もう", + "kanaOut": "む", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "よう", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v1", + "vk" + ] + }, + { + "kanaIn": "ろう", + "kanaOut": "る", + "tagsIn": [], + "tagsOut": [ + "v5" + ] + }, + { + "kanaIn": "こよう", + "kanaOut": "くる", + "tagsIn": [], + "tagsOut": [ + "vk" + ] + }, + { + "kanaIn": "しよう", + "kanaOut": "する", + "tagsIn": [], + "tagsOut": [ + "vs-" + ] + } + ] +} diff --git a/yomi_base/japanese2/data/dictionary.db b/yomi_base/japanese2/data/dictionary.db new file mode 100644 index 0000000..971da66 --- /dev/null +++ b/yomi_base/japanese2/data/dictionary.db @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50737c19f1e501b771e429e944a8bbf24551c97a9047eb013175c8c20295539d +size 20406272 diff --git a/yomi_base/japanese2/deinflect.py b/yomi_base/japanese2/deinflect.py new file mode 100644 index 0000000..45db449 --- /dev/null +++ b/yomi_base/japanese2/deinflect.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- + +# +# Copyright (C) 2011 Alex Yatskov +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import codecs +import json + + +# +# Deinflection +# + +class Deinflection: + def __init__(self, term, tags=list(), rule=str()): + self.children = list() + self.term = term + self.tags = tags + self.rule = rule + + + def deinflect(self, validator, rules): + for rule, variants in rules.items(): + for variant in variants: + tagsIn = variant['tagsIn'] + tagsOut = variant['tagsOut'] + kanaIn = variant['kanaIn'] + kanaOut = variant['kanaOut'] + + for i in xrange(len(kanaIn), len(self.term) + 1): + term = self.term[:i] + + allowed = not self.tags + for tag in self.tags: + if tag in tagsIn: + allowed = True + + if allowed and term.endswith(kanaIn): + rebase = term[:-len(kanaIn)] + kanaOut + if validator(rebase, self.tags): + child = Deinflection(rebase, tagsOut, rule) + self.children.append(child) + child.deinflect(validator, rules) + + + def dump(self, depth=0): + result = u'%s%s' % (u'\t' * depth, self.term) + if self.rule: + result += u' (%s)' % self.rule + result += u'\n' + + for child in self.children: + result += child.dump(depth + 1) + + return result + + + def __str__(self): + return self.dump() + + +# +# Deinflector +# + +class Deinflector: + def __init__(self, filename): + with codecs.open(filename, 'rb', 'utf-8') as fp: + self.rules = json.load(fp) + + + def deinflect(self, term, validator=lambda term, tags: True): + node = Deinflection(term) + node.deinflect(validator, self.rules) + return node