1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
Metadata-Version: 1.1
Name: python-tr
Version: 0.1.2
Summary: A Pure-Python implementation of the tr algorithm
Home-page: https://github.com/ikegami-yukino/python-tr
Author: Yukino Ikegami
Author-email: yknikgm@gmail.com
License: MIT License
Description: python-tr
==========
|travis| |coveralls| |pyversion| |version| |landscape| |license|
This module is a Python implementation of the tr algorithm.
tr(string1, string2, source, option='')
If not given option, then replace all characters in string1 with
the character in the same position in string2.
Following options are available:
c
Replace all complemented characters in string1 with the character in the same position in string2.
d
Delete all characters in string1.
s
Squeeze all characters in string1.
cs
Squeeze all the characters in string2 besides "c" replacement.
ds
Delete all characters in string1. Squeeze all characters in string2.
cd
Delete all complemented characters in string1.
Params:
- <unicode> string1
- <unicode> string2
- <unicode> source
- <basestring> option
Return:
- <unicode> translated_source
Note
===========
- If Python2.x, the type of paramaters (string1, string2 and source) must be unicode.
- If Python3.3 or later, the type of paramaters (string1, string2 and source) must be str.
Installation
==============
::
pip install python-tr
Example
===========
Python2.x
.. code:: python
from tr import tr
tr(u'bn', u'cr', u'bunny')
# => u'curry'
tr(u'n', '', u'bunny', 'd')
# => u'buy'
tr(u'n', u'u', u'bunny', 'c')
# => u'uunnu'
tr(u'n', u'', u'bunny', 's')
# => u'buny'
tr(u'bn', '', u'bunny', 'cd')
# => u'bnn'
tr(u'bn', u'cr', u'bunny', 'cs')
# => u'brnnr'
tr(u'bn', u'cr', u'bunny', 'ds')
# => u'uy'
Python3.3 or later
.. code:: python
from tr import tr
tr('bn', 'cr', 'bunny')
# => 'curry'
tr('n', '', 'bunny', 'd')
# => 'buy'
tr('n', 'u', 'bunny', 'c')
# => 'uunnu'
tr('n', '', 'bunny', 's')
# => 'buny'
tr('bn', '', 'bunny', 'cd')
# => 'bnn'
tr('bn', 'cr', 'bunny', 'cs')
# => 'brnnr'
tr('bn', 'cr', 'bunny', 'ds')
# => 'uy'
Contributions are welcome.
.. |travis| image:: https://travis-ci.org/ikegami-yukino/python-tr.svg?branch=master
:target: https://travis-ci.org/ikegami-yukino/python-tr
:alt: travis-ci.org
.. |coveralls| image:: https://coveralls.io/repos/ikegami-yukino/python-tr/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/ikegami-yukino/python-tr?branch=master
:alt: coveralls.io
.. |version| image:: https://img.shields.io/pypi/v/python-tr.svg
:target: http://pypi.python.org/pypi/python-tr/
:alt: latest version
.. |pyversion| image:: https://img.shields.io/pypi/pyversions/python-tr.svg
.. |landscape| image:: https://landscape.io/github/ikegami-yukino/python-tr/master/landscape.svg?style=flat
:target: https://landscape.io/github/ikegami-yukino/python-tr/master
:alt: Code Health
.. |license| image:: https://img.shields.io/pypi/l/python-tr.svg
:target: http://pypi.python.org/pypi/python-tr/
:alt: license
CHANGES
=======
0.1.2 (2016-03-11)
------------------
- Fix transliteration bugs in no option bug
This bug is reported by id774.
Many thanks.
0.1.1 (2015-02-11)
------------------
- Fix metacharcter bug in squeeze
This bug is reported by Pierre Nugues.
Many thanks.
0.1 (2014-11-24)
------------------
- Improve processing speed slightly
0.0.1 (2014-07-10)
------------------
First release.
Keywords: tr,transliterate,translate
Platform: POSIX
Platform: Windows
Platform: Unix
Platform: MacOS
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Text Processing :: General
|