from typing import Optional class Node: cost: Optional[float] def __init__(self, start_pos, word, yomi): if len(word) == 0: raise AssertionError(f"len(word) should not be 0") self.start_pos = start_pos self.word = word self.yomi = yomi self.prev = None self.cost = 0 def __repr__(self): return f"" def is_bos(self): return self.word == '' def is_eos(self): return self.word == '' def get_key(self) -> str: if self.is_bos(): return '' elif self.is_eos(): return '' else: return f"{self.word}/{self.yomi}"