Skip to main content

マルコフ連鎖を使った文章自動生成プログラム+CLI

Project description

Text Generator CLI

Release Package PyPI version

  • マルコフ連鎖を使った文章自動生成プログラム(日本語のみ) + コマンドラインインターフェース
  • ohshige15/TextGeneratorForkForkの 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

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 元

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TextGenerator-cli-0.1.3.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

TextGenerator_cli-0.1.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file TextGenerator-cli-0.1.3.tar.gz.

File metadata

  • Download URL: TextGenerator-cli-0.1.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for TextGenerator-cli-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3868aa0bb476337063ab5dd9c281cff228293ee77dd35d6bdbef98f09f5bf15d
MD5 4256460b8ff4dd8e6a35554fe4526b80
BLAKE2b-256 c1565ce56d90b74ce40dd5e1dd51d24c5196fd0b508f939acc40c7538ecee384

See more details on using hashes here.

File details

Details for the file TextGenerator_cli-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: TextGenerator_cli-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for TextGenerator_cli-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f702251bf605423ce841dfbb3b5fd3b9fcfa951d14c6560ce07bd8383621bcbd
MD5 06c66b070c09136a9e25e3f47fe605ac
BLAKE2b-256 4283644396b1c8993968173dc9728f466ef9d78757dce600844be5bd49e1bca3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page