jitenbot/bot/yomichan/terms/jitenon.py

68 lines
1.9 KiB
Python
Raw Normal View History

2023-04-23 17:33:42 +00:00
from bot.yomichan.grammar import sudachi_rules
from bot.yomichan.terms.terminator import Terminator
2023-05-06 03:53:17 +00:00
from bot.yomichan.glossary.jitenon import JitenonKokugoGlossary
from bot.yomichan.glossary.jitenon import JitenonYojiGlossary
from bot.yomichan.glossary.jitenon import JitenonKotowazaGlossary
class JitenonTerminator(Terminator):
2023-05-06 21:55:00 +00:00
def __init__(self, target):
super().__init__(target)
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-05-06 03:53:17 +00:00
glossary = self._glossary_maker.make_glossary(entry, self._image_dir)
2023-04-23 05:34:46 +00:00
self._glossary_cache[entry.entry_id] = glossary
return glossary
def _sequence(self, entry):
return entry.entry_id
def _link_glossary_parameters(self, entry):
return []
def _subentry_lists(self, entry):
return []
2023-05-06 03:53:17 +00:00
class JitenonKokugoTerminator(JitenonTerminator):
2023-05-06 21:55:00 +00:00
def __init__(self, target):
super().__init__(target)
2023-05-06 03:53:17 +00:00
self._glossary_maker = JitenonKokugoGlossary()
def _inflection_rules(self, entry, expression):
return sudachi_rules(expression)
def _term_tags(self, entry):
return ""
class JitenonYojiTerminator(JitenonTerminator):
2023-05-06 21:55:00 +00:00
def __init__(self, target):
super().__init__(target)
2023-05-06 03:53:17 +00:00
self._glossary_maker = JitenonYojiGlossary()
def _inflection_rules(self, entry, expression):
return ""
def _term_tags(self, entry):
tags = entry.kankenkyuu.split("/")
return " ".join(tags)
class JitenonKotowazaTerminator(JitenonTerminator):
2023-05-06 21:55:00 +00:00
def __init__(self, target):
super().__init__(target)
2023-05-06 03:53:17 +00:00
self._glossary_maker = JitenonKotowazaGlossary()
def _inflection_rules(self, entry, expression):
2023-04-23 17:33:42 +00:00
return sudachi_rules(expression)
def _term_tags(self, entry):
return ""