Published
Edited
Dec 14, 2021
Importers
Insert cell
Insert cell
Insert cell
{
const docs = [
['a', 'b', 'c', 'c'],
['a', 'b', 'a'],
['c'],
]
const ids = docs.map((_, id) => id)
const corpus = new tfidf.Corpus(ids, docs)
return ids.map(id => corpus.docVector(id))
}
Insert cell
Insert cell
Insert cell
{
const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et magna aliqua."
const indices = kwic.findIndices(text, ['sit', 'tempor', 'ut'])
return indices.map(([i0, i1]) => text.substring(i0, i1))
}
Insert cell
Insert cell
Insert cell
{
const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et magna aliqua."
const highlighted = kwic.highlight(
text,
['sit', 'tempor', 'ut'],
d => `<span style="background-color: #CFC; padding: 0 0.2em; border-radius: 0.2em;">${d}</span>`,
(d, s, e) => kwic.truncate(d, s, e, maxLen, efficiency)
)

return html`${highlighted}`
}
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