How to use the pykakasi.kakasi function in pykakasi

To help you get started, we’ve selected a few pykakasi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github miurahr / pykakasi / tests / test_pykakasi.py View on Github external
def test_kakasi_long_symbol_H():
    TESTS = [
        (u'やったー', u'yattaa'),
        (u'でっでー', u'deddee'),
        (u'てんさーふろー', u'tensaafuroo'),
        (u'がっがーん', u'gaggaan'),
        (u'どーん', u'doon')
    ]

    kakasi = pykakasi.kakasi()
    kakasi.setMode('H', 'a')
    converter = kakasi.getConverter()
    for case, result in TESTS:
        print(converter.do(case))
        assert converter.do(case) == result
github miurahr / pykakasi / tests / test_pykakasi_issues.py View on Github external
def test_issues60():
    TESTS = [
        (u"市立", u"しりつ")
    ]
    kakasi = pykakasi.kakasi()
    kakasi.setMode("H", None)
    kakasi.setMode("K", None)
    kakasi.setMode("J", "H")
    kakasi.setMode("s", False)
    kakasi.setMode("C", True)
    kakasi.setMode("E", None)
    kakasi.setMode("a", None)
    converter = kakasi.getConverter()
    for case, result in TESTS:
        assert converter.do(case) == result
github miurahr / pykakasi / tests / test_pykakasi.py View on Github external
def test_kakasi_E2a_upper():
    TESTS = [
        (u"abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
    ]
    kakasi = pykakasi.kakasi()
    kakasi.setMode("E", "a")
    kakasi.setMode("U", True)
    converter = kakasi.getConverter()
    for case, result in TESTS:
        assert converter.do(case) == result
github miurahr / pykakasi / tests / basic_3.py View on Github external
TESTS = [
            ("構成",         "Kousei"),
            ("好き",         "Suki"),
            ("大きい",       "Ookii"),
            ("かんたん",     "kantan"),
            ("にゃ",         "nya"),
            ("っき",         "kki"),
            ("っふぁ",       "ffa"),
            ("漢字とひらがな交じり文", "Kanzi tohiragana Maziri Bun"),
            ("Alphabet 123 and 漢字", "Alphabet 123 and Kanzi"),
            ("日経新聞", "Nikkeisinbun"),
            ("日本国民は、","Nihonkokumin ha,")
        ]

        kakasi = pykakasi.kakasi()
        kakasi.setMode("H","a")
        kakasi.setMode("K","a")
        kakasi.setMode("J","a")
        kakasi.setMode("r","Kunrei")
        kakasi.setMode("C",True)
        kakasi.setMode("s",True)
        kakasi.setMode("E","a")
        converter  = kakasi.getConverter()
        for case, result in TESTS:
            self.assertEqual(converter.do(case), result)
github miurahr / pykakasi / tests / test_pykakasi.py View on Github external
TESTS = [
        (u"", ""),
        (u"構成", "Kousei"),
        (u"好き", "Suki"),
        (u"大きい", "Ookii"),
        (u"かんたん", "kantan"),
        (u"にゃ", "nya"),
        (u"っき", "kki"),
        (u"っふぁ", "ffa"),
        (u"漢字とひらがな交じり文", "Kanzi tohiragana Maziri Bun"),
        (u"Alphabet 123 and 漢字", "Alphabet 123 and Kanzi"),
        (u"日経新聞", "Nikkeisinbun"),
        (u"日本国民は、", "Nihonkokumin ha,")
    ]

    kakasi = pykakasi.kakasi()
    kakasi.setMode("H", "a")
    kakasi.setMode("K", "a")
    kakasi.setMode("J", "a")
    kakasi.setMode("r", "Kunrei")
    kakasi.setMode("E", "a")
    kakasi.setMode("s", True)
    kakasi.setMode("a", None)
    kakasi.setMode("C", True)
    converter = kakasi.getConverter()
    for case, result in TESTS:
        assert converter.do(case) == result
github miurahr / pykakasi / tests / test_pykakasi_issues.py View on Github external
def test_issues59():
    TESTS = [
        (u"じゃーん", u"じゃーん"),
        (u"ヷヸヹヺ", u"ヷヸヹヺ")
    ]
    kakasi = pykakasi.kakasi()
    kakasi.setMode("H", None)
    kakasi.setMode("K", "H")
    kakasi.setMode("J", None)
    kakasi.setMode("s", False)
    kakasi.setMode("C", True)
    kakasi.setMode("E", None)
    kakasi.setMode("a", None)
    converter = kakasi.getConverter()
    for case, result in TESTS:
        assert converter.do(case) == result
github miurahr / pykakasi / tests / test_pykakasi.py View on Github external
def test_kakasi_passport_specialcase():

    TESTS = [
        (u"えっちゅう", "etchu"),
        (u"はっちょう", "hatcho"),
        (u"エッチュウ", "etchu"),
        (u"ハッチョウ", "hatcho")
    ]
    kakasi = pykakasi.kakasi()
    kakasi.setMode("H", "a")
    kakasi.setMode("K", "a")
    kakasi.setMode("J", "a")
    kakasi.setMode("r", "Passport")
    kakasi.setMode("E", "a")
    kakasi.setMode("a", None)
    converter = kakasi.getConverter()
    for case, result in TESTS:
        assert converter.do(case) == result
github miurahr / pykakasi / tests / test_exceptions.py View on Github external
def test_kakasi_unknown_mode():
    with pytest.raises(InvalidModeValueException):
        kakasi = pykakasi.kakasi()
        kakasi.setMode("H", "a")
        kakasi.setMode("K", "a")
        kakasi.setMode("J", "X")
github julesontheroad / NSC_BUILDER / py / ztools / Fs / ChromeNacp.py View on Github external
if i == 2:					
						kakasi = pykakasi.kakasi()
						kakasi.setMode("H", "a")
						kakasi.setMode("K", "a")
						kakasi.setMode("J", "a")
						kakasi.setMode("s", True)
						kakasi.setMode("E", "a")
						kakasi.setMode("a", None)
						kakasi.setMode("C", False)
						converter = kakasi.getConverter()
						title=converter.do(title)	
						title=title[0].upper()+title[1:]
						editor=converter.do(editor)		
						editor=editor[0].upper()+editor[1:]		
					if i == 14 or i == 13 or i==12:					
						kakasi = pykakasi.kakasi()
						kakasi.setMode("H", "a")
						kakasi.setMode("K", "a")
						kakasi.setMode("J", "a")
						kakasi.setMode("s", True)
						kakasi.setMode("E", "a")
						kakasi.setMode("a", None)
						kakasi.setMode("C", False)	
						
				message=("Language: "+str(NacpLanguageType(i)).replace('NacpLanguageType.', ''));feed=self.html_feed(feed,6,message)		
				
				feed+='<ul style="margin-bottom: 2px;margin-top: 3px">'
				message=["Name:",title];feed=self.html_feed(feed,3,message)			
				message=["Publisher:",editor];feed=self.html_feed(feed,3,message)
				feed+='</ul>'						
		return feed
github julesontheroad / NSC_BUILDER / py / ztools / Fs / Nacp.py View on Github external
if i == 2:					
						kakasi = pykakasi.kakasi()
						kakasi.setMode("H", "a")
						kakasi.setMode("K", "a")
						kakasi.setMode("J", "a")
						kakasi.setMode("s", True)
						kakasi.setMode("E", "a")
						kakasi.setMode("a", None)
						kakasi.setMode("C", False)
						converter = kakasi.getConverter()
						title=converter.do(title)	
						title=title[0].upper()+title[1:]
						editor=converter.do(editor)		
						editor=editor[0].upper()+editor[1:]		
					if i == 14 or i == 13 or i==12:					
						kakasi = pykakasi.kakasi()
						kakasi.setMode("H", "a")
						kakasi.setMode("K", "a")
						kakasi.setMode("J", "a")
						kakasi.setMode("s", True)
						kakasi.setMode("E", "a")
						kakasi.setMode("a", None)
						kakasi.setMode("C", False)	
				if gui==True:					
					message=('...............................');print(message);feed+=message+'...............................'*2+'\n'	
					message=('Language: '+ str(NacpLanguageType(i)).replace('NacpLanguageType.', ''));print(message);feed+=message+'\n'				
					message=('...............................');print(message);feed+=message+'...............................'*2+'\n'						
					message=('- Name: '+ title);print(message);feed+=message+'\n'					
					message=('- Publisher: '+ editor);print(message);feed+=message+'\n'
				else:
					message=('...............................');print(message);feed+=message+'\n'		
					message=('Language: '+ str(NacpLanguageType(i)).replace('NacpLanguageType.', ''));print(message);feed+=message+'\n'