From 4e04fbe99749bd83c0be301d7f3b26f0c4e49ecb Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Wed, 11 Apr 2012 06:30:19 -0400 Subject: [PATCH 1/6] Initial, etc --- LICENSE | 21 +++ jTransliterate/__init__.py | 254 +++++++++++++++++++++++++++++ jTransliterate/test.py | 30 ++++ jTransliterate/translation_maps.py | 128 +++++++++++++++ readme.md | 57 +++++++ setup.py | 34 ++++ 6 files changed, 524 insertions(+) create mode 100644 LICENSE create mode 100644 jTransliterate/__init__.py create mode 100644 jTransliterate/test.py create mode 100644 jTransliterate/translation_maps.py create mode 100644 readme.md create mode 100644 setup.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cd5b253 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2009 - 2010 Ryan McGrath + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/jTransliterate/__init__.py b/jTransliterate/__init__.py new file mode 100644 index 0000000..9f388f7 --- /dev/null +++ b/jTransliterate/__init__.py @@ -0,0 +1,254 @@ +# -*- coding: utf-8 -*- +#!/usr/bin/python + +__author__ = "Ryan McGrath " +__version__ = "1.0" + +""" + A class that allows for easy transliteration of [Hirag/Katak]ana + and English/Latin. Much of the work here is inspired/inherited/etc + from Kim Ahlström and his work on "Ve", built in Ruby. + + Credit where credit is due: + https://github.com/Kimtaro/ve/blob/master/lib/providers/japanese_transliterators.rb +""" + +import re + +# Lookup tables for character conversions. Much of this is borrowed from the work of +# Kim Ahlström and Ve: https://github.com/Kimtaro/ve/ +# +# Ve's Transliterators are written in Ruby, and I wanted Python. Consider it a nice port. ;) +from translation_maps import H_SYLLABIC_N, H_SMALL_TSU, HIRA_TO_LATN, LATN_TO_HIRA + +def defaultToSelfText(fn): + """ + A fun little decorator that makes it so we can default to + the text stored on a class instance, but also let people just + instantiate and re-use calls while supplying new text. Whee. + """ + def wrapper(self, text = None): + if text is None: + text = self.text + + return fn(self, text = text) + + return wrapper + +class JapaneseTransliterator(object): + def __init__(self, text): + """__init__(self, text) + + JapaneseTransliterator("fadjfnjsfnjsafnjsdnf") + + I envisioned storing the original text on the instantiated object + itself, and allowing it to be overridden on a per-function-call basis. + + So I did. + + Parameters: + text - Text to be operated on. Unicode please! + """ + self.text = text + + @defaultToSelfText + def transliterate_from_hrkt_to_latn(self, text): + """transliterate_from_hrkt_to_latn(self, text) + + Transliterates from [Hirag/Katak]ana to Latin/En. + + Parameters: + text - Optional. Use different text than what's on + the class instance. + """ + text = self.transliterate_from_kana_to_hira(text) + return self.transliterate_from_hira_to_latn(text) + + @defaultToSelfText + def transliterate_from_hira_to_latn(self, text): + """transliterate_from_hira_to_latn(self, text) + + Transliterates from Hiragana to Latin/En. Phonetics, that is. + + Parameters: + text - Optional. Use different text than what's on + the class instance. + """ + # Decode once, not twice + _H_SMALL_TSU = H_SMALL_TSU.decode('utf-8') + _H_SYLLABIC_N = H_SYLLABIC_N.decode('utf-8') + + kana = (text * 1).decode('utf-8') + romaji = '' + geminate = False + + index = 0 + klength = len(kana) + + while klength > 0: + for length in [2, 1]: + mora = '' + for_conversion = kana[index:(index + length)] + + if for_conversion == _H_SMALL_TSU: + geminate = True + index += length + klength -= length + break + + elif for_conversion == _H_SYLLABIC_N and re.match(u'[\u3084-\u3088]', kana[(index + 1):(index + 2)]): + # Syllabic N before ya, yu or yo + mora = "n'" + elif for_conversion in HIRA_TO_LATN: + mora = HIRA_TO_LATN[for_conversion] + + if len(mora) > 0: + if geminate: + geminate = False + romaji += mora[index:index + 1] + + romaji += mora + index += length + klength -= length + break + elif length == 1: + romaji += for_conversion + index += length + klength -= length + + return romaji + + @defaultToSelfText + def transliterate_from_latn_to_hrkt(self, text): + """transliterate_from_latn_to_hrkt(self, text) + + Transliterates from Latin/En to Hiragana (mostly). + + Parameters: + text - Optional. Use different text than what's on + the class instance. + """ + # Duplicate the text... + romaji = text * 1 + kana = '' + + romaji = re.sub('/m([BbPp])/', 'n\1', romaji) + romaji = re.sub('/M([BbPp])/', 'N\1', romaji) + + index = 0 + rlength = len(romaji) - 1 + + while rlength > 0: + for for_removal in [3, 2, 1]: + mora = '' + for_conversion = romaji[index:(index + for_removal)] + is_upper = True if re.search('[A-Z][^A-Z]*', for_conversion) else False + for_conversion = for_conversion.lower() + + if re.match('/nn[aiueo]/', for_conversion): + mora = H_SYLLABIC_N + for_removal = 1 + elif for_conversion in LATN_TO_HIRA: + mora = LATN_TO_HIRA[for_conversion] + elif for_conversion == 'tch' or (for_removal == 2 and re.match('/([kgsztdnbpmyrlwc])\1/', for_conversion)): + mora = H_SMALL_TSU + for_removal = 1 + + if mora != '': + if is_upper: + kana += self.transliterate_from_hira_to_kana(text = (mora * 1)) + else: + kana += mora + + index += for_removal + rlength -= for_removal + break + elif for_removal == 1: + kana += for_conversion + index += 1 + rlength -= 1 + + return kana + + @defaultToSelfText + def transliterate_from_kana_to_hira(self, text): + """transliterate_from_kana_to_hira(self, text) + + Transliterates from Katakana to Hiragana. + + Parameters: + text - Optional. Use different text than what's on + the class instance. + """ + return JapaneseTransliterator.transpose_codepoints_in_range(text, -96, 12449, 12534) + + @defaultToSelfText + def transliterate_from_hira_to_kana(self, text): + """transliterate_from_hira_to_kana(self, text) + + Transliterates from Hiragana to Katakana. + + Parameters: + text - Optional. Use different text than what's on + the class instance. + """ + return JapaneseTransliterator.transpose_codepoints_in_range(text, 96, 12353, 12438) + + @defaultToSelfText + def transliterate_from_fullwidth_to_halfwidth(self, text): + """transliterate_from_fullwidth_to_halfwidth(self, text) + + Transliterates from full-width to half-width. + + Parameters: + text - Optional. Use different text than what's on + the class instance. + """ + text = JapaneseTransliterator.transpose_codepoints_in_range(text, -65248, 65281, 65374) + return JapaneseTransliterator.transpose_codepoints_in_range(text, -12256, 12288, 12288) + + @defaultToSelfText + def transliterate_from_halfwidth_to_fullwidth(self, text): + """transliterate_from_fullwidth_to_halfwidth(self, text) + + Transliterates from half-width to full-width. + + Parameters: + text - Optional. Use different text than what's on + the class instance. + """ + text = JapaneseTransliterator.transpose_codepoints_in_range(text, 65248, 33, 126) + return JapaneseTransliterator.transpose_codepoints_in_range(text, 12256, 32, 32) + + @staticmethod + def transpose_codepoints_in_range(text, distance, range_start, range_end): + """JapaneseTransliterator.transpose_codepoints_in_range(text, distance, range_start, range_end) + + Given a set of text (unicode...), coupled with distance and range, transposes + it for a corresponding swap and returns the new set. + + Parameters: + text - text to be transposed, codepoint-wise + distance - to the other side of the map + range_start - start of the range we're interested in, codepont-wise + range_end - end of the range we're interested in, codepoint-wise + + Returns: + string, text, etc + """ + if not isinstance(text, unicode): + # Python will raise a UnicodeEncodeError here if there are any + # outstanding issues, otherwise things should be fine. *shrug* + text = unicode(text, 'utf-8') + + transposed_text = u'' + codepoints = map(lambda char: ord(char), list(text)) + + for codepoint in codepoints: + print codepoint + if codepoint >= range_start and codepoint <= range_end: + transposed_text += unichr(codepoint + distance) + else: + transposed_text += unichr(codepoint) + + return transposed_text \ No newline at end of file diff --git a/jTransliterate/test.py b/jTransliterate/test.py new file mode 100644 index 0000000..79b710c --- /dev/null +++ b/jTransliterate/test.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +from __init__ import JapaneseTransliterator + +# Transliterate from Latin/English to [Hirag/Katak]ana +x = JapaneseTransliterator('kanazawa') +print x.transliterate_from_latn_to_hrkt() +# Should print "かなざわ" + +# Transliterate from Hiragana to Latin/English +b = JapaneseTransliterator('かなざわ') +print b.transliterate_from_hira_to_latn() +# Should print "kanazawa" + +# Transliterate from either Hiragana or Katakana to Latin/English +print b.transliterate_from_hrkt_to_latn(text = 'カナザワ') +# Should print "kanazawa" + +# Transliterate from Katakan to Hiragana (You... probably never need to do this) +print b.transliterate_from_kana_to_hira(text = 'キットカート') +# Should print "きっとかーと" + +# Transliterate from Hiragana to Katakana +print b.transliterate_from_hira_to_kana(text = 'かなざわ') +# Should print "カナザワ" + +# If you want to convert between half/full width kana, you can use the following +# functions. I didn't care enough to do demos here. ;| +b.transliterate_from_halfwidth_to_fullwidth() +b.transliterate_from_fullwidth_to_halfwidth() diff --git a/jTransliterate/translation_maps.py b/jTransliterate/translation_maps.py new file mode 100644 index 0000000..7a89963 --- /dev/null +++ b/jTransliterate/translation_maps.py @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- + +H_SYLLABIC_N= 'ん' +H_SMALL_TSU = 'っ' + +""" + +Python sucks with regards to unicode-fun, but I'm leaving this here as +a fun reference for anyone deciphering all this. Enjoy. -- Ryan + +HIRA_TO_LATN = { + "あ":"a", "い":"i", "う":"", "え":"e", "お":"o", + "か":"ka", "き":"ki", "く":"k", "け":"ke", "こ":"ko", + "が":"ga", "ぎ":"gi", "ぐ":"g", "げ":"ge", "ご":"go", + "さ":"sa", "し":"shi", "す":"s", "せ":"se", "そ":"so", + "ざ":"za", "じ":"ji", "ず":"z", "ぜ":"ze", "ぞ":"zo", + "た":"ta", "ち":"chi", "つ":"ts", "て":"te", "と":"to", + "だ":"da", "ぢ":"ji", "づ":"z", "で":"de", "ど":"do", + "な":"na", "に":"ni", "ぬ":"n", "ね":"ne", "の":"no", + "は":"ha", "ひ":"hi", "ふ":"f", "へ":"he", "ほ":"ho", + "ば":"ba", "び":"bi", "ぶ":"b", "べ":"be", "ぼ":"bo", + "ぱ":"pa", "ぴ":"pi", "ぷ":"p", "ぺ":"pe", "ぽ":"po", + "ま":"ma", "み":"mi", "む":"m", "め":"me", "も":"mo", + "や":"ya", "ゆ":"y", "よ":"yo", + "ら":"ra", "り":"ri", "る":"r", "れ":"re", "ろ":"ro", + "わ":"wa", "うぃ":"whi", "うぇ":"whe", "を":"wo", + "ゑ":"wye", "ゐ":"wyi", "ー":"-", "ん":"n", + + "きゃ":"kya", "きゅ":"ky", "きょ":"kyo", "きぇ":"kye", "きぃ":"kyi", + "ぎゃ":"gya", "ぎゅ":"gy", "ぎょ":"gyo", "ぎぇ":"gye", "ぎぃ":"gyi", + "くぁ":"kwa", "くぃ":"kwi", "くぅ":"kw", "くぇ":"kwe", "くぉ":"kwo", + "ぐぁ":"qwa", "ぐぃ":"gwi", "ぐぅ":"gw", "ぐぇ":"gwe", "ぐぉ":"gwo", + "しゃ":"sha", "しぃ":"syi", "しゅ":"sh", "しぇ":"she", "しょ":"sho", + "じゃ":"jya", "じゅ":"zy", "じぇ":"zye", "じょ":"zyo", "じぃ":"zyi", + "すぁ":"swa", "すぃ":"swi", "すぅ":"sw", "すぇ":"swe", "すぉ":"swo", + "ちゃ":"tya", "ちゅ":"ty", "ちぇ":"tye", "ちょ":"tyo", "ちぃ":"tyi", + "ぢゃ":"dya", "ぢぃ":"dyi", "ぢゅ":"dy", "ぢぇ":"dye", "ぢょ":"dyo", + "つぁ":"tsa", "つぃ":"tsi", "つぇ":"tse", "つぉ":"tso", "てゃ":"tha", + "てぃ":"thi", "てゅ":"th", "てぇ":"the", "てょ":"tho", "とぁ":"twa", + "とぃ":"twi", "とぅ":"tw", "とぇ":"twe", "とぉ":"two", "でゃ":"dha", + "でぃ":"dhi", "でゅ":"dh", "でぇ":"dhe", "でょ":"dho", "どぁ":"dwa", + "どぃ":"dwi", "どぅ":"dw", "どぇ":"dwe", "どぉ":"dwo", "にゃ":"nya", + "にゅ":"ny", "にょ":"nyo", "にぇ":"nye", "にぃ":"nyi", "ひゃ":"hya", + "ひぃ":"hyi", "ひゅ":"hy", "ひぇ":"hye", "ひょ":"hyo", "びゃ":"bya", + "びぃ":"byi", "びゅ":"by", "びぇ":"bye", "びょ":"byo", "ぴゃ":"pya", + "ぴぃ":"pyi", "ぴゅ":"py", "ぴぇ":"pye", "ぴょ":"pyo", "ふぁ":"fwa", + "ふぃ":"fyi", "ふぇ":"fye", "ふぉ":"fwo", "ふぅ":"fw", "ふゃ":"fya", + "ふゅ":"fy", "ふょ":"fyo", "みゃ":"mya", "みぃ":"myi", "みゅ":"my", + "みぇ":"mye", "みょ":"myo", "りゃ":"rya", "りぃ":"ryi", "りゅ":"ry", + "りぇ":"rye", "りょ":"ryo", + "ゔぁ":"va", "ゔぃ":"vyi", "ゔ":"v", "ゔぇ":"vye", "ゔぉ":"vo", + "ゔゃ":"vya", "ゔゅ":"vy", "ゔょ":"vyo", + "うぁ":"wha", "いぇ":"ye", "うぉ":"who", + "ぁ":"xa", "ぃ":"xi", "ぅ":"x", "ぇ":"xe", "ぉ":"xo", + "ゕ":"xka", "ゖ":"xke", "ゎ":"xwa" +} +""" +HIRA_TO_LATN = {u'\u3057\u3047': 'she', u'\u3057\u3043': 'syi', u'\u308b': 'ru', u'\u3093': 'n', u'\u3074\u3047': 'pye', u'\u3074\u3043': 'pyi', u'\u304d\u3085': 'kyu', u'\u304d\u3087': 'kyo', u'\u304d\u3083': 'kya', u'\u3067\u3047': 'dhe', u'\u3050\u3041': 'qwa', u'\u3067\u3043': 'dhi', u'\u3094\u3087': 'vyo', u'\u308a\u3043': 'ryi', u'\u3094\u3083': 'vya', u'\u3048': 'e', u'\u3050': 'gu', u'\u3058': 'ji', u'\u3060': 'da', u'\u3064\u3049': 'tso', u'\u3064\u3047': 'tse', u'\u3064\u3043': 'tsi', u'\u3064\u3041': 'tsa', u'\u3070': 'ba', u'\u3078': 'he', u'\u3080': 'mu', u'\u3088': 'yo', u'\u3043': 'xi', u'\u3090': 'wyi', u'\u3050\u3043': 'gwi', u'\u3072': 'hi', u'\u3050\u3047': 'gwe', u'\u3050\u3045': 'gwu', u'\u3050\u3049': 'gwo', u'\u3057\u3087': 'sho', u'\u3057\u3085': 'shu', u'\u3057\u3083': 'sha', u'\u304b': 'ka', u'\u3053': 'ko', u'\u3074\u3087': 'pyo', u'\u305b': 'se', u'\u3074\u3085': 'pyu', u'\u3074\u3083': 'pya', u'\u304d\u3047': 'kye', u'\u3068\u3041': 'twa', u'\u304d\u3043': 'kyi', u'\u306b': 'ni', u'\u3067\u3087': 'dho', u'\u3067\u3085': 'dhu', u'\u3067\u3083': 'dha', u'\u3094\u3049': 'vo', u'\u3094\u3047': 'vye', u'\u307b': 'ho', u'\u3094\u3043': 'vyi', u'\u3094\u3041': 'va', u'\u3081': 'me', u'\u3089': 'ra', u'\u3091': 'wye', u'\u3046\u3041': 'wha', u'\u3046\u3043': 'whi', u'\u3046\u3047': 'whe', u'\u3073\u3083': 'bya', u'\u3046\u3049': 'who', u'\u3073\u3087': 'byo', u'\u3073\u3085': 'byu', u'\u3066\u3083': 'tha', u'\u3066\u3085': 'thu', u'\u3066\u3087': 'tho', u'\u3046': 'u', u'\u304e': 'gi', u'\u3056': 'za', u'\u308a\u3047': 'rye', u'\u305e': 'zo', u'\u3094\u3085': 'vyu', u'\u3066': 'te', u'\u306e': 'no', u'\u3076': 'bu', u'\u307e': 'ma', u'\u3059\u3049': 'swo', u'\u3086': 'yu', u'\u3059\u3041': 'swa', u'\u3059\u3043': 'swi', u'\u3059\u3045': 'swu', u'\u3059\u3047': 'swe', u'\u308e': 'xwa', u'\u3096': 'xke', u'\u308a\u3085': 'ryu', u'\u308a\u3087': 'ryo', u'\u308a\u3083': 'rya', u'\u3073': 'bi', u'\u3069\u3049': 'dwo', u'\u3069\u3041': 'dwa', u'\u3069\u3043': 'dwi', u'\u3069\u3045': 'dwu', u'\u3069\u3047': 'dwe', u'\u3041': 'xa', u'\u3049': 'xo', u'\u3051': 'ke', u'\u3073\u3043': 'byi', u'\u3073\u3047': 'bye', u'\u3061': 'chi', u'\u3069': 'do', u'\u3071': 'pa', u'\u3066\u3043': 'thi', u'\u3066\u3047': 'the', u'\u3079': 'be', u'\u308f': 'wa', u'\u3062\u3085': 'dyu', u'\u3062\u3087': 'dyo', u'\u3062\u3083': 'dya', u'\u307f\u3087': 'myo', u'\u307f\u3085': 'myu', u'\u307f\u3083': 'mya', u'\u3044': 'i', u'\u304c': 'ga', u'\u3072\u3085': 'hyu', u'\u3072\u3087': 'hyo', u'\u3054': 'go', u'\u3072\u3083': 'hya', u'\u305c': 'ze', u'\u3064': 'tsu', u'\u304f\u3049': 'kwo', u'\u304f\u3047': 'kwe', u'\u304f\u3045': 'kwu', u'\u304f\u3043': 'kwi', u'\u306c': 'nu', u'\u304f\u3041': 'kwa', u'\u3074': 'pi', u'\u3068': 'to', u'\u307c': 'bo', u'\u3084': 'ya', u'\u308c': 're', u'\u3072\u3047': 'hye', u'\u3094': 'vu', u'\u3072\u3043': 'hyi', u'\u3045': 'xu', u'\u3047': 'xe', u'\u304f': 'ku', u'\u3057': 'shi', u'\u305f': 'ta', u'\u3062\u3047': 'dye', u'\u3067': 'de', u'\u3062\u3043': 'dyi', u'\u306f': 'ha', u'\u3077': 'pu', u'\u307f\u3047': 'mye', u'\u307f\u3043': 'myi', u'\u30fc': '-', u'\u307f': 'mi', u'\u306b\u3083': 'nya', u'\u306b\u3087': 'nyo', u'\u306b\u3085': 'nyu', u'\u308d': 'ro', u'\u3059': 'su', u'\u3095': 'xka', u'\u304e\u3043': 'gyi', u'\u304e\u3047': 'gye', u'\u3042': 'a', u'\u3058\u3043': 'zyi', u'\u304a': 'o', u'\u3058\u3047': 'zye', u'\u3052': 'ge', u'\u3075\u3049': 'fwo', u'\u3075\u3045': 'fwu', u'\u3075\u3047': 'fye', u'\u305a': 'zu', u'\u3075\u3041': 'fwa', u'\u3075\u3043': 'fyi', u'\u3061\u3083': 'tya', u'\u3062': 'ji', u'\u3061\u3085': 'tyu', u'\u3061\u3087': 'tyo', u'\u306a': 'na', u'\u3044\u3047': 'ye', u'\u3068\u3049': 'two', u'\u3068\u3043': 'twi', u'\u307a': 'pe', u'\u3068\u3047': 'twe', u'\u3068\u3045': 'twu', u'\u3082': 'mo', u'\u3058\u3083': 'jya', u'\u308a': 'ri', u'\u3058\u3087': 'zyo', u'\u3058\u3085': 'zyu', u'\u3092': 'wo', u'\u3075\u3085': 'fyu', u'\u3075\u3087': 'fyo', u'\u3075\u3083': 'fya', u'\u3061\u3043': 'tyi', u'\u3061\u3047': 'tye', u'\u306b\u3043': 'nyi', u'\u306b\u3047': 'nye', u'\u304d': 'ki', u'\u3055': 'sa', u'\u305d': 'so', u'\u3065': 'zu', u'\u304e\u3083': 'gya', u'\u306d': 'ne', u'\u304e\u3085': 'gyu', u'\u304e\u3087': 'gyo', u'\u3075': 'fu', u'\u307d': 'po'} + +LATN_TO_HIRA = { + 'a': 'あ', 'i': 'い', 'u': 'う', 'e': 'え', 'o': 'お', + 'ka': 'か', 'ki': 'き', 'ku': 'く', 'ke': 'け', 'ko': 'こ', + 'ga': 'が', 'gi': 'ぎ', 'gu': 'ぐ', 'ge': 'げ', 'go': 'ご', + 'sa': 'さ', 'si': 'し', 'shi': 'し', 'su': 'す', 'se': 'せ', 'so': 'そ', + 'za': 'ざ', 'zi': 'じ', 'ji': 'じ', 'zu': 'ず', 'ze': 'ぜ', 'zo': 'ぞ', + 'ta': 'た', 'ti': 'ち', 'chi': 'ち', 'tu': 'つ', 'tsu': 'つ', 'te': 'て','to': 'と', + 'da': 'だ', 'di': 'ぢ', 'du': 'づ', 'dzu': 'づ', 'de': 'で','do': 'ど', + 'na': 'な', 'ni': 'に', 'nu': 'ぬ','ne': 'ね','no': 'の', + 'ha': 'は', 'hi': 'ひ', 'hu': 'ふ', 'fu': 'ふ', 'he': 'へ','ho': 'ほ', + 'ba': 'ば', 'bi': 'び', 'bu': 'ぶ','be': 'べ','bo': 'ぼ', + 'pa': 'ぱ', 'pi': 'ぴ', 'pu': 'ぷ','pe': 'ぺ','po': 'ぽ', + 'ma': 'ま', 'mi': 'み', 'mu': 'む','me': 'め','mo': 'も', + 'ya': 'や', 'yu': 'ゆ', 'yo': 'よ', + 'ra': 'ら', 'ri': 'り', 'ru': 'る','re': 'れ','ro': 'ろ', + 'la': 'ら', 'li': 'り', 'lu': 'る','le': 'れ','lo': 'ろ', + 'wa': 'わ', 'wi': 'うぃ', 'we': 'うぇ', 'wo': 'を', + 'wye': 'ゑ', 'wyi': 'ゐ', '-': 'ー', + + 'n': 'ん', 'nn': 'ん', "n'": 'ん', + + 'kya': 'きゃ', 'kyu': 'きゅ', 'kyo': 'きょ', 'kye': 'きぇ', 'kyi': 'きぃ', + 'gya': 'ぎゃ', 'gyu': 'ぎゅ', 'gyo': 'ぎょ', 'gye': 'ぎぇ', 'gyi': 'ぎぃ', + 'kwa': 'くぁ', 'kwi': 'くぃ', 'kwu': 'くぅ', 'kwe': 'くぇ', 'kwo': 'くぉ', + 'gwa': 'ぐぁ', 'gwi': 'ぐぃ', 'gwu': 'ぐぅ', 'gwe': 'ぐぇ', 'gwo': 'ぐぉ', + 'qwa': 'ぐぁ', 'gwi': 'ぐぃ', 'gwu': 'ぐぅ', 'gwe': 'ぐぇ', 'gwo': 'ぐぉ', + + 'sya': 'しゃ', 'syi': 'しぃ', 'syu': 'しゅ', 'sye': 'しぇ', 'syo': 'しょ', + 'sha': 'しゃ','shu': 'しゅ', 'she': 'しぇ', 'sho': 'しょ', + 'ja': 'じゃ','ju': 'じゅ', 'je': 'じぇ', 'jo': 'じょ', + 'jya': 'じゃ', 'jyi': 'じぃ', 'jyu': 'じゅ', 'jye': 'じぇ', 'jyo': 'じょ', + 'zya': 'じゃ', 'zyu': 'じゅ', 'zyo': 'じょ', 'zye': 'じぇ', 'zyi': 'じぃ', + 'swa': 'すぁ', 'swi': 'すぃ', 'swu': 'すぅ', 'swe': 'すぇ', 'swo': 'すぉ', + + 'cha': 'ちゃ','chu': 'ちゅ', 'che': 'ちぇ', 'cho': 'ちょ', + 'cya': 'ちゃ', 'cyi': 'ちぃ', 'cyu': 'ちゅ', 'cye': 'ちぇ', 'cyo': 'ちょ', + 'tya': 'ちゃ', 'tyi': 'ちぃ', 'tyu': 'ちゅ', 'tye': 'ちぇ', 'tyo': 'ちょ', + 'dya': 'ぢゃ', 'dyi': 'ぢぃ', 'dyu': 'ぢゅ', 'dye': 'ぢぇ', 'dyo': 'ぢょ', + 'tsa': 'つぁ', 'tsi': 'つぃ','tse': 'つぇ', 'tso': 'つぉ', + 'tha': 'てゃ', 'thi': 'てぃ', 'thu': 'てゅ', 'the': 'てぇ', 'tho': 'てょ', + 'twa': 'とぁ', 'twi': 'とぃ', 'twu': 'とぅ', 'twe': 'とぇ', 'two': 'とぉ', + 'dha': 'でゃ', 'dhi': 'でぃ', 'dhu': 'でゅ', 'dhe': 'でぇ', 'dho': 'でょ', + 'dwa': 'どぁ', 'dwi': 'どぃ', 'dwu': 'どぅ', 'dwe': 'どぇ', 'dwo': 'どぉ', + + 'nya': 'にゃ', 'nyu': 'にゅ', 'nyo': 'にょ', 'nye': 'にぇ', 'nyi': 'にぃ', + + 'hya': 'ひゃ', 'hyi': 'ひぃ', 'hyu': 'ひゅ', 'hye': 'ひぇ', 'hyo': 'ひょ', + 'bya': 'びゃ', 'byi': 'びぃ', 'byu': 'びゅ', 'bye': 'びぇ', 'byo': 'びょ', + 'pya': 'ぴゃ', 'pyi': 'ぴぃ', 'pyu': 'ぴゅ', 'pye': 'ぴぇ', 'pyo': 'ぴょ', + 'fa': 'ふぁ', 'fi': 'ふぃ','fe': 'ふぇ', 'fo': 'ふぉ', + 'fwa': 'ふぁ', 'fwi': 'ふぃ', 'fwu': 'ふぅ', 'fwe': 'ふぇ', 'fwo': 'ふぉ', + 'fya': 'ふゃ', 'fyi': 'ふぃ', 'fyu': 'ふゅ', 'fye': 'ふぇ', 'fyo': 'ふょ', + + 'mya': 'みゃ', 'myi': 'みぃ', 'myu': 'みゅ', 'mye': 'みぇ', 'myo': 'みょ', + + 'rya': 'りゃ', 'ryi': 'りぃ', 'ryu': 'りゅ', 'rye': 'りぇ', 'ryo': 'りょ', + 'lya': 'りゃ', 'lyu': 'りゅ', 'lyo': 'りょ', 'lye': 'りぇ', 'lyi': 'りぃ', + + 'va': 'ゔぁ', 'vi': 'ゔぃ', 'vu': 'ゔ','ve': 'ゔぇ', 'vo': 'ゔぉ', + 'vya': 'ゔゃ', 'vyi': 'ゔぃ', 'vyu': 'ゔゅ', 'vye': 'ゔぇ', 'vyo': 'ゔょ', + 'wha': 'うぁ', 'whi': 'うぃ', 'ye': 'いぇ', 'whe': 'うぇ', 'who': 'うぉ', + + 'xa': 'ぁ', 'xi': 'ぃ', 'xu': 'ぅ', 'xe': 'ぇ', 'xo': 'ぉ', + 'xya': 'ゃ', 'xyu': 'ゅ', 'xyo': 'ょ', + 'xtu': 'っ', 'xtsu': 'っ', + 'xka': 'ゕ', 'xke': 'ゖ', 'xwa': 'ゎ', + + '@@': ' ', '#[': '「', '#]': '」', '#,': '、', '#.': '。', '#/': '・', +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..3e78247 --- /dev/null +++ b/readme.md @@ -0,0 +1,57 @@ +jTransliterate - [Hirag/Katak]ana to Latin/English & Back +=========================================================================== +Sometimes you may want to convert from Hiragana to Katakana, or back again, or... +I dunno, maybe you wanna get the English pronunciation of these words. I'll +be honest and say it's of no concern or interest to me, but I needed this in +Python and so I ported it, figured I'd release it. + +It's MIT licensed. Credit for much of this also belongs to Kim Ahlström and +his linguistics/etc work on **[Ve](https://github.com/Kimtaro/ve/blob/master/lib/providers/japanese_transliterators.rb)**. + + +Installation +--------------------------------------------------------------------------- + pip install jTransliterate + + +Examples && Documentation +--------------------------------------------------------------------------- +``` python +# -*- coding: utf-8 -*- + +from jTransliterate import JapaneseTransliterator + +# Transliterate from Latin/English to [Hirag/Katak]ana +x = JapaneseTransliterator('kanazawa') +print x.transliterate_from_latn_to_hrkt() +# Should print "かなざわ" + +# Transliterate from Hiragana to Latin/English +b = JapaneseTransliterator('かなざわ') +print b.transliterate_from_hira_to_latn() +# Should print "kanazawa" + +# Transliterate from either Hiragana or Katakana to Latin/English +print b.transliterate_from_hrkt_to_latn(text = 'カナザワ') +# Should print "kanazawa" + +# Transliterate from Katakan to Hiragana (You... probably never need to do this) +print b.transliterate_from_kana_to_hira(text = 'キットカート') +# Should print "きっとかーと" + +# Transliterate from Hiragana to Katakana +print b.transliterate_from_hira_to_kana(text = 'かなざわ') +# Should print "カナザワ" + +# If you want to convert between half/full width kana, you can use the following +# functions. I didn't care enough to do demos here. ;| +b.transliterate_from_halfwidth_to_fullwidth() +b.transliterate_from_fullwidth_to_halfwidth() +``` + +Questions, Comments, Complaints and/or etc +--------------------------------------------------------------------------- +Hit me up on them Twitters or find me on them internets at the links below. + +Twitter: **[@ryanmcgrath](http://twitter.com/ryanmcgrath/)** +Web: **[Veno Designs](http://venodesigns.net/)** diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..41cd274 --- /dev/null +++ b/setup.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +from setuptools import setup +from setuptools import find_packages + +__author__ = 'Ryan McGrath ' +__version__ = '1.0.0' + +setup( + # Basic package information. + name='jTransliterate', + version=__version__, + packages=find_packages(), + + # Packaging options. + include_package_data=True, + + # Metadata for PyPI. + author='Ryan McGrath', + author_email='ryan@venodesigns.net', + license='MIT License', + url='http://github.com/ryanmcgrath/twython/tree/master', + keywords='japanese translation transliterate katakana hiragana latin', + description='Transliterate [Hirag/Katak]ana to Latin/English and back. Convert half/full-width Japanese text.', + long_description=open('readme.md').read(), + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Communications :: Chat', + 'Topic :: Internet' + ] +) From 38c5cf5b2dcc42200fc1e1c29bd9c165739a7fc3 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Wed, 11 Apr 2012 07:49:16 -0400 Subject: [PATCH 2/6] Remove print statement --- jTransliterate/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jTransliterate/__init__.py b/jTransliterate/__init__.py index 9f388f7..c285f0a 100644 --- a/jTransliterate/__init__.py +++ b/jTransliterate/__init__.py @@ -245,10 +245,9 @@ class JapaneseTransliterator(object): codepoints = map(lambda char: ord(char), list(text)) for codepoint in codepoints: - print codepoint if codepoint >= range_start and codepoint <= range_end: transposed_text += unichr(codepoint + distance) else: transposed_text += unichr(codepoint) - return transposed_text \ No newline at end of file + return transposed_text From c90ccd79a6e01996f00d0453be375a752b183545 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Wed, 11 Apr 2012 07:49:42 -0400 Subject: [PATCH 3/6] Version bump --- jTransliterate/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jTransliterate/__init__.py b/jTransliterate/__init__.py index c285f0a..1cdbe01 100644 --- a/jTransliterate/__init__.py +++ b/jTransliterate/__init__.py @@ -2,7 +2,7 @@ #!/usr/bin/python __author__ = "Ryan McGrath " -__version__ = "1.0" +__version__ = "1.0.1" """ A class that allows for easy transliteration of [Hirag/Katak]ana diff --git a/setup.py b/setup.py index 41cd274..d9ec980 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup from setuptools import find_packages __author__ = 'Ryan McGrath ' -__version__ = '1.0.0' +__version__ = '1.0.1' setup( # Basic package information. From df94686813031845e01ce9c5e7340d13195f27fa Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Wed, 11 Apr 2012 08:22:04 -0400 Subject: [PATCH 4/6] Fixes, 1.0.2 --- jTransliterate/__init__.py | 10 +++++----- jTransliterate/test.py | 10 +++++----- readme.md | 10 +++++----- setup.py | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/jTransliterate/__init__.py b/jTransliterate/__init__.py index 1cdbe01..aa56428 100644 --- a/jTransliterate/__init__.py +++ b/jTransliterate/__init__.py @@ -2,7 +2,7 @@ #!/usr/bin/python __author__ = "Ryan McGrath " -__version__ = "1.0.1" +__version__ = "1.0.2" """ A class that allows for easy transliteration of [Hirag/Katak]ana @@ -62,8 +62,8 @@ class JapaneseTransliterator(object): the class instance. """ text = self.transliterate_from_kana_to_hira(text) - return self.transliterate_from_hira_to_latn(text) - + return self.transliterate_from_hira_to_latn(text.encode('utf-8')) + @defaultToSelfText def transliterate_from_hira_to_latn(self, text): """transliterate_from_hira_to_latn(self, text) @@ -115,7 +115,7 @@ class JapaneseTransliterator(object): romaji += for_conversion index += length klength -= length - + return romaji @defaultToSelfText @@ -129,7 +129,7 @@ class JapaneseTransliterator(object): the class instance. """ # Duplicate the text... - romaji = text * 1 + romaji = (text * 1).decode('utf-8') kana = '' romaji = re.sub('/m([BbPp])/', 'n\1', romaji) diff --git a/jTransliterate/test.py b/jTransliterate/test.py index 79b710c..8e63613 100644 --- a/jTransliterate/test.py +++ b/jTransliterate/test.py @@ -13,18 +13,18 @@ print b.transliterate_from_hira_to_latn() # Should print "kanazawa" # Transliterate from either Hiragana or Katakana to Latin/English -print b.transliterate_from_hrkt_to_latn(text = 'カナザワ') +print b.transliterate_from_hrkt_to_latn(text = u'(ストロベリー)') # Should print "kanazawa" # Transliterate from Katakan to Hiragana (You... probably never need to do this) -print b.transliterate_from_kana_to_hira(text = 'キットカート') +#print b.transliterate_from_kana_to_hira(text = 'キットカート') # Should print "きっとかーと" # Transliterate from Hiragana to Katakana -print b.transliterate_from_hira_to_kana(text = 'かなざわ') +#print b.transliterate_from_hira_to_kana(text = 'かなざわ') # Should print "カナザワ" # If you want to convert between half/full width kana, you can use the following # functions. I didn't care enough to do demos here. ;| -b.transliterate_from_halfwidth_to_fullwidth() -b.transliterate_from_fullwidth_to_halfwidth() +#b.transliterate_from_halfwidth_to_fullwidth() +#b.transliterate_from_fullwidth_to_halfwidth() diff --git a/readme.md b/readme.md index 3e78247..2ee9e84 100644 --- a/readme.md +++ b/readme.md @@ -22,25 +22,25 @@ Examples && Documentation from jTransliterate import JapaneseTransliterator # Transliterate from Latin/English to [Hirag/Katak]ana -x = JapaneseTransliterator('kanazawa') +x = JapaneseTransliterator(u'kanazawa') print x.transliterate_from_latn_to_hrkt() # Should print "かなざわ" # Transliterate from Hiragana to Latin/English -b = JapaneseTransliterator('かなざわ') +b = JapaneseTransliterator(u'かなざわ') print b.transliterate_from_hira_to_latn() # Should print "kanazawa" # Transliterate from either Hiragana or Katakana to Latin/English -print b.transliterate_from_hrkt_to_latn(text = 'カナザワ') +print b.transliterate_from_hrkt_to_latn(text = u'カナザワ') # Should print "kanazawa" # Transliterate from Katakan to Hiragana (You... probably never need to do this) -print b.transliterate_from_kana_to_hira(text = 'キットカート') +print b.transliterate_from_kana_to_hira(text = u'キットカート') # Should print "きっとかーと" # Transliterate from Hiragana to Katakana -print b.transliterate_from_hira_to_kana(text = 'かなざわ') +print b.transliterate_from_hira_to_kana(text = u'かなざわ') # Should print "カナザワ" # If you want to convert between half/full width kana, you can use the following diff --git a/setup.py b/setup.py index d9ec980..7cfddc9 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup from setuptools import find_packages __author__ = 'Ryan McGrath ' -__version__ = '1.0.1' +__version__ = '1.0.2' setup( # Basic package information. From d7c62d0518305541ae85f3d8130d1dc5c8596848 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Wed, 11 Apr 2012 08:40:26 -0400 Subject: [PATCH 5/6] Fix installation --- MANIFEST.in | 1 + jTransliterate/__init__.py | 2 +- setup.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..89cb7b5 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include LICENSE readme.md diff --git a/jTransliterate/__init__.py b/jTransliterate/__init__.py index aa56428..7ffa6fc 100644 --- a/jTransliterate/__init__.py +++ b/jTransliterate/__init__.py @@ -2,7 +2,7 @@ #!/usr/bin/python __author__ = "Ryan McGrath " -__version__ = "1.0.2" +__version__ = "1.0.3" """ A class that allows for easy transliteration of [Hirag/Katak]ana diff --git a/setup.py b/setup.py index 7cfddc9..99934aa 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup from setuptools import find_packages __author__ = 'Ryan McGrath ' -__version__ = '1.0.2' +__version__ = '1.0.3' setup( # Basic package information. @@ -19,8 +19,8 @@ setup( author='Ryan McGrath', author_email='ryan@venodesigns.net', license='MIT License', - url='http://github.com/ryanmcgrath/twython/tree/master', - keywords='japanese translation transliterate katakana hiragana latin', + url='https://github.com/ryanmcgrath/jTransliterate', + keywords='japanese translation transliterate katakana hiragana latin romaji', description='Transliterate [Hirag/Katak]ana to Latin/English and back. Convert half/full-width Japanese text.', long_description=open('readme.md').read(), classifiers=[ From 0dac5c73303e98cbcc369c9e8b18b00bcf486525 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Sat, 4 May 2013 21:30:01 -0700 Subject: [PATCH 6/6] Create gh-pages branch via GitHub --- images/arrow-down.png | Bin 0 -> 423 bytes images/octocat-small.png | Bin 0 -> 570 bytes index.html | 106 +++++++++ javascripts/scale.fix.js | 20 ++ params.json | 1 + stylesheets/pygment_trac.css | 69 ++++++ stylesheets/styles.css | 413 +++++++++++++++++++++++++++++++++++ 7 files changed, 609 insertions(+) create mode 100644 images/arrow-down.png create mode 100644 images/octocat-small.png create mode 100644 index.html create mode 100644 javascripts/scale.fix.js create mode 100644 params.json create mode 100644 stylesheets/pygment_trac.css create mode 100644 stylesheets/styles.css diff --git a/images/arrow-down.png b/images/arrow-down.png new file mode 100644 index 0000000000000000000000000000000000000000..585b0bddba878b95acc961fc5c0c55c3ea2e75db GIT binary patch literal 423 zcmeAS@N?(olHy`uVBq!ia0vp^JU}eW!3HFke0{SLNU;<^miKrK zR4D>d>0FeWSdy8arx22vo62CJZ=!E#Q zuUEhHFKq}eVcf!fOXk2252o^`A0Pfx?pl-`?tS^o=dZa}n)o-rOj#-_e`l7jy7u+r zhj0Hd|L1+)z+f_A|GJISy4qrPpME*#k;S{#M4)d)HS2xXctpM~nN-ejV$=G%1)}zh z6_&;B=NTB*Rz&o)EN^QNw)=Nauj9or^J@~D*Th}TXM8@bL&NZxPHmc!SKl9%dr^gl zqh@m|zG6sNdzVY`kauM4^m$&|dG9N?-~61nSXA6TxH5R=Pxc4Kow9qMI-LOq1%s!n KpUXO@geCw=gQOS$ literal 0 HcmV?d00001 diff --git a/images/octocat-small.png b/images/octocat-small.png new file mode 100644 index 0000000000000000000000000000000000000000..66c25398dd9090905e37aa2d48bb2d77a0ac6255 GIT binary patch literal 570 zcmV-A0>%A_P)V>IRB3Hx05~r+FEKJgdgKHE00ELo zL_t(Ijg^xed`v89bwq|>- zBcAI>wNjQ~{V)H%tlWtR3ZPgl_WI*s7zQut?CiWv)3hNC$Q&OX?xs?y7lFshPE4M* zWwYbCv9ZzqmMOqA&6xTyFpvlX0a(^MlwlaPupofy>3N$E3)SoOTg`Kw1aKY(ER{+J z8i40IIbbma`(6R7dL#-k0u){W3czrO-f82x&g$~grz@IyWqNvQc6)p4Nm@33tb3m8 zqya>Phsa&m{#?w>&fMT<@_Edvm9hja12DK_rqO6@Dy6#qH=`bjY5@o|v#Lj;wod}b>JrdoE#olbS0=7RdB$LTJ@R`4#*!KNI_tZAjO+JC<^Z)<=07*qo IM6N<$f|}m$2LJ#7 literal 0 HcmV?d00001 diff --git a/index.html b/index.html new file mode 100644 index 0000000..9007cd1 --- /dev/null +++ b/index.html @@ -0,0 +1,106 @@ + + + + + + Jtransliterate by ryanmcgrath + + + + + + + + +
+
+

Jtransliterate

+

Transliterate [Hirag/Katak]ana to Latin/English and back with Python. Convert half/full-width Japanese text.

+ + + +

This project is maintained by ryanmcgrath

+ + +
+
+

jTransliterate - [Hirag/Katak]ana to Latin/English & Back

+ +

Sometimes you may want to convert from Hiragana to Katakana, or back again, or... +I dunno, maybe you wanna get the English pronunciation of these words. I'll +be honest and say it's of no concern or interest to me, but I needed this in +Python and so I ported it, figured I'd release it.

+ +

It's MIT licensed. Credit for much of this also belongs to Kim Ahlström and +his linguistics/etc work on Ve.

+ +

Installation

+ +
pip install jTransliterate
+
+ +

Examples && Documentation

+ +
# -*- coding: utf-8 -*-
+
+from jTransliterate import JapaneseTransliterator
+
+# Transliterate from Latin/English to [Hirag/Katak]ana
+x = JapaneseTransliterator(u'kanazawa')
+print x.transliterate_from_latn_to_hrkt()
+# Should print "かなざわ"
+
+# Transliterate from Hiragana to Latin/English
+b = JapaneseTransliterator(u'かなざわ')
+print b.transliterate_from_hira_to_latn()
+# Should print "kanazawa"
+
+# Transliterate from either Hiragana or Katakana to Latin/English
+print b.transliterate_from_hrkt_to_latn(text = u'カナザワ')
+# Should print "kanazawa"
+
+# Transliterate from Katakan to Hiragana (You... probably never need to do this)
+print b.transliterate_from_kana_to_hira(text = u'キットカート')
+# Should print "きっとかーと"
+
+# Transliterate from Hiragana to Katakana
+print b.transliterate_from_hira_to_kana(text = u'かなざわ')
+# Should print "カナザワ" 
+
+# If you want to convert between half/full width kana, you can use the following
+# functions. I didn't care enough to do demos here. ;|
+b.transliterate_from_halfwidth_to_fullwidth()
+b.transliterate_from_fullwidth_to_halfwidth()
+
+ +

Questions, Comments, Complaints and/or etc

+ +

Hit me up on them Twitters or find me on them internets at the links below.

+ +

Twitter: @ryanmcgrath
+Web: Veno Designs

+
+ +
+ + + + + + \ No newline at end of file diff --git a/javascripts/scale.fix.js b/javascripts/scale.fix.js new file mode 100644 index 0000000..08716c0 --- /dev/null +++ b/javascripts/scale.fix.js @@ -0,0 +1,20 @@ +fixScale = function(doc) { + + var addEvent = 'addEventListener', + type = 'gesturestart', + qsa = 'querySelectorAll', + scales = [1, 1], + meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : []; + + function fix() { + meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; + doc.removeEventListener(type, fix, true); + } + + if ((meta = meta[meta.length - 1]) && addEvent in doc) { + fix(); + scales = [.25, 1.6]; + doc[addEvent](type, fix, true); + } + +}; \ No newline at end of file diff --git a/params.json b/params.json new file mode 100644 index 0000000..7b6a6d9 --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"name":"Jtransliterate","tagline":"Transliterate [Hirag/Katak]ana to Latin/English and back with Python. Convert half/full-width Japanese text.","body":"jTransliterate - [Hirag/Katak]ana to Latin/English & Back\r\n===========================================================================\r\nSometimes you may want to convert from Hiragana to Katakana, or back again, or...\r\nI dunno, maybe you wanna get the English pronunciation of these words. I'll\r\nbe honest and say it's of no concern or interest to me, but I needed this in\r\nPython and so I ported it, figured I'd release it.\r\n\r\nIt's MIT licensed. Credit for much of this also belongs to Kim Ahlström and\r\nhis linguistics/etc work on **[Ve](https://github.com/Kimtaro/ve/blob/master/lib/providers/japanese_transliterators.rb)**.\r\n\r\n\r\nInstallation\r\n---------------------------------------------------------------------------\r\n pip install jTransliterate\r\n\r\n\r\nExamples && Documentation\r\n---------------------------------------------------------------------------\r\n``` python\r\n# -*- coding: utf-8 -*-\r\n\r\nfrom jTransliterate import JapaneseTransliterator\r\n\r\n# Transliterate from Latin/English to [Hirag/Katak]ana\r\nx = JapaneseTransliterator(u'kanazawa')\r\nprint x.transliterate_from_latn_to_hrkt()\r\n# Should print \"かなざわ\"\r\n\r\n# Transliterate from Hiragana to Latin/English\r\nb = JapaneseTransliterator(u'かなざわ')\r\nprint b.transliterate_from_hira_to_latn()\r\n# Should print \"kanazawa\"\r\n\r\n# Transliterate from either Hiragana or Katakana to Latin/English\r\nprint b.transliterate_from_hrkt_to_latn(text = u'カナザワ')\r\n# Should print \"kanazawa\"\r\n\r\n# Transliterate from Katakan to Hiragana (You... probably never need to do this)\r\nprint b.transliterate_from_kana_to_hira(text = u'キットカート')\r\n# Should print \"きっとかーと\"\r\n\r\n# Transliterate from Hiragana to Katakana\r\nprint b.transliterate_from_hira_to_kana(text = u'かなざわ')\r\n# Should print \"カナザワ\" \r\n\r\n# If you want to convert between half/full width kana, you can use the following\r\n# functions. I didn't care enough to do demos here. ;|\r\nb.transliterate_from_halfwidth_to_fullwidth()\r\nb.transliterate_from_fullwidth_to_halfwidth()\r\n```\r\n\r\nQuestions, Comments, Complaints and/or etc\r\n---------------------------------------------------------------------------\r\nHit me up on them Twitters or find me on them internets at the links below.\r\n\r\nTwitter: **[@ryanmcgrath](http://twitter.com/ryanmcgrath/)** \r\nWeb: **[Veno Designs](http://venodesigns.net/)** \r\n","google":"UA-40660943-4","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 0000000..c6a6452 --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,69 @@ +.highlight { background: #ffffff; } +.highlight .c { color: #999988; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .k { font-weight: bold } /* Keyword */ +.highlight .o { font-weight: bold } /* Operator */ +.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ +.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #aa0000 } /* Generic.Error */ +.highlight .gh { color: #999999 } /* Generic.Heading */ +.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #555555 } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */ +.highlight .gt { color: #aa0000 } /* Generic.Traceback */ +.highlight .kc { font-weight: bold } /* Keyword.Constant */ +.highlight .kd { font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #009999 } /* Literal.Number */ +.highlight .s { color: #d14 } /* Literal.String */ +.highlight .na { color: #008080 } /* Name.Attribute */ +.highlight .nb { color: #0086B3 } /* Name.Builtin */ +.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ +.highlight .no { color: #008080 } /* Name.Constant */ +.highlight .ni { color: #800080 } /* Name.Entity */ +.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ +.highlight .nn { color: #555555 } /* Name.Namespace */ +.highlight .nt { color: #000080 } /* Name.Tag */ +.highlight .nv { color: #008080 } /* Name.Variable */ +.highlight .ow { font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #009999 } /* Literal.Number.Float */ +.highlight .mh { color: #009999 } /* Literal.Number.Hex */ +.highlight .mi { color: #009999 } /* Literal.Number.Integer */ +.highlight .mo { color: #009999 } /* Literal.Number.Oct */ +.highlight .sb { color: #d14 } /* Literal.String.Backtick */ +.highlight .sc { color: #d14 } /* Literal.String.Char */ +.highlight .sd { color: #d14 } /* Literal.String.Doc */ +.highlight .s2 { color: #d14 } /* Literal.String.Double */ +.highlight .se { color: #d14 } /* Literal.String.Escape */ +.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ +.highlight .si { color: #d14 } /* Literal.String.Interpol */ +.highlight .sx { color: #d14 } /* Literal.String.Other */ +.highlight .sr { color: #009926 } /* Literal.String.Regex */ +.highlight .s1 { color: #d14 } /* Literal.String.Single */ +.highlight .ss { color: #990073 } /* Literal.String.Symbol */ +.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #008080 } /* Name.Variable.Class */ +.highlight .vg { color: #008080 } /* Name.Variable.Global */ +.highlight .vi { color: #008080 } /* Name.Variable.Instance */ +.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ + +.type-csharp .highlight .k { color: #0000FF } +.type-csharp .highlight .kt { color: #0000FF } +.type-csharp .highlight .nf { color: #000000; font-weight: normal } +.type-csharp .highlight .nc { color: #2B91AF } +.type-csharp .highlight .nn { color: #000000 } +.type-csharp .highlight .s { color: #A31515 } +.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/styles.css b/stylesheets/styles.css new file mode 100644 index 0000000..f14d9e4 --- /dev/null +++ b/stylesheets/styles.css @@ -0,0 +1,413 @@ +@import url(https://fonts.googleapis.com/css?family=Arvo:400,700,400italic); + +/* MeyerWeb Reset */ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font: inherit; + vertical-align: baseline; +} + + +/* Base text styles */ + +body { + padding:10px 50px 0 0; + font-family:"Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + color: #232323; + background-color: #FBFAF7; + margin: 0; + line-height: 1.8em; + -webkit-font-smoothing: antialiased; + +} + +h1, h2, h3, h4, h5, h6 { + color:#232323; + margin:36px 0 10px; +} + +p, ul, ol, table, dl { + margin:0 0 22px; +} + +h1, h2, h3 { + font-family: Arvo, Monaco, serif; + line-height:1.3; + font-weight: normal; +} + +h1,h2, h3 { + display: block; + border-bottom: 1px solid #ccc; + padding-bottom: 5px; +} + +h1 { + font-size: 30px; +} + +h2 { + font-size: 24px; +} + +h3 { + font-size: 18px; +} + +h4, h5, h6 { + font-family: Arvo, Monaco, serif; + font-weight: 700; +} + +a { + color:#C30000; + font-weight:200; + text-decoration:none; +} + +a:hover { + text-decoration: underline; +} + +a small { + font-size: 12px; +} + +em { + font-style: italic; +} + +strong { + font-weight:700; +} + +ul li { + list-style: inside; + padding-left: 25px; +} + +ol li { + list-style: decimal inside; + padding-left: 20px; +} + +blockquote { + margin: 0; + padding: 0 0 0 20px; + font-style: italic; +} + +dl, dt, dd, dl p { + font-color: #444; +} + +dl dt { + font-weight: bold; +} + +dl dd { + padding-left: 20px; + font-style: italic; +} + +dl p { + padding-left: 20px; + font-style: italic; +} + +hr { + border:0; + background:#ccc; + height:1px; + margin:0 0 24px; +} + +/* Images */ + +img { + position: relative; + margin: 0 auto; + max-width: 650px; + padding: 5px; + margin: 10px 0 32px 0; + border: 1px solid #ccc; +} + + +/* Code blocks */ + +code, pre { + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; + color:#000; + font-size:14px; +} + +pre { + padding: 4px 12px; + background: #FDFEFB; + border-radius:4px; + border:1px solid #D7D8C8; + overflow: auto; + overflow-y: hidden; + margin-bottom: 32px; +} + + +/* Tables */ + +table { + width:100%; +} + +table { + border: 1px solid #ccc; + margin-bottom: 32px; + text-align: left; + } + +th { + font-family: 'Arvo', Helvetica, Arial, sans-serif; + font-size: 18px; + font-weight: normal; + padding: 10px; + background: #232323; + color: #FDFEFB; + } + +td { + padding: 10px; + background: #ccc; + } + + +/* Wrapper */ +.wrapper { + width:960px; +} + + +/* Header */ + +header { + background-color: #171717; + color: #FDFDFB; + width:170px; + float:left; + position:fixed; + border: 1px solid #000; + -webkit-border-top-right-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -moz-border-radius-topright: 4px; + -moz-border-radius-bottomright: 4px; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + padding: 34px 25px 22px 50px; + margin: 30px 25px 0 0; + -webkit-font-smoothing: antialiased; +} + +p.header { + font-size: 16px; +} + +h1.header { + font-family: Arvo, sans-serif; + font-size: 30px; + font-weight: 300; + line-height: 1.3em; + border-bottom: none; + margin-top: 0; +} + + +h1.header, a.header, a.name, header a{ + color: #fff; +} + +a.header { + text-decoration: underline; +} + +a.name { + white-space: nowrap; +} + +header ul { + list-style:none; + padding:0; +} + +header li { + list-style-type: none; + width:132px; + height:15px; + margin-bottom: 12px; + line-height: 1em; + padding: 6px 6px 6px 7px; + + background: #AF0011; + background: -moz-linear-gradient(top, #AF0011 0%, #820011 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); + background: -webkit-linear-gradient(top, #AF0011 0%,#820011 100%); + background: -o-linear-gradient(top, #AF0011 0%,#820011 100%); + background: -ms-linear-gradient(top, #AF0011 0%,#820011 100%); + background: linear-gradient(top, #AF0011 0%,#820011 100%); + + border-radius:4px; + border:1px solid #0D0D0D; + + -webkit-box-shadow: inset 0px 1px 1px 0 rgba(233,2,38, 1); + box-shadow: inset 0px 1px 1px 0 rgba(233,2,38, 1); + +} + +header li:hover { + background: #C3001D; + background: -moz-linear-gradient(top, #C3001D 0%, #950119 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); + background: -webkit-linear-gradient(top, #C3001D 0%,#950119 100%); + background: -o-linear-gradient(top, #C3001D 0%,#950119 100%); + background: -ms-linear-gradient(top, #C3001D 0%,#950119 100%); + background: linear-gradient(top, #C3001D 0%,#950119 100%); +} + +a.buttons { + -webkit-font-smoothing: antialiased; + background: url(../images/arrow-down.png) no-repeat; + font-weight: normal; + text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 0; + padding: 2px 2px 2px 22px; + height: 30px; +} + +a.github { + background: url(../images/octocat-small.png) no-repeat 1px; +} + +a.buttons:hover { + color: #fff; + text-decoration: none; +} + + +/* Section - for main page content */ + +section { + width:650px; + float:right; + padding-bottom:50px; +} + + +/* Footer */ + +footer { + width:170px; + float:left; + position:fixed; + bottom:10px; + padding-left: 50px; +} + +@media print, screen and (max-width: 960px) { + + div.wrapper { + width:auto; + margin:0; + } + + header, section, footer { + float:none; + position:static; + width:auto; + } + + footer { + border-top: 1px solid #ccc; + margin:0 84px 0 50px; + padding:0; + } + + header { + padding-right:320px; + } + + section { + padding:20px 84px 20px 50px; + margin:0 0 20px; + } + + header a small { + display:inline; + } + + header ul { + position:absolute; + right:130px; + top:84px; + } +} + +@media print, screen and (max-width: 720px) { + body { + word-wrap:break-word; + } + + header { + padding:10px 20px 0; + margin-right: 0; + } + + section { + padding:10px 0 10px 20px; + margin:0 0 30px; + } + + footer { + margin: 0 0 0 30px; + } + + header ul, header p.view { + position:static; + } +} + +@media print, screen and (max-width: 480px) { + + header ul li.download { + display:none; + } + + footer { + margin: 0 0 0 20px; + } + + footer a{ + display:block; + } + +} + +@media print { + body { + padding:0.4in; + font-size:12pt; + color:#444; + } +} \ No newline at end of file