Public
Edited
Dec 12
Insert cell
Insert cell
Insert cell
${sorted.slice(0,limit).map(sentenceDiv)}
Insert cell
text = FileAttachment("pg4264.txt").text()
Insert cell
parsed = text
.replace("—", " ")
.replace("Mr.", "Mr")
.replace("Mrs.", "Mrs")
.replace("Ms.", "Ms")
.split(/[.!?]/)
.map(x=> ({sentence: x, n_words: x.match(/ /g)?.length}))
.map(x=> ({...x, n_words: x.n_words ?? 0}))
Insert cell
parsed
select
sentence,
1+n_words as n_words,
from parsed
where n_words > 10
order by n_words desc
Insert cell
sentenceDiv = (x) => {
const el = html`<div>
<h2 class="letter">${x.n_words} words</h2>
<p class="wordlist">${x.sentence}</p>
</div>`
return el
}
Insert cell
<style>
.letter {
background-color: #000080;
color: #ffffff;
text-align: center;
font-family: monospace;
}

/* .wordlist {
font-family: monospace;
} */
</style>
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more