metaforecast/src/backend/utils/misc/process-forecasts-from-old-givewellopenphil.ts
2022-04-23 23:44:38 +04:00

49 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Imports */
import fs from "fs";
/* Definitions */
let locationData = "../../input";
/* Body */
let rawdata = fs.readFileSync(
`${locationData}/givewellopenphil-questions.json`,
{ encoding: "utf-8" }
);
let data = JSON.parse(rawdata);
let results = [];
let counter = 0;
for (let datum of data) {
let id = `givewellopenphil-2021-${counter}`;
counter = counter + 1;
// let probability = Math.round(Number(datum["Percentage"].replace("%", ""))) / 100;
let result = {
id: id,
title: datum["title"],
url: datum["url"],
platform: datum["platform"],
description: datum["description"],
options: datum["options"],
/*[
{
name: "Yes",
probability: probability,
type: "PROBABILITY",
},
{
name: "No",
probability: 1 - Math.round(probability * 100) / 100,
type: "PROBABILITY",
},
],
*/
timestamp: "2021-02-23T152137.005Z", //new Date().toISOString(),
qualityindicators: {
stars: datum.qualityindicators.stars,
},
};
results.push(result);
}
let string = JSON.stringify(results, null, 2);
fs.writeFileSync(`${locationData}/givewellopenphil-questions-new.json`, string);