Skip to content

Instantly share code, notes, and snippets.

@zachwhalen
Created December 1, 2025 08:53
Show Gist options
  • Select an option

  • Save zachwhalen/40e70d9f1f887d37ae69d1f7e035cad3 to your computer and use it in GitHub Desktop.

Select an option

Save zachwhalen/40e70d9f1f887d37ae69d1f7e035cad3 to your computer and use it in GitHub Desktop.
Lines of Questioning
import re
import json
import random
from textblob import TextBlob
import nltk
from nltk.tag import pos_tag
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
nltk.download('averaged_perceptron_tagger_eng')
nltk.download('brown')
nltk.download('punkt_tab')
text = "\n".join([k['s'] for k in data_list])
blob = TextBlob(text)
sentences = blob.sentences
questions = []
for sentence in sentences:
if (str(sentence)[-1] == '?'):
cleaner = re.sub(r'["\'“`\[\]\(\)_]', '', str(sentence))
cleaner = re.sub(r"\n([A-Z]\w+)",lambda x: " " + x.group(1).lower(),cleaner)
cleaner = re.sub(r"\n"," ",cleaner)
if (cleaner[0].islower()):
cleaner = cleaner.split()[0][0].upper() + cleaner[1:]
questions.append(cleaner)
questions = set(questions)
book = '# Lines of Questioning\n\n\n'
fib = [1,1]
while (len(fib) < 10):
fib.append(fib[-2] + fib[-1])
chapter = 0
while (len(book) < 50000):
chapter += 1
book += "## Chapter " + str(chapter) + "\n\n"
for i in range(len(fib)):
book += " " + random.choice([str(q) for q in questions if len(q.split(" ")) == fib[i]]) + "\n"
book += "\n\n"
with open("/content/book.md","w") as f:
f.write(book)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment