Utilise une combinaison de chaînes Markov et une grammaire sans contexte pour générer des phrases aléatoires avec des caractéristiques des deux modèles de langue.
Créé par William Gilpin, 2014-2019
Installation automatique
Télécharger et extraire le référentiel, puis exécuter
$ python setup.py install
Souvent, l'analyseur ne parviendra pas à installer. Alors, courez à la place
$ pip install git+git://github.com/emilmont/pyStatParser
Installation manuelle
Exigences
Installations facultatives (pour utiliser tous les outils)
Installez manuellement le code et les dépendances de base en exécutant ces commandes
$ git clone https://github.com/williamgilpin/cfgen
$ conda install nltk
$ pip install git+git://github.com/emilmont/pyStatParser
Pour marquer la grammaire ou corriger automatiquement les phrases résultantes, installez le vérificateur de langue Python Package.
$ pip install language-check
Pointez l'outil vers votre corpus et configurez le modèle de langue. Ici, nous utiliserons 2 grammes de Frankenstein de Mary Shelley.
my_model = GrammarModel('cfgen/full_books/frankenstein.txt', 2)
Générez maintenant un exemple de phrase
example_sentence = my_model.make_sentence()
corrected_example_sentence = clean_output_text(example_sentence, use_language_tool=True)
print(corrected_example_sentence)
Un flux de travail complet est donné dans le fichier Demos.ipynb .
D'un modèle formé sur Frankenstein de Mary Shelley:
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.
D'un modèle formé sur le Livre des révélations:
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.