生成马尔可夫模因的命令行工具。

markovmeme的Python项目详细描述


马尔可夫模因

PyPI versionGitHub actions status

用马尔可夫模型生成主题模因不是很好吗?或者只是随机的 生成文本?我也这么认为。在

使用

安装

您可以从pypi安装

pip install markovmeme

或者直接从存储库安装:

^{pr2}$

使用

您可以看到以下基本用法。基本上,有一个“generate”命令:

$ markov-meme 
usage: markov-meme [-h]{generate} ...

Markov Meme Generator

optional arguments:
  -h, --help  show this help message and exit

actions:
  actions for Markov Meme Generator

  {generate}  markovmeme actions
    generate  generate a meme

您可以通过查看生成帮助查看可用的语料库:

$ markov-meme generate --help
usage: markov-meme generate [-h][--outfile OUTFILE][--fontsize FONTSIZE][--font {OpenSans-Regular,Pacifico-Regular,Anton-Regular}][--corpus {hamlet,dr_seuss,trump_speech,the_office,office/stanley,office/toby,office/meredith,office/holly,office/creed,office/oscar,office/deangelo,office/david,office/dwight,office/kelly,office/phyllis,office/jim,office/nellie,office/gabe,office/clark,office/roy,office/karen,office/michael,office/andy,office/charles,office/kevin,office/pam,office/ryan,office/erin,office/robert,office/darryl,office/pete,office/jan,office/jo,office/angela}][--custom-corpus CUSTOM_CORPUS][--image CUSTOM_IMAGE][--no-model]

optional arguments:
  -h, --help            show this help message and exit
  --outfile OUTFILE     the output file to save the image (defaults to
                        randomly generated png)
  --fontsize FONTSIZE   font size of text (if desired) defaults to 16
  --font {OpenSans-Regular,Pacifico-Regular,Anton-Regular}
                        choice of font (defaults to open sans)
  --corpus {hamlet,dr_seuss,trump_speech,the_office,office/stanley,office/toby,office/meredith,office/holly,office/creed,office/oscar,office/deangelo,office/david,office/dwight,office/kelly,office/phyllis,office/jim,office/nellie,office/gabe,office/clark,office/roy,office/karen,office/michael,office/andy,office/charles,office/kevin,office/pam,office/ryan,office/erin,office/robert,office/darryl,office/pete,office/jan,office/jo,office/angela}
                        the corpus to use to generate the meme, matches to
                        images.
  --custom-corpus CUSTOM_CORPUS
                        A custom corpus file, full path
  --image CUSTOM_IMAGE  A custom image file, full path
  --no-model            Don't generate a sentence from corpus, just randomly
                        select sentence.

随机生成

要从随机语料库中生成模因,只需运行:

$ markov-meme generate

如果随机选择的语料库没有匹配的图像,您将看到

No images exist for corpus office/clark. Please specify --image.

语料库和图像选择

您可以再次运行相同的命令,或者指定特定的语料库和图像。在

$ markov-meme generate --corpus office/michael --image markovmeme/data/images/office/michael1.png

对于指定一个自定义语料库也可以这样做,它应该是一个有行的文本文件 从生成模型。在

$ markov-meme generate --custom-corpus markovmeme/data/corpus/office/michael.txt --image markovmeme/data/images/office/michael2.png

跳过模型

如果您不想使用模型(并且希望从一些语料库中得到真实的行),请添加--no-model

$ markov-meme generate --no-model

交互式Python

在大多数情况下,文本大小和字符数被限制在合理的范围内 1-3行。如果您想自定义或以其他方式使用它,您可以进行交互 直接与全班同学交流:

frommarkovmeme.mainimportMemeImagefrommarkovmeme.textimportgenerate_text# corpus is absolute path, or relative to module's data/corpus foldercorpus="office/michael"text=generate_text(corpus=corpus,use_model=True,size=10)# Set image to full path, or None to select based on corpusmeme=MemeImage(image=None,corpus=corpus)# Add text generated, centered on topmeme.write_text(text,fontsize=args.fontsize,font=font)# Leave outfile as None to generate random namememe.save_image(None)

支持

你有问题吗?或者想推荐一个功能使其更好? 请open an issue!

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

推荐PyPI第三方库


热门话题
java从Dropwizard中的Minio检索文件时,GET请求中的超时是如何处理的?   带Hibernate的java Jackson用于序列化以避免枚举   Raspberry Pi上的java Jave分段错误   java在屏幕旋转时不保存当前片段和数据   java War文件未在Heroku上正确部署   如何使用Java处理Selenium webdriver中的促销广告或cookie   java处理“用法:PApplet[options]<classname>[sketch args]”   java文本文件错误扫描程序   运行第一个JavaFX模块化程序时出现java异常   java将fileoutputstream转换为字符串   如何调试gstreamerjava?   java Spring RestTemplate ResponseBody类是什么样的   如何将JSON数组转换为Java列表。我在用斯文森   javascript在显示div按钮后进入新页面