Использует комбинацию цепочек Маркова и грамматики без контекста для генерации случайных предложений с функциями обеих языковых моделей.
Создан Уильямом Гилпином, 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.