Public
Edited
May 5, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// See https://talk.observablehq.com/t/how-to-import-sentencex-in-observable/9201
segment = import("https://cdn.skypack.dev/sentencex@0.4.2").then(
(d) => d.default
)
Insert cell
sentences = segment(lang, text)
Insert cell
sentenceSpans = []
Insert cell
function displaycolors() {
for (let i = 0; i < sentences.length; i++) {
const randomClass = classes[i % classes.length];
sentenceSpans[i] =
'<span class="sentence ' + randomClass + '">' + sentences[i] + "</span>";
}
return sentenceSpans.join("");
}
Insert cell
output = displaycolors()
Insert cell
classes = ["red", "blue", "orange", "green", "yellow", "indigo", "lime"]
Insert cell
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