Public
Edited
May 21, 2024
Paused
Insert cell
Insert cell
viewof query = Inputs.text({
value: "Personalizing Search via Association",
label: "query",
submit: true
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof selectionType = Inputs.select(["brush", "disjoint clicking"])
Insert cell
similarityMatrixChart = {
const selectionFn =
selectionType === "brush" ? vl.selectInterval : vl.selectMulti;
const brush = selectionFn("selected").encodings("y");
return vl
.markRect({ tooltip: true })
.params(brush)
.encode(
vl
.x()
.fieldO("i")
.title(null)
.axis({ orient: "top" })
.sort(getOrderForAttrib(recomendedPapers, columnOrder)),
vl
.y()
.fieldO("j")
.title(null)
.sort(getOrderForAttrib(recomendedPapers, rowOrder)),
vl.color().fieldQ("similarity"),
vl.opacity().if(brush, 1).value(0.3),
vl.tooltip(["title"])
)
.data(tidySimilarity(similarity, recomendedPapers, columnOrder, rowOrder));
}
Insert cell
recomendedPapers = recommendations ? recommendations.fields.slice().map((d, i) => ((d.__i = i), d)): []
Insert cell
function tidySimilarity(similarity, papers, columnOrder, rowOrder) {
return similarity
.map((row, i) =>
row.map((similarity, j) => ({
title: `${similarity.toFixed(2)} (${i} -> ${j}); ${
papers[i].title
} -> ${papers[j].title}`,
i,
j,
similarity: similarity
}))
)
.flat();
}
Insert cell
function getOrderForAttrib(papers, attrib) {
return attrib === "None"
? papers.map((_, i) => i)
: papers
.sort((a, b) => d3.ascending(a[attrib], b[attrib]))
.map((d, i) => d.__i);
}
Insert cell
url = `${server}${papersUrl}`
Insert cell
tableFormat = ({ authors: authors => authors.map(a => a.name).join(", ") })
Insert cell
methods= "prone,specter,scincl,gnn".split(",")
Insert cell
papers = (await d3.json(url)).search_results
Insert cell
natural = require('natural@6.7.2/lib/natural/index.js').catch(() => window["buildExportMap"])
Insert cell
corpusId = paperSelectedForRec.externalIds.CorpusId
Insert cell
recommendedURL = `/cgi-bin/recommend_papers?id=CorpusId:${corpusId}&limit=${limit}&method=${method}&score2=prone,specter,scincl,gnn&fields=title,citationCount,year,authors`
Insert cell
server = `http://localhost:8000`
Insert cell
papersUrl = `/cgi-bin/paper_search?query=${query}`
Insert cell
recommendations = {
yield null;
yield await fetch(`${server}${recommendedURL}`).then((res) => res.json());
}
Insert cell
similarity = recommendations ? recommendations.score2[method] : []
Insert cell
Insert cell
import {vegaSelected} from "@john-guerra/vega-selected"
Insert cell
import {multiAutoSelect} from "@john-guerra/multi-auto-select"
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