Verwendet eine Kombination aus Markov-Ketten und einer kontextfreien Grammatik, um zufällige Sätze mit Merkmalen beider Sprachmodelle zu generieren.
Erstellt von William Gilpin, 2014-2019
Automatische Installation
Laden Sie das Repository herunter und extrahieren Sie und führen Sie dann aus
$ python setup.py install
Oft kann der Parser nicht installiert werden. Also stattdessen laufen
$ pip install git+git://github.com/emilmont/pyStatParser
Manuelle Installation
Anforderungen
Optionale Installationen (zur Verwendung aller Tools)
Installieren Sie den Code und die grundlegenden Abhängigkeiten manuell, indem Sie diese Befehle ausführen
$ git clone https://github.com/williamgilpin/cfgen
$ conda install nltk
$ pip install git+git://github.com/emilmont/pyStatParser
Installieren Sie die Python-Paket-Sprachprüfung, um die Grammatik zu bewerten oder die resultierenden Sätze automatisch zu korrigieren.
$ pip install language-check
Zeigen Sie das Tool auf Ihren Korpus und richten Sie das Sprachmodell ein. Hier werden wir 2 Gramm von Mary Shelleys Frankenstein verwenden.
my_model = GrammarModel('cfgen/full_books/frankenstein.txt', 2)
Generieren Sie nun einen Beispielsatz
example_sentence = my_model.make_sentence()
corrected_example_sentence = clean_output_text(example_sentence, use_language_tool=True)
print(corrected_example_sentence)
In der Datei Demos.ipynb finden Sie einen vollständigen Workflow.
Aus einem Modell, das auf Mary Shelleys Frankenstein trainiert wurde:
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.
Aus einem Modell, das auf dem Buch der Enthüllungen trainiert wurde:
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.