Published
Edited
Oct 23, 2018
Insert cell
Insert cell
Insert cell
// Load the list of qualified keywords per article

// subarticle csv
// keywordData = d3.csv("https://gist.githubusercontent.com/rielc/2194210a928725b3cbedfac08ffbf717/raw/b7630275d6a970afafe7216c2dfa32647dceec5e/2018-10-23_qualified_keywords_by_subarticle.csv")

// pdf csv
keywordData = d3.csv("https://gist.githubusercontent.com/rielc/2194210a928725b3cbedfac08ffbf717/raw/0ba3a84934749738a0f8d3aeb0c5a62987c8e386/2018-10-23_qualified_keywords_by_pdf.csv")
Insert cell
Insert cell
// Instead of the article, lets only have an array of the keywords
keywordCombinations = keywordData
//.filter(article => !!article.qualified_keywords)
.map(
article => article.qualified_keywords
.split(' ')
.map(kw => kw.split('=').reverse().join(' [') + ']')
)
Insert cell
Insert cell
// Apply the reducer and collect ALL combinations of all articles
allCombinations = keywordCombinations.map(m => m.reduce(reduceToLinks, [])).reduce((acc, el) => [...acc, ...el])
Insert cell
// Count how often each combination occurs
stat = allCombinations.reduce((acc, el) => {
if (!acc[el]) {
acc[el] = 1;
return acc;
}
acc[el] += 1;
return acc;
}, {})
Insert cell
//Print the result to the console
// console.log(Object.entries(stat).map(([key, count]) => `${key},${count}`).join('\n'))
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