jitenbot/bot/entries/jitenon_kotowaza.py

42 lines
1.3 KiB
Python
Raw Normal View History

2023-04-22 22:56:52 +00:00
from bot.entries.jitenon import JitenonEntry
2023-04-11 17:01:23 +00:00
import bot.yomichan.grammar as Grammar
2023-04-10 20:20:33 +00:00
2023-04-22 22:56:52 +00:00
class JitenonKotowazaEntry(JitenonEntry):
2023-04-10 20:20:33 +00:00
columns = {
"言葉": ["expression", ""],
"読み方": ["yomikata", ""],
"意味": ["imi", ""],
"出典": ["shutten", ""],
"例文": ["reibun", ""],
"異形": ["ikei", []],
"類句": ["ruiku", []],
}
def __init__(self, sequence):
2023-04-22 22:56:52 +00:00
super().__init__(sequence)
2023-04-10 20:20:33 +00:00
def yomichan_terms(self):
terms = []
for idx, headword in enumerate(self._headwords()):
(expression, reading) = headword
definition_tags = None
2023-04-22 17:03:00 +00:00
inflection_rules = Grammar.sudachi_rules(expression)
2023-04-10 20:20:33 +00:00
score = -idx
glossary = self.yomichan_glossary
sequence = self.sequence
term_tags = ""
term = [
expression, reading, definition_tags, inflection_rules,
score, glossary, sequence, term_tags
]
terms.append(term)
return terms
2023-04-11 04:41:43 +00:00
def _headwords(self):
if self.expression == "金棒引き・鉄棒引き":
return [["金棒引き", "かなぼうひき"],
["鉄棒引き", "かなぼうひき"]]
else:
2023-04-22 22:56:52 +00:00
return super()._headwords()