基于马尔可夫链的句子生成

markovip的Python项目详细描述


马尔科夫

https://img.shields.io/pypi/v/markovipy.svghttps://img.shields.io/travis/prodicus/markovipy.svgDocumentation StatusUpdates

logo

当你给她完整的课文后,她试着用连贯的句子和你进行引人注目的对话。不,她不会抱怨你的语料库有多大。另外,不要问她是否能通过图灵测试。她可能不会再和你说话了。

wrote a blog post如果你感兴趣的话,我会解释动机以及幕后的原因

安装

要安装markovipy,请在终端中运行此命令:

$ pip install markovipy

这是安装markovipy的首选方法,因为它总是安装最新的稳定版本。

如果您没有安装pip,这个Python installation guide可以指导您 你完成了整个过程。

用法

在项目中使用markovipy:

>>> from markovipy import MarkoviPy
>>>
>>> # create MarkoviPy object
>>> obj = MarkoviPy("/Users/tasrahma/development/projects/markovipy/corpus/ts_eliot/Gerontion_utf8.txt", 3)
>>>
>>>
>>> # arguments passed, is the initial corpus file and the markov chain length(defaults to 2 if nothing passed)
>>> obj.generate_sentence()
'Cammel, whirled Beyond the circuit of the shuddering Bear In fractured atoms.'
>>>
>>> obj.generate_sentence()
'After such knowledge, what forgiveness? Think now History has many cunning passages, contrived corridors And issues, deceives with whispering ambitions, Guides us by vanities.'
>>>
>>> obj.generate_sentence()
'Gull against the wind, in the windy straits Of Belle Isle, or running on the Horn, White feathers in the snow, the Gulf claims, And an old man, a dull head among windy spaces.'
>>>
>>> obj.generate_sentence()
'Silvero With caressing hands, at Limoges Who walked all night in the field overhead; Rocks, moss, stonecrop, iron, merds.'
>>>
>>> obj.generate_sentence()
"Gives too soon Into weak hands, what's thought can be dispensed with Till the refusal propagates a fear."

功能

  • 要添加更多测试。到目前为止,已经编写了一些最低限度的测试。我们非常欢迎你的贡献。
  • 创建一个带有一些漂亮按钮/ui的web界面,它会给你随机的引号。

历史记录

0.3.0(2017-05-30)

  • markovipy模块中公开了Markovipy类。 API从

    from markovipy.markovipy import MarkoviPy

from markovipy import MarkoviPy

0.2.0(2017-04-29)

  • self.middle_value映射变为defaultdict
  • list_to_tuple()被删除,只使用tuple()
  • 已将self.words_list = get_word_list(self.filename)移动到__init__()

0.1.1(2017-04-14)

  • 在读取文件时修复了UnicodeDecodeError,而不是使用普通的open()

0.1.0(2017-04-11)

  • pypi上的第一个版本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java无法启动发现(Android附近连接API v2)   如何用Java在Firestore中创建嵌套字段?   GUI Java中的swing BMI计算器;   java如何检查上下文是否为当前正在运行的活动   LiveCycle ES4支持java 8吗?   构建Spring引导API后,java类路径不正确   启动时swing Java Jtable行颜色   JAVAutil。ConcurrentModificationException随着Apache Tomee Plus 7.1.2的发布启动ear文件   在JAVA中使用lambda表达式的foreach for循环   java小程序没有在我的IE8和firefox6中运行。0.2   java有没有比ConcurrentHashMap性能更好的并发映射?   java Android静态与非静态问题   尝试提交TableCell时调用java cancelEdit()   java在LINUX系统上使用MCRTsim模拟器   Java多态性方法重写