Published
Edited
Sep 15, 2020
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
book = await FileAttachment("pg18362.txt").text()
Insert cell
Insert cell
phrases = book
.replaceAll(/\[.*?\]/g, "")
.split("\r\n")
.slice(startLine, endLine)
.map(d => d.trim())
.filter(d => d.length > 1)
.filter(d => !d.match(/^[A-Z ]+$/))
Insert cell
Insert cell
lines = (generate,
Array.from({ length: randomPoemLength() }, d => phrases[randomPhraseIndex()]))
Insert cell
randomPhraseIndex = d3.randomInt(0, phrases.length)
Insert cell
randomPoemLength = d3.randomInt(minLength, maxLength + 1)
Insert cell
minLength = 2
Insert cell
maxLength = 7
Insert cell
startLine = 507
Insert cell
endLine = 33000
Insert cell
d3 = require("d3@6")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more