def romajify(text, system="hepburn"): out = "" katsu = Cutlet(system) for line in text.split("\n"): for chunk in line.split(ZKS): for sent in senter.segment(chunk): out += katsu.romaji(sent) + " " out += ZKS out += "\n" return out
def main(): signal(SIGPIPE, SIG_DFL) system = sys.argv[1] if len(sys.argv) > 1 else 'hepburn' katsu = Cutlet(system) try: for line in fileinput.input([]): print(katsu.romaji(line.strip())) except KeyboardInterrupt: sys.exit(0)
def test_naughty(text): # Goal here is just to not have an exception cut = Cutlet() cut.romaji(text)
def test_empty_string(ja, roma): cut = Cutlet() assert cut.romaji(ja) == roma
def test_romaji_title(ja, roma): cut = Cutlet() assert cut.romaji(ja, title=True) == roma
def test_romaji_non_foreign(ja, roma): cut = Cutlet() cut.use_foreign_spelling = False assert cut.romaji(ja) == roma
def test_romaji_slugs(ja, roma): cut = Cutlet() assert cut.slug(ja) == roma
def test_romaji_kunrei(ja, roma): cut = Cutlet('kunrei') assert cut.romaji(ja) == roma
def test_romaji(ja, roma): cut = Cutlet() assert cut.romaji(ja) == roma
def test_words_kunrei(ja, roma): cut = Cutlet('kunrei') word = cut.tagger.parseToNodeList(ja)[0] assert cut.romaji_word(word) == roma