マルコフ連鎖を使った文章自動生成プログラム+CLI
Project description
Text Generator CLI
- マルコフ連鎖を使った文章自動生成プログラム(日本語のみ) + コマンドラインインターフェース
- ohshige15/TextGeneratorのForkのForkの Fork
インストール
- 注: 現在PyPIの
mecab-python3
はエラー文がうるさいので以下のようにしてmaster HEAD
のものを導入するのがおすすめ
pip install git+https://github.com/SamuraiT/mecab-python3
1. 事前に mecab をセットアップしておく
- Mac:
brew install mecab
brew install mecab-ipadic
- Linux(Ubuntu):
sudo apt install mecab libmecab-dev mecab-ipadic-utf8 -y
- Windows:
- 3rd Party のインストーラでインストール
- 環境変数
Path
にC:\Program Files\MeCab\bin
を追加
2. TextGenerator-cli
を PyPI からダウンロード
pip install TextGenerator-cli
ヘルプ
$ textgen
usage: textgen [-h] [-V] {prepare,p,generate,g,help,h} ...
マルコフ連鎖を使った文章自動生成プログラム
positional arguments:
{prepare,p,generate,g,help,h}
prepare (p) モデルをテキストから作成(chain.db)
generate (g) 文章を生成する
help (h) ヘルプを表示する
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
$ textgen p -h
usage: textgen prepare [-h] [FILE [FILE ...]]
positional arguments:
FILE テキストファイル(指定がなければstdin)
optional arguments:
-h, --help show this help message and exit
$ textgen g -h
usage: textgen generate [-h] [-n NL] [-l BYTE] [-t LIMIT]
optional arguments:
-h, --help show this help message and exit
-n NL, --num_line NL 生成する文数(>=0)
-l BYTE, --length BYTE
指定したbyte数以下のものが生成されるまで試行(>=0)
-t LIMIT, --try_limit LIMIT
試行回数の上限(>=0)
使い方
# 吾輩は猫であるを青空文庫からダウンロード
$ curl 'http://pubserver2.herokuapp.com/api/v0.1/books/789/content?format=txt' -o wagahai.txt
# モデル作成
$ textgen p wagahai.txt
# 文数2で生成
$ textgen g -n 2
従って人間らしい行動を二週間継続するなら白髪だって伝染しているかとの諺《ことわざ》になるそうだ面白いじゃありませんか、今戸焼の狸《たぬき》からしていいでしょう」漆桶《み》がある。
Fork 元
- オリジナル: ohshige15/TextGenerator
- +はてブロ投稿: karaage0703/TextGenerator
- +マイナーな変更: nkutomi/TextGenerator
- +CLI(いまここ): eggplants/TextGenerator
- +マイナーな変更: nkutomi/TextGenerator
- +はてブロ投稿: karaage0703/TextGenerator
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for TextGenerator_cli-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f702251bf605423ce841dfbb3b5fd3b9fcfa951d14c6560ce07bd8383621bcbd |
|
MD5 | 06c66b070c09136a9e25e3f47fe605ac |
|
BLAKE2b-256 | 4283644396b1c8993968173dc9728f466ef9d78757dce600844be5bd49e1bca3 |