cfgen
1.0.0
マルコフチェーンとコンテキストフリーの文法の組み合わせを使用して、両方の言語モデルの機能を備えたランダムな文を生成します。
William Gilpin、2014-2019によって作成されました
自動インストール
リポジトリをダウンロードして抽出してから実行します
$ python setup.py install
多くの場合、パーサーはインストールに失敗します。代わりに実行します
$ pip install git+git://github.com/emilmont/pyStatParser
手動インストール
要件
オプションのインストール(すべてのツールを使用する)
これらのコマンドを実行して、コードと基本依存関係を手動でインストールする
$ git clone https://github.com/williamgilpin/cfgen
$ conda install nltk
$ pip install git+git://github.com/emilmont/pyStatParser
文法を採点したり、結果の文章を自動的に修正するには、Pythonパッケージの言語チェックをインストールします。
$ pip install language-check
ツールをコーパスに向けて、言語モデルをセットアップします。ここでは、メアリーシェリーのフランケンシュタインの2グラムを使用します。
my_model = GrammarModel('cfgen/full_books/frankenstein.txt', 2)
次に、例の文を生成します
example_sentence = my_model.make_sentence()
corrected_example_sentence = clean_output_text(example_sentence, use_language_tool=True)
print(corrected_example_sentence)
ファイルdemos.ipynbに完全なワークフローが与えられます。
メアリーシェリーのフランケンシュタインで訓練されたモデルから:
these conversation possessed to his time
those sense all fulfillment, me of affairs a soul been of I.
The next kindness her black, light of it I wished as our perish certainty.
horrible wretch that memory, their lake I to me, which the glad unhappiness
of the paroxysm of a several engagement of Clerval in her apartment and all
mainland, and on a progress, me surprised so divine me.
啓示の本で訓練されたモデルから:
Who said ever to no crown to was the listener and SECOND:
my man, and to the wheat,
and had eat in this angel.
Their pieces kill the sort the angel come up
to another translucent and weep any stone.
Her timeless will measure them to the day,
hold created with earth noises and hurled every nation.
There shown out upon the voice
It be in seventh which is to trample, I.
This tampering opened not for its time.
The land to their moment Who threw their glory to cherish that art.
The glory to the speaking, and at that white appearance, and say given
the thousand for the sake. And said show in myself. And it of no sweet victory
whose gateways enemies was loathe to the bowl
and it for them and worked out as my hast to every vision.
Their noise erase me.