Public
Edited
Oct 31, 2022
3 stars
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
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
Insert cell
Insert cell
cse599dPaperData = FileAttachment("cse599d-paper-data.json").json()
Insert cell
cse599dPaperData[2].s2data.abstract.length
Insert cell
doi = "10.1145/3411764.3445648"
Insert cell
doiResponse = fetch(`https://doi.org/${doi}`, {
checkContentType: true,
method: 'GET',
headers: { Accept: 'application/vnd.citationstyles.csl+json' } // request in CSL-JSON format
}).then(res => {
if (res.status === 200) {
return res.json();
} else {
return { status: res.status, message: 'DOI service responded with non-OK status code.' };
}
})
Insert cell
pdfUrl = doiResponse.link[0].URL
Insert cell
fetch(pdfUrl, { method: "GET" })
Insert cell
Insert cell
s2orc_sample = FileAttachment("s2orc_sample.jsonl").text()
Insert cell
s2orc_metadata = FileAttachment("metadata.jsonl")
Insert cell
itemsWithBt[1]
Insert cell
itemsWithBt[1].body_text[0]
Insert cell
itemsWithBt[1].body_text[0].text
Insert cell
itemsWithBt[1].bib_entries
Insert cell
itemsWithBt[1].bib_entries.BIBREF1
Insert cell
itemsWithBt[1]
Insert cell
paperIds = itemsWithBt.map((item) => item.paper_id)
Insert cell
citationIds = {
let bibEntryTables = itemsWithBt.map((item) => item.bib_entries);
let flatBibEntries = bibEntryTables
.map((table) => Object.values(table))
.flat();
let ids = flatBibEntries.map((entry) => entry.link).filter((id) => !!id);
return ids;
}
Insert cell
citationIdsInDataset = paperIds.map((id) => paperIds.includes(id))
Insert cell
Insert cell
items[0]
Insert cell
years = metasWithBt.map((meta) => meta.year)
Insert cell
margin = {
return {
top: 20,
right: 50,
bottom: 50,
left: 20
};
}
Insert cell
Insert cell
Insert cell
xScale = d3
.scaleLinear()
// .domain(d3.extent(metasWithBt, (d) => d.year))
.domain([1990, 2022])
.rangeRound([0, width])
.nice()
Insert cell
function generateDotplotStacks(data, binwidth) {
data = data.sort((a, b) => a - b);
const stacks = [];
for (let i = 0; i < data.length; ) {
const threshold = data[i] + binwidth;

const stack = [data[i]];
let j = i + 1;

while (data[j] < threshold) {
stack.push(data[j++]);
}
let v = (stack[stack.length - 1] - stack[0]) / 2;
const diff = data[i] - data[i - 1];
// if (diff > binwidth || i == 0) { // X_0 = -inf in the original algorithm
// v = (stack[stack.length - 1] - stack[0]) / 2;
// }

stacks.push({
values: stack,
// "x": jStat.median(stack),
// "x": (stack[0] + stack[stack.length - 1]) / 2
x: stack[0] + v,
v: v,
diff: diff,
threshold: threshold
});
i = j;
}
return stacks;
}
Insert cell
binwidth = 1.25 * Math.sqrt(20 / metasWithBt.length)
Insert cell
someItemRefs = Object.values(itemsWithBt[1].bib_entries)
.map((entry) => entry.link)
.filter((link) => !!link)
Insert cell
someItem = itemsWithBt[paperIdx]
Insert cell
Insert cell
someItemBts = someItem.body_text
Insert cell
someItemBtTexts = someItemBts.map((bt) => bt.text)
Insert cell
someItemBtCitations = someItemBts.map((bt) => bt.cite_spans)
Insert cell
Insert cell
Insert cell
sentenceBibs = getBibsForSentence(5, someItemBts[paragraphIdx])
Insert cell
someItemBts[paragraphIdx]
Insert cell
function getCitations(item, pIdx, sIdx) {
let sentenceBibs = getBibsForSentence(sIdx, item.body_text[pIdx]);
let sentenceCitations = sentenceBibs.map(
(bibEntry) => item.bib_entries[bibEntry.ref_id]
);
return sentenceCitations;
}
Insert cell
getCitations(someItem, paragraphIdx, 5)
Insert cell
someItem
Insert cell
someItemBtCitations[paragraphIdx]
Insert cell
itemsWithBt[paperIdx].bib_entries["BIBREF1"]
Insert cell
selectedPaper = itemsWithBt[paperIdx]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
endTag = function (s) {
return `</td><td style="padding: 3px;">${s
.out(its.sentiment)
.toFixed(2)}</td></tr>`;
}
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