From d36cefb50ddf67daa08a221d2de4d3eaae9e2492 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 8 Jul 2023 23:43:14 +0200 Subject: more deinflections --- db/dict/deinflections.sql | 38 ++++++++++++++++++++++++++++++++++++-- db/find.sql | 6 +++--- 2 files changed, 39 insertions(+), 5 deletions(-) (limited to 'db') diff --git a/db/dict/deinflections.sql b/db/dict/deinflections.sql index ff177e2..a6070a8 100644 --- a/db/dict/deinflections.sql +++ b/db/dict/deinflections.sql @@ -15,7 +15,7 @@ insert into deinflection_temp values ('infl:negative', 'しない', 'する', 'a', 's'), ('infl:negative', 'こない', 'くる', 'a', 'k'), ('infl:negative', '来ない', '来る', 'a', 'k'), - ('infl:negative', 'ない', 'ある', 'a', 'ru'), -- this one may cause problems (?) + -- ('infl:negative', 'ない', 'ある', 'a', 'ru'), -- this one may cause problems (?) -- ('infl:negative', 'ない', '', 'a', 'ru'), -- this one may cause problems (?) -- past tense @@ -33,6 +33,7 @@ insert into deinflection_temp values ('infl:tense:past', 'きた', 'くる', 'a', 'k'), ('infl:tense:past', '来た', 'くる', 'a', 'k'), ('infl:tense:past', '行った', '行く', 'a', ''), + ('infl:tense:past', 'かった', 'い', 'a', 'a'), -- past negative -- adjective to adverb ('infl:adverb', 'く', 'い', 'a', 'i'), @@ -104,7 +105,8 @@ insert into deinflection_temp values ('infl:suffix:te', 'って', 'った', 'a', 'u'), ('infl:suffix:te', 'きて', 'きた', 'a', 'k'), ('infl:suffix:te', '来て', '来た', 'a', 'k'), - ('infl:suffix:te', 'くて', 'い', 'a', ''), -- TODO: rules_out of this one is i? + ('infl:suffix:te', 'くて', 'い', 'a', 'a'), + ('infl:suffix:te', 'よくて', 'いい', 'a', 'a'), -- exception -- -tari lists ('infl:suffix:tari', 'たり', 'た', 'a', 'ru'), @@ -120,6 +122,38 @@ insert into deinflection_temp values ('infl:suffix:sa class:noun', 'さ', '', 'a', 'na'), ('infl:suffix:sa class:noun', 'さ', 'い', 'a', 'i'), + -- continuous tense + ('infl:tense:cont', 'いる', '', 'a', 'a'), + + -- potential form + ('infl:potential', 'られる', 'る', 'a', 'ru'), + ('infl:potential', 'える', 'う', 'a', 'u'), + ('infl:potential', 'ける', 'く', 'a', 'u'), + ('infl:potential', 'げる', 'ぐ', 'a', 'u'), + ('infl:potential', 'せる', 'す', 'a', 'u'), + ('infl:potential', 'てる', 'つ', 'a', 'u'), + ('infl:potential', 'ねる', 'ぬ', 'a', 'u'), + ('infl:potential', 'べる', 'ぶ', 'a', 'u'), + ('infl:potential', 'める', 'む', 'a', 'u'), + ('infl:potential', 'れる', 'る', 'a', 'u'), + ('infl:potential', 'できる', 'する', 'a', 's'), + ('infl:potential', 'こられる', 'くる', 'a', 'k'), + ('infl:potential', 'ありうる', 'ある', 'a', ''), -- exception + ('infl:potential', 'ありえる', 'ある', 'a', ''), -- exception + + -- conditionals + ('infl:suffix:ba', 'えば', 'う', 'a', 'u'), + ('infl:suffix:ba', 'けば', 'く', 'a', 'u'), + ('infl:suffix:ba', 'げば', 'ぐ', 'a', 'u'), + ('infl:suffix:ba', 'せば', 'す', 'a', 'u'), + ('infl:suffix:ba', 'てば', 'つ', 'a', 'u'), + ('infl:suffix:ba', 'ねば', 'ぬ', 'a', 'u'), + ('infl:suffix:ba', 'べば', 'ぶ', 'a', 'u'), + ('infl:suffix:ba', 'めば', 'む', 'a', 'u'), + ('infl:suffix:ba', 'れば', 'る', 'a', 'u ru'), + ('infl:suffix:ba', 'ければ', 'い', 'a', 'a'), + -- TODO: 〜であれば (deconjugates to です i think?) + -- auxiliary rules ('class:verb:suru-included', 'する', '', 's', ''); -- deconjugate suru verbs into stem diff --git a/db/find.sql b/db/find.sql index cdaebb3..dd6a011 100644 --- a/db/find.sql +++ b/db/find.sql @@ -49,7 +49,7 @@ with results(id, expression, reading, tags, depth, rules, original, deinflected) (length(term) > 0) limit 50 -- failsafe to catch any infinite loops ) - select term, tags, depth, substr(:term, 1, deinflect.length), rules_out + select term, tags, depth, substr(:term, 1, deinflect.length), rules from deinflect ) select @@ -65,7 +65,7 @@ with results(id, expression, reading, tags, depth, rules, original, deinflected) inner join term on (term.expression = deinflections.term) or (term.reading = deinflections.term) inner join term_tag on term_tag.term_id = term.id inner join tag on term_tag.tag_id = tag.id - group by term.id, deinflections.original + group by term.id, deinflections.original, deinflections.rules having term.id is not null ) select @@ -92,5 +92,5 @@ left join sort_overlay on (user_overlay.expression = results.expression) and (user_overlay.reading = results.reading) and (user_overlay.user_id = (select id from user where username = :user)) -group by results.id, results.original; +group by results.id, results.original, results.rules; -- cgit v1.2.3