Platform
Resources
Pricing
Sign in
Get started
Kerry Rodden
Workspace
Fork
Published
By
Kerry Rodden
Edited
Sep 15, 2020
4 stars
1
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
generate
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
poem
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
book
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
phrases
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
lines
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randomPhraseIndex
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randomPoemLength
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
minLength
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
maxLength
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
startLine
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
endLine
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML