Public
Edited
Jun 8, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
balVar = (desc)=>
({desc,...fuzzy.variable([-1,1], {
below:fuzzy.invSigmoid(-0.05,10),
equal:fuzzy.gaussian(0,0.125),
above:fuzzy.sigmoid(0.05,10)
})})
Insert cell
simVar = (prop)=>
({prop,...fuzzy.variable([-1,1], {
equal:fuzzy.invSigmoid(0.05,10),
close:fuzzy.gaussian(0.25,0.20),
apart:fuzzy.sigmoid(0.45,10)
})})
Insert cell
outVar= (prop) =>
({prop,...fuzzy.variable([0, 1], {
vague:
//fuzzy.invSigmoid(0.4,10),
fuzzy.invRamp(0,1),
maybe:
// fuzzy.gaussian(0.5,0.175),
fuzzy.triangle(0,0.5,1),
clear:
// fuzzy.sigmoid(0.75,5),
// fuzzy.triangle(0.25,1)
fuzzy.ramp(0,1)
})})
Insert cell
dimVar = (prop)=>
({prop,...fuzzy.variable([-1,1], {
small:fuzzy.invSigmoid(-0.2,10),
basic:fuzzy.gaussian(0,0.1),
large:fuzzy.sigmoid(0.2,10),
})})
Insert cell
binVar = (prop)=>
({prop,...fuzzy.variable([0, 1], {
vague: fuzzy.invRamp(0,1),
clear: fuzzy.ramp(0,1)
})})
Insert cell
inputs = ({
lineWidth: dimVar('dims[2]'),
charWidth: balVar('dims[5]'), // + divide by line count
leadWidth: simVar('lead[2]'),
hangWidth: simVar('hang[2]'),

leadHeight: simVar('lead[3]'),
hangHeight: simVar('hang[3]'),

leadIndent: simVar('lead[0]'),
hangIndent: simVar('hang[0]'),

lineExtent: simVar('dims[4]'),
leadExtent: simVar('lead[4]'),
hangExtent: simVar('hang[4]'),

duplicate: binVar('dupl'),

titlecase: binVar('caps>gaps'),
numerated: binVar('enum'),

pageTurn: binVar('turn'),
lineEnd: binVar('punc'),
numberEnd: binVar('enum[i + 1] + punc'),

sameLine: binVar('same'),

})
Insert cell
Insert cell
temp.ticks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
feature.filter(d=>d.class=='below')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function clamp(num, min, max) {
return num <= min
? min
: num >= max
? max
: num
}
Insert cell
function roll(arr, {mode = 'entries', sort = true } = {}) {

const counts = new Map();
var count = 0;
for (const item of arr) {
count = (counts.get(item) ?? 0) + 1
counts.set(item,count)
}
return sort ? [...counts[mode]()].sort((a,b)=> b[1]-a[1])
: [...counts[mode]()]
}
Insert cell
columns = { let t1 = performance.now();
let result = //roll(
roll(roll(
temp.outer.filter(d=>d.axis).map(d=>d.page),{mode:'values'},
{mode:'values',sort:false}))[0]
// chain(temp.outer.filter(d=>d.axis).map(d=>d.page),
// Array(2).fill(count({mode:'values',sort:false})))
return {t:performance.now()-t1,result}
}
Insert cell
function count({mode = 'entries', sort = true } = {}) {

return (arr) => {

const counts = new Map();
var count = 0;
for (const item of arr) {
count = (counts.get(item) ?? 0) + 1
counts.set(item,count)
}
return sort ? [...counts[mode]()].sort((a,b)=> b[1]-a[1] || a-b )
: [...counts[mode]()]
}

}
Insert cell
chain = (array,...steps) => steps.flat().reduce((pipe,fn) => fn(pipe),array)
Insert cell
Insert cell
Insert cell
Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"
Insert cell
fuzzy = import('https://cdn.skypack.dev/@thi.ng/fuzzy@2.1.23?min')
Insert cell
vizzy = import('https://cdn.skypack.dev/@thi.ng/fuzzy-viz@2.1.45?min')
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