hor2vec
_ ____
| |__ ___ _ _|___ \__ _____ ___
| '_ \ / _ \| '__|__) \ \ / / _ \/ __|
| | | | (_) | | / __/ \ V / __/ (__
|_| |_|\___/|_| |_____| \_/ \___|\___|
Change your horizontal pure text to vertical with some options.
Installation
-
hor2vec
doesn't use any third party Python package. - You can just
git clone
from GitHub,cd
into clonedhor2vec
dir, and usepython3 hor2vec ...
. - You can also install from PyPI with
pip install hor2vec
, after that, you can just usehor2vec ...
.
GitHub
$ git clone https://github.com/M157q/hor2vec
PyPI
$ pip install hor2vec
Docker
$ docker pull M157q/hor2vec
Usage
usage: hor2vec [-h] [-s SEP] [-ld {l2r,r2l}] [-wd {t2b,b2t}] [-nr] [-fw] [input]
positional arguments:
input The file has horizontal pure text to be changed to vertical. If not
been given in the command, will use the stdin as input.
optional arguments:
-h, --help show this help message and exit
-s SEP, --sep SEP, --separator SEP
The separator between lines. Default is '', you can use ' ', '|' or any
other strings.
-ld {l2r,r2l}, --line-direction {l2r,r2l}
The reading direction of each line. Default is 'l2r' (left to right),
you can choose 'r2l' (right to left).
-wd {t2b,b2t}, --word-direction {t2b,b2t}
The reading direction of each word/character. Default is 't2b' (top to
bottom), you can choose 'b2t' (bottom to top).
-nr, --no-rotate If this option has been given, hor2vec won't rotate the input.
-fw, --full-width If this option has been given, hor2vec will use fullwidth characters
instead of halfwidth characters. Some half-width punctuation marks
don't have vertical way. You can enable this option to make it show
full-width in vertical way.
- Some half-width punctuation marks don't have vertical way.
- You can enable option
--full-width
to make it show full-width in vertical way.
- You can enable option
Usage - Docker
- There are 2 ways to use the docker image
- Use
stdin
as inputdocker run -it --rm M157q/hor2vec
- type in the input string
- Press
Ctrl-D
- Get the output
- Use local file as input
docker run -it --rm -v $PWD:/srv/work m157q/hor2vec ${FILENAME}
- e.g., If you have a file
a
in your current directory:docker run -it --rm -v $PWD:/srv/work m157q/hor2vec a
- Get the output
- Use
Examples
Chinese
$ cat tests/data/chinese_test_data.txt
ๆ่ฆ่ธไธไธๅ้็็ๆ
้
ๆๆๅฟ่จๆไฝ ้ชไผด็ๆบซๅบฆ
่ฉฆ่ๆพไธๅฟไธญๆ้บๆพๅญค็จ
ๅญธ่็ฅ็ฆ
ๆ่ฆ่ฎๆๅ
จไธ็ๆๅๆข็ไบบ
็ธไฟกไธๅๅฎๆ้ฝๆฏๆๅฅฝ็่ทฏ
ๅ่ฆ
$ python3 hor2vec tests/data/chinese_test_data.txt
ๆๆ่ฉฆๅญธๆ็ธๅ
่ฆๆ่่่ฆไฟก่ฆ
่ธๅฟๆพ็ฅ่ฎไธ
ไธ่จไธ็ฆๆๅ
ไธๆๅฟใๅ
จๅฎ
ๅไฝ ไธญใไธๆ
้้ชๆใ็้ฝ
็ไผด้บใๆๆฏ
็็ๆพใๅๆ
ๆ
ๆบซๅญคใๆขๅฅฝ
้ๅบฆ็จใ็็
ใใใใไบบ่ทฏ
$ python3 hor2vec -s '|' tests/data/chinese_test_data.txt
ๆ|ๆ|่ฉฆ|ๅญธ|ๆ|็ธ|ๅ
่ฆ|ๆ|่|่|่ฆ|ไฟก|่ฆ
่ธ|ๅฟ|ๆพ|็ฅ|่ฎ|ไธ|
ไธ|่จ|ไธ|็ฆ|ๆ|ๅ|
ไธ|ๆ|ๅฟ|ใ|ๅ
จ|ๅฎ|
ๅ|ไฝ |ไธญ|ใ|ไธ|ๆ|
้|้ช|ๆ|ใ|็|้ฝ|
็|ไผด|้บ|ใ|ๆ|ๆฏ|
็|็|ๆพ|ใ|ๅ|ๆ|
ๆ
|ๆบซ|ๅญค|ใ|ๆข|ๅฅฝ|
้|ๅบฆ|็จ|ใ|็|็|
ใ|ใ|ใ|ใ|ไบบ|่ทฏ|
$ python3 hor2vec -s '|' -ld r2l tests/data/chinese_test_data.txt
ๅ|็ธ|ๆ|ๅญธ|่ฉฆ|ๆ|ๆ
่ฆ|ไฟก|่ฆ|่|่|ๆ|่ฆ
ใ|ไธ|่ฎ|็ฅ|ๆพ|ๅฟ|่ธ
ใ|ๅ|ๆ|็ฆ|ไธ|่จ|ไธ
ใ|ๅฎ|ๅ
จ|ใ|ๅฟ|ๆ|ไธ
ใ|ๆ|ไธ|ใ|ไธญ|ไฝ |ๅ
ใ|้ฝ|็|ใ|ๆ|้ช|้
ใ|ๆฏ|ๆ|ใ|้บ|ไผด|็
ใ|ๆ|ๅ|ใ|ๆพ|็|็
ใ|ๅฅฝ|ๆข|ใ|ๅญค|ๆบซ|ๆ
ใ|็|็|ใ|็จ|ๅบฆ|้
ใ|่ทฏ|ไบบ|ใ|ใ|ใ|
$ python3 hor2vec -s '|' -ld r2l -wd b2t tests/data/chinese_test_data.txt
ใ|่ทฏ|ไบบ|ใ|ใ|ใ|
ใ|็|็|ใ|็จ|ๅบฆ|้
ใ|ๅฅฝ|ๆข|ใ|ๅญค|ๆบซ|ๆ
ใ|ๆ|ๅ|ใ|ๆพ|็|็
ใ|ๆฏ|ๆ|ใ|้บ|ไผด|็
ใ|้ฝ|็|ใ|ๆ|้ช|้
ใ|ๆ|ไธ|ใ|ไธญ|ไฝ |ๅ
ใ|ๅฎ|ๅ
จ|ใ|ๅฟ|ๆ|ไธ
ใ|ๅ|ๆ|็ฆ|ไธ|่จ|ไธ
ใ|ไธ|่ฎ|็ฅ|ๆพ|ๅฟ|่ธ
่ฆ|ไฟก|่ฆ|่|่|ๆ|่ฆ
ๅ|็ธ|ๆ|ๅญธ|่ฉฆ|ๆ|ๆ
$ python3 hor2vec -nr -ld r2l tests/data/chinese_test_data.txt
ใ้ๆ
็็้ๅไธไธ่ธ่ฆๆ
ใๅบฆๆบซ็ไผด้ชไฝ ๆ่จๅฟๆๆ
ใ็จๅญคๆพ้บๆไธญๅฟไธๆพ่่ฉฆ
ใใใใใใใใ็ฆ็ฅ่ๅญธ
ไบบ็ๆขๅๆ็ไธๅ
จๆ่ฎ่ฆๆ
่ทฏ็ๅฅฝๆๆฏ้ฝๆๅฎๅไธไฟก็ธ
ใใใใใใใใใใ่ฆๅ
$ python3 hor2vec -nr -ld r2l -wd b2t tests/data/chinese_test_data.txt
ใใใใใใใใใใ่ฆๅ
่ทฏ็ๅฅฝๆๆฏ้ฝๆๅฎๅไธไฟก็ธ
ไบบ็ๆขๅๆ็ไธๅ
จๆ่ฎ่ฆๆ
ใใใใใใใใ็ฆ็ฅ่ๅญธ
ใ็จๅญคๆพ้บๆไธญๅฟไธๆพ่่ฉฆ
ใๅบฆๆบซ็ไผด้ชไฝ ๆ่จๅฟๆๆ
ใ้ๆ
็็้ๅไธไธ่ธ่ฆๆ
English
$ cat tests/data/english_test_data.txt
I
want
to
be
your
friend.
Can
we
?
$ python3 hor2vec tests/data/english_test_data.txt
Iwtbyf Cw?
aoeor ae
n ui n
t re
n
d
.
$ python3 hor2vec -fw tests/data/english_test_data.txt
๏ผฉ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ ๏ผฃ๏ฝ๏ผ
ใ๏ฝ๏ฝ๏ฝ
๏ฝ๏ฝ ๏ฝ๏ฝ
ใ๏ฝใใ๏ฝ๏ฝ ๏ฝ
ใ๏ฝใใ๏ฝ๏ฝ
ใใใใใ๏ฝ
ใใใใใ๏ฝ
ใใใใใ๏ผ
$ python3 hor2vec -s ' ' tests/data/english_test_data.txt
I w t b y f C w ?
a o e o r a e
n u i n
t r e
n
d
.
$ python3 hor2vec -s ' ' -ld r2l tests/data/english_test_data.txt
? w C f y b t w I
e a r o e o a
n i u n
e r t
n
d
.
$ python3 hor2vec -s ' ' -ld r2l -wd b2t tests/data/english_test_data.txt
.
d
n
e r t
n i u n
e a r o e o a
? w C f y b t w I
$ python3 hor2vec -nr -ld r2l tests/data/english_test_data.txt
I
tnaw
ot
eb
ruoy
.dneirf
naC
ew
?
$ python3 hor2vec -nr -ld r2l -wd b2t tests/data/english_test_data.txt
?
ew
naC
.dneirf
ruoy
eb
ot
tnaw
I
Development
Install test dependencies
pip install -r requirements-test.txt
Testings
python -m pytest --cov hor2vec/ --cov-report html --cov-report term
or just
make test