马尔科夫链随机文本生成

这次的试验参考了网上的资源:


GitHub - Forec/Markov-Speaking: 一个使用马尔科夫链算法构建中/英文语句的类,提供了解析文本和生成语言的接口

使用方法:

>>> import markov_speaking

>>> p = markov_speaking.Markov('swords.txt', 1)

Building prefix dict from the default dictionary ...

Loading model from cache /home/forec/cache

Dumping model to file cache /home/forec/cache

Loading model cost 1.578 seconds.

Prefix dict has been built succesfully.

>>> p.say(5)

忽然想到一计说道师伯令狐师兄行侠仗义。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容