マルコフ連鎖を使った文章自動生成プログラム+CLI
Project description
Text Generator
マルコフ連鎖を使った文章自動生成プログラム(日本語のみ)
インストール
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 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.