indic_transliteration.sanscript¶
Transliteration functions for Sanskrit. The most important function is
transliterate()
, which is very easy to use:
output = transliterate(data, IAST, DEVANAGARI)
By default, the module supports the following scripts:
- Bengali
- Devanagari
- Gujarati
- Kannada
- Malayalam
- Telugu
- Tamil
- Oriya
- Gurmukhi/ Punjabi/ Panjabi
and the following romanizations:
- HK = ‘hk’
- IAST = ‘iast’
- ITRANS = ‘itrans’
- OPTITRANS = ‘optitrans’
- KOLKATA = ‘kolkata’
- SLP1 = ‘slp1’
- VELTHUIS = ‘velthuis’
- WX = ‘wx’
Each of these schemes is defined in a global dictionary SCHEMES, whose keys are strings:
devanagari_scheme = SCHEMES['devanagari']
For convenience, we also define a variable for each scheme:
devanagari_scheme = SCHEMES[DEVANAGARI]
These variables are documented below.
license: | MIT and BSD |
---|
-
class
indic_transliteration.sanscript.
SchemeMap
(from_scheme, to_scheme)[source]¶ Maps one
Scheme
to another. This class grabs the metadata and character data required fortransliterate()
.Parameters: - from_scheme – the source scheme
- to_scheme – the destination scheme
-
indic_transliteration.sanscript.
transliterate
(data, _from=None, _to=None, scheme_map=None, **kw)[source]¶ Transliterate data with the given parameters:
output = transliterate('idam adbhutam', HK, DEVANAGARI)
Each time the function is called, a new
SchemeMap
is created to map the input scheme to the output scheme. This operation is fast enough for most use cases. But for higher performance, you can pass a pre-computedSchemeMap
instead:scheme_map = SchemeMap(SCHEMES[HK], SCHEMES[DEVANAGARI]) output = transliterate('idam adbhutam', scheme_map=scheme_map)
Parameters: