Published
Edited
Jun 25, 2019
Insert cell
md`# Preprocess TICCLAT data`
Insert cell
Insert cell
eval_data = Files.text(eval_file).then(t => d3.tsvParse(t, d3.autoType))
Insert cell
eval_data.filter(d => d.wordform =='-beurs')
Insert cell
columns = eval_data.columns
Insert cell
new_eval_data = {
const new_eval_data = [];
eval_data.forEach(function(r) {
if ((r !== undefined) && (r.morph_par !== undefined)) {
const s = r.morph_par.split(/(#)/);
s.forEach(function(c) {
if (c.length > 2) {
var new_row = Object.assign({}, r);
new_row.morph_par = c;
new_eval_data.push(new_row);
}
});
}
})
return new_eval_data;
}
Insert cell
new_eval_data_comp = {
const new_eval_data_comp = [];
new_eval_data.forEach(function(r) {
var new_row = Object.assign({}, r);
if (r !== undefined && r.morph_par !== undefined) {
const s = r.morph_par.split(/(['A-Z'])/);
const Z = s[2];
const Y = s[4];
const X = s[6];
const W1 = s[8];
var V1 = s[10];
if (s[10] !== undefined) {
V1 = s[10].split('_')[0];
}
const h1 = s[11]+s[13]+s[15];
const W2 = s[18];
var V2 = s[10];
if (s[20] !== undefined) {
V2 = s[20].split('_')[0];
}
const h2 = s[21]+s[23]+s[25];

r.components = {'Z': Z, 'Y': Y,'X': X,'W1': W1,'V1': V1,'h1': h1,'W2': W2,'V2': V2,'h2': h2};
}
new_eval_data_comp.push(new_row);
})
return new_eval_data_comp;
}
Insert cell
new_eval_data_comp_splitid = {
const new_eval_data_comp_splitid = [];
new_eval_data_comp.forEach(function(r) {
if ((r !== undefined) && (r.dict_ids !== undefined) && (r.dict_ids !== null)) {
const s = r.dict_ids.split(/(#)/);
s.forEach(function(c) {
if (c.length > 2) {
var new_row = Object.assign({}, r);
new_row.dict_ids = c;
new_eval_data_comp_splitid.push(new_row);
}
});
}
})
return new_eval_data_comp_splitid;
}
Insert cell
new_eval_data_comp_splitid.filter(d => d.wordform =='-beurs')
Insert cell
new_eval_data_comp_splitid.filter(d => d.wordform =='-balcke')
Insert cell
// DOM.download(serialize(new_eval_data_comp_splitid), null, "Download JSON")
Insert cell
Insert cell
JSONStream = require("stream-json@1.3.0/index.js");
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