Reddit Poem Generator
Rpoems is a simple library that uses psaw (PushiftIO wrapper) and various different tactics to generate poetry from a corpus of reddit comments which are defined by many different parameters.
Requirements
- Python 3.6+
Installing
Install with:
pip install rpoems
Documentation
An import method in this library is the build corpus method which generates a cache of comments given certain parameters
import rpoems
from datetime import datetime as dt
before = dt(2018, 8, 22)
after = dt(2018, 8, 20)
corpus = rpoems.build_corpus(subreddit="AskReddit", before=before, after=after, limit=3000)
Parameters
subreddit(str): The name of the subreddit you want to collect comments from. Defaults tosubreddit=""which means that comments are collected from any subreddit. (Use at your own risk. I didn't implement a profanity filter)before(datetime): Any comments collected will be before this data. Defaults tobefore=datetime.datetime.now()which means that any comment before the time this progam runs is fair game.after(datetime): Any comments collected will be after this data. Defaults toafter=datetime.datetime(2000, 1, 1)limit(int): The maximum number of comments that will be collected. People tend to underestimate how many comments are present within a certain time-span. The default oflimit=2000will be good enough for most poemsauthor(str): From which author should the comments be from. Defaults toauthor="". This feature is not functioning as well as I hoped due to issues with the Pushshift API. Best not to use it.
import rpoems
# For examples sake, I will build a different corpus, but you can definitely use the corpus from before.
corpus = rpoems.build_corpus(limit=2000)
# We now have many different types of poems we can build. I will go over one option in the coding example
poem = rpoems.couplet_rhyming_poem(corpus)
print(poem)
'''
We did it. Racism is no more. Have achieved world peace.
Tbh NES Ice Hockey player was one of my most wanted characters pre-release
and whatever you do, don't go to chauvin's florida address
you can't win in ace attorney, so it is not imperative for him to progress
Am I better off just getting BotW instead of Smash, then?
And my basic math skills have been foiled again...
'''
couplet_rhyming_poem is one method used to create a poem from a corpus. The others will be detailed below
Poem Generating Methods
couplet_rhyming_poem(corpus): Generates a poem with rhyme scheme AABBCC given a corpus of commentsvilanelle(corpus): Generates a vilanelle given a corpus of commentshaiku(corpus): Generates a haiku given a corpus of commentsacrostic(corpus, key): Generates a poem in which the first letter of each line are the letters instrkey in ordercustom_rhyme(corpus, rhyme_scheme): Generates a poem given a corpus and astrrhyme_schemerhyme_schemeis a string of capital letters. Examples include "AABCC", "CCCDDD", "AAABBC", "ZZSSY"
custom_syl(corpus, syl_string): Generates a poem given a corpus and the amount of syllables in each linesyl_stringis astrin which numbers are split by "-". Example inputs include "9-4-2", "1-2-3", "5-4-5"
tanka(corpus): Generates a poem with syllable sequence "5-7-5-7-7" given a corpus of commentsnonet(corpus): Generates a poem with a syllable sequence of "9-8-7-6-5-4-3-2-1" given a corpus of commentsmagic_nine(corpus): Generates a poem with a rhyme scheme "ABACADABA" given a corpus of commentsall_alphabet(corpus): Generates a poem in which the first letter of each line is a letter of the alphabet in order
Release files for rpoems 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rpoems-1.0.2.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rpoems-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / rpoems-1.0.2.tar.gz
| Download URL | rpoems-1.0.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dee67a3188ef19ec92a5909bf85cfdf54673dcad535580e9daa366c872aec712
|
|
BLAKE2b-256 checksum How to use checksums |
512a4e88d88c76eda08ef64945e821ff8ca6eb075da4fafe0e3eb56bee27554a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|
Release files / rpoems-1.0.2-py3-none-any.whl
| Download URL | rpoems-1.0.2-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f1076e7f30552d9541b50ec7819a73f01f87d00c9db4b4f4c881ee42b9f94a3
|
|
BLAKE2b-256 checksum How to use checksums |
2f961a39124b783e0ae25236e0ad61330ac90671d9cbff89e35e385f97eb90e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|