Public
Edited
Aug 19, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
maxOverallCount = Math.max(...letterOccurrenceData.map((it) => it.overallCount))
Insert cell
maxPositionalCount = Math.max(
...letterOccurrenceData.map((it) => Math.max(...it.positionalCounts))
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
class Counter {
constructor() {
this.countsByKey = new Map();
}

getCountFor(key) {
const count = this.countsByKey.get(key);
return isFinite(count) ? count : 0;
}

incrementCountFor(key) {
this.countsByKey.set(key, this.getCountFor(key) + 1);
}

getKeysOrderedByDecreasingCount() {
return Array.from(this.countsByKey.keys()).sort((a, b) => {
return (
this.getCountFor(b) - this.getCountFor(a) ||
String(a).localeCompare(String(b))
);
});
}
}
Insert cell
function* generateDigraphs() {
for (const word of words) {
for (let i = 0; i < word.length - 1; i++) {
yield word.substring(i, i + 2);
}
}
}
Insert cell
Insert cell
d3 = require("d3@6")
Insert cell
html = htl.html
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