2023-04-23 17:33:42 +00:00
|
|
|
from bot.yomichan.grammar import sudachi_rules
|
2023-04-23 01:26:54 +00:00
|
|
|
from bot.yomichan.terms.terminator import Terminator
|
|
|
|
from bot.yomichan.glossary.jitenon import make_glossary
|
|
|
|
|
|
|
|
|
|
|
|
class JitenonTerminator(Terminator):
|
2023-05-01 22:31:28 +00:00
|
|
|
def __init__(self, name):
|
|
|
|
super().__init__(name)
|
2023-04-23 01:26:54 +00:00
|
|
|
|
|
|
|
def _definition_tags(self, entry):
|
|
|
|
return None
|
|
|
|
|
|
|
|
def _glossary(self, entry):
|
2023-04-23 05:34:46 +00:00
|
|
|
if entry.entry_id in self._glossary_cache:
|
|
|
|
return self._glossary_cache[entry.entry_id]
|
2023-04-23 01:26:54 +00:00
|
|
|
glossary = make_glossary(entry)
|
2023-04-23 05:34:46 +00:00
|
|
|
self._glossary_cache[entry.entry_id] = glossary
|
2023-04-23 01:26:54 +00:00
|
|
|
return glossary
|
|
|
|
|
|
|
|
def _sequence(self, entry):
|
|
|
|
return entry.entry_id
|
|
|
|
|
|
|
|
def _link_glossary_parameters(self, entry):
|
|
|
|
return []
|
|
|
|
|
|
|
|
def _subentry_lists(self, entry):
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
class JitenonYojiTerminator(JitenonTerminator):
|
2023-05-01 22:31:28 +00:00
|
|
|
def __init__(self, name):
|
|
|
|
super().__init__(name)
|
2023-04-23 01:26:54 +00:00
|
|
|
|
|
|
|
def _inflection_rules(self, entry, expression):
|
|
|
|
return ""
|
|
|
|
|
|
|
|
def _term_tags(self, entry):
|
2023-04-23 05:17:42 +00:00
|
|
|
tags = entry.kankenkyuu.split("/")
|
2023-04-23 01:26:54 +00:00
|
|
|
return " ".join(tags)
|
|
|
|
|
|
|
|
|
|
|
|
class JitenonKotowazaTerminator(JitenonTerminator):
|
2023-05-01 22:31:28 +00:00
|
|
|
def __init__(self, name):
|
|
|
|
super().__init__(name)
|
2023-04-23 01:26:54 +00:00
|
|
|
|
|
|
|
def _inflection_rules(self, entry, expression):
|
2023-04-23 17:33:42 +00:00
|
|
|
return sudachi_rules(expression)
|
2023-04-23 01:26:54 +00:00
|
|
|
|
|
|
|
def _term_tags(self, entry):
|
|
|
|
return ""
|