将您的水平纯文本转换为垂直文本,并可选择一些选项。
项目描述
hor2vec
_ ____
| |__ ___ _ _|___ \__ _____ ___
| '_ \ / _ \| '__|__) \ \ / / _ \/ __|
| | | | (_) | | / __/ \ V / __/ (__
|_| |_|\___/|_| |_____| \_/ \___|\___|
将您的水平纯文本转换为垂直文本,并可选择一些选项。
安装
hor2vec
不使用任何第三方Python包。- 您可以直接从GitHub使用
git clone
,进入复制的hor2vec
目录,并使用python3 hor2vec ...
。 - 您也可以使用
pip install hor2vec
从PyPI安装,之后您可以直接使用hor2vec ...
。
GitHub
$ git clone https://github.com/M157q/hor2vec
PyPI
$ pip install hor2vec
Docker
$ docker pull M157q/hor2vec
用法
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.
- 某些半角标点符号没有垂直方式。
- 您可以使用选项
--full-width
使其在垂直方式中显示全角。
- 您可以使用选项
用法 - Docker
- 使用Docker镜像有两种方式
- 使用
stdin
作为输入docker run -it --rm M157q/hor2vec
- 输入输入字符串
- 按
Ctrl-D
- 获取输出
- 使用本地文件作为输入
docker run -it --rm -v $PWD:/srv/work m157q/hor2vec ${FILENAME}
- 例如,如果您当前目录中有一个名为
a
的文件docker run -it --rm -v $PWD:/srv/work m157q/hor2vec a
- 获取输出
- 使用
示例
中文
$ 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
見再
路的好最是都排安切一信相
人的敢勇最界世全成變要我
福祝著學
獨孤憾遺最中心下放著試
度溫的伴陪你有記忘會我
途旅的生陌個一上踏要我
英文
$ 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
Iwtbyf Cw?
aoeor ae
n ui n
t re
n
d
.
$ 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
开发
安装测试依赖项
pip install -r requirements-test.txt
测试
python -m pytest --cov hor2vec/ --cov-report html --cov-report term
或直接
make test
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
hor2vec-2.2.1.tar.gz (21.2 kB 查看哈希值)
构建分布
hor2vec-2.2.1-py2.py3-none-any.whl (17.1 kB 查看哈希值)
关闭
hor2vec-2.2.1.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 5ac8755f25bd88fa6f6df922f8033eab04e1fe61a6134fb7016aa86badeaf221 |
|
MD5 | c79860b888bf6f532b29b2bdcf2719d8 |
|
BLAKE2b-256 | cc01ca757e13ec5bc3506ff413fad48300c3abbfc420ad61573739808b181081 |
关闭
hor2vec-2.2.1-py2.py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e33fada274e0aa295e877efa905eb4017efd8bd31015c97f93c830f1c27c8942 |
|
MD5 | 27bf2f4ca66ff28259ecfd937fa96dcd |
|
BLAKE2b-256 | 9bc4e9e58cb5fdb629caeb607ddfde33f4298d628d6f85277af4e9a37a01a34b |