Public
Edited
Aug 27, 2023
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
// test_records = soFetch('https://github.com/JustinGOSSES/NASA-Acronyms-in-Public-Abstracts/raw/main/data/raw/test_records.jsonl').then(res => res.text());
test_records = processed_stringTEST
Insert cell
Insert cell
test_records_json = loadJSON_fromStringOfJSONL(test_records)
Insert cell
Insert cell
// acronyms_string = soFetch('https://github.com/JustinGOSSES/NASA-Acronyms-in-Public-Abstracts/raw/main/data/interim/acronyms.jsonl').then(res => res.text());
acronyms_string = FileAttachment("acronyms@1.jsonl").text()
Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
acronyms_json = loadJSON_fromStringOfJSONL(acronyms_string)
Insert cell
Insert cell
Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
formatted_acronyms = FileAttachment("formatted_acronyms.jsonl").text()
Insert cell
//////// HAD TO REPLACE WITH FILE ATTACHEMENT AS FETCH FOR JSON BROKE?
////formatted_acronyms_string_ORIGINAL = soFetch('https://github.com/JustinGOSSES/NASA-Acronyms-in-Public-Abstracts/raw/main/data/interim/formatted_acronyms.jsonl').then(res => res.text());
Insert cell
Insert cell
// formatted_acronyms = loadJSON_fromStringOfJSONL(formatted_acronyms_string)
Insert cell
Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
///// THIS WAS ORIGINAL BUT HAD TO SHIFT TO FILE UPLOADS
// processed_string_Original = soFetch('https://github.com/JustinGOSSES/NASA-Acronyms-in-Public-Abstracts/raw/main/data/processed/processed_acronyms.jsonl').then(res => res.text());
Insert cell
processed_string = FileAttachment("processed_acronyms@1.jsonl").text()
Insert cell
processed_stringTEST = test_records1.text()
Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
test_records1 = FileAttachment("test_records@1.jsonl")
Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Select a data source…
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
// async function fetchJsonLines(jsonl_url) {
// const response = await fetch(jsonl_url);
// const text = await response.text();
// // const lines = text.trim().split("\n");
// // return lines.map((line) => JSON.parse(line));
// return text
// }
Insert cell
// test = fetch('https://github.com/JustinGOSSES/NASA-Acronyms-in-Public-Abstracts/raw/main/data/raw/test_records.jsonl')
Insert cell
mutable progress = 0
Insert cell
result = {
const response = await fetch('https://data.nasa.gov/download/byqb-7uyn/application%2Fzip');

// Check if streaming is supported.
const reader = response.body && response.body.getReader();
if (!reader) {
const value = new Uint8Array(await response.arrayBuffer());
mutable progress = value.length;
return value;
}

// Read chunks, updating as we go.
const values = [];
mutable progress = 0;
while (true) {
const {done, value} = await reader.read();
if (done) break;
mutable progress += value.length;
values.push(value);
}

// Concatenate chunks into an array.
return concat(Uint8Array, values);
}
Insert cell
function concat(type, arrays) {
let i = 0;
let n = 0;
for (const a of arrays) n += a.length;
const concat = new type(n);
for (let a of arrays) concat.set(a, i), i += a.length;
return concat;
}
Insert cell
Insert cell
processed = loadJSON_fromStringOfJSONL(processed_string)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
acronym_counts_in_abstracts = _.countBy(acronyms_json,function(obj){
return Object.keys(obj).length === 0 && Object.getPrototypeOf(obj) === Object.prototype ? 'has_no_acronyms':'has_acronyms';
})
Insert cell
Insert cell
Insert cell
function count_counts_of_acronyms_in_abstracts(acronym_counts_in_abstract){
let counts_of_number_acronyms_per_abstract = {}
function count_counts(item) {
if(Object.keys(item).length > 0){
let item_length = Object.keys(item).length
if (item_length in counts_of_number_acronyms_per_abstract){
counts_of_number_acronyms_per_abstract[item_length] += 1
}
else{
counts_of_number_acronyms_per_abstract[item_length] = 1
}
}
}
acronym_counts_in_abstract.forEach(count_counts)
return counts_of_number_acronyms_per_abstract
}
Insert cell
histogram_of_acronym_counts_per_abstract = count_counts_of_acronyms_in_abstracts(acronyms_json)
Insert cell
function make_array_objs_from_histo_counts (histogram_of_acronym_counts_per_abstract){
let array_of_objects = []
let keys = Object.keys(histogram_of_acronym_counts_per_abstract)
for (let key in keys){
let temp_obj = {"number_of_acronyms_in_an_abstract":0,"occured_this_many_times":0}
temp_obj["number_of_acronyms_in_an_abstract"] = parseInt(key)
temp_obj["occured_this_many_times"] = histogram_of_acronym_counts_per_abstract[key]
array_of_objects.push(temp_obj)
}
array_of_objects = array_of_objects.splice(1,)
return array_of_objects
}
Insert cell
histogram_of_acronym_counts_per_abstract_transformed = make_array_objs_from_histo_counts (histogram_of_acronym_counts_per_abstract)
Insert cell
acronym_counts_per_abstract = Plot.dot(histogram_of_acronym_counts_per_abstract_transformed, {x: "number_of_acronyms_in_an_abstract", y: "occured_this_many_times", stroke: "number_of_acronyms_in_an_abstract"}).plot({
marginLeft: 70,
width:400
})
Insert cell
Inputs.table(histogram_of_acronym_counts_per_abstract_transformed)
Insert cell
viewof test_abstracts_selected = Inputs.table(test_records_json, {columns: ["type","title","subject.NASATerms", "creator", "description","contributor.originator"]},{width:{type:3,description:60,creator:20}})
Insert cell
Insert cell
test_abstracts_selected[0].description[0]
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

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