fix: insight types
This commit is contained in:
parent
0cddbf69b0
commit
aff30ac0c4
|
@ -5,6 +5,7 @@ import { Tabletojson } from "tabletojson";
|
|||
import {average} from "../../utils";
|
||||
import {hash} from "../utils/hash";
|
||||
import {FetchedQuestion, Platform} from "./";
|
||||
import {FullQuestionOption} from "../../common/types";
|
||||
|
||||
/* Definitions */
|
||||
const platformName = "goodjudgment";
|
||||
|
@ -41,17 +42,15 @@ export const goodjudgment: Platform = {
|
|||
// },
|
||||
// });
|
||||
|
||||
const content = await axios
|
||||
.request({
|
||||
const content = await axios.request({
|
||||
url: "https://goodjudgment.io/superforecasts/",
|
||||
method: "get",
|
||||
headers: {
|
||||
"User-Agent": "Chrome",
|
||||
"User-Agent": "Chrome"
|
||||
},
|
||||
// agent,
|
||||
// port: 80,
|
||||
})
|
||||
.then((query) => query.data);
|
||||
}).then((query) => query.data);
|
||||
|
||||
// Processing
|
||||
let results: FetchedQuestion[] = [];
|
||||
|
@ -63,38 +62,21 @@ export const goodjudgment: Platform = {
|
|||
let title = table[0]["0"].split("\t\t\t").splice(3)[0];
|
||||
if (title != undefined) {
|
||||
title = title.replaceAll("</a>", "");
|
||||
const id = `${platformName}-${hash(title)}`;
|
||||
const description = table
|
||||
.filter((row: any) => row["0"].includes("BACKGROUND:"))
|
||||
.map((row: any) => row["0"])
|
||||
.map((text: any) =>
|
||||
text
|
||||
.split("BACKGROUND:")[1]
|
||||
.split("Examples of Superforecaster")[0]
|
||||
.split("AT A GLANCE")[0]
|
||||
.replaceAll("\n\n", "\n")
|
||||
.split("\n")
|
||||
.slice(3)
|
||||
.join(" ")
|
||||
.replaceAll(" ", "")
|
||||
.replaceAll("<br> ", "")
|
||||
)[0];
|
||||
const options = table
|
||||
.filter((row: any) => "4" in row)
|
||||
.map((row: any) => ({
|
||||
name: row["2"]
|
||||
.split('<span class="qTitle">')[1]
|
||||
.replace("</span>", ""),
|
||||
const id = `${platformName}-${
|
||||
hash(title)
|
||||
}`;
|
||||
const description = table.filter((row : any) => row["0"].includes("BACKGROUND:")).map((row : any) => row["0"]).map((text : any) => text.split("BACKGROUND:")[1].split("Examples of Superforecaster")[0].split("AT A GLANCE")[0].replaceAll("\n\n", "\n").split("\n").slice(3).join(" ").replaceAll(" ", "").replaceAll("<br> ", ""))[0];
|
||||
const options = table.filter((row : any) => "4" in row).map((row : any) => ({
|
||||
name: row["2"].split('<span class="qTitle">')[1].replace("</span>", ""),
|
||||
probability: Number(row["3"].split("%")[0]) / 100,
|
||||
type: "PROBABILITY",
|
||||
type: "PROBABILITY"
|
||||
}));
|
||||
let analysis = table.filter((row: any) =>
|
||||
row[0] ? row[0].toLowerCase().includes("commentary") : false
|
||||
);
|
||||
let analysis = table.filter((row : any) => row[0] ? row[0].toLowerCase().includes("commentary") : false);
|
||||
// "Examples of Superforecaster Commentary" / Analysis
|
||||
// The following is necessary twice, because we want to check if there is an empty list, and then get the first element of the first element of the list.
|
||||
analysis = analysis ? analysis[0] : "";
|
||||
analysis = analysis ? analysis[0] : ""; // not a duplicate
|
||||
analysis = analysis ? analysis[0] : "";
|
||||
// not a duplicate
|
||||
// console.log(analysis)
|
||||
let standardObj: FetchedQuestion = {
|
||||
id,
|
||||
|
@ -104,16 +86,14 @@ export const goodjudgment: Platform = {
|
|||
options,
|
||||
qualityindicators: {},
|
||||
extra: {
|
||||
superforecastercommentary: analysis || "",
|
||||
},
|
||||
superforecastercommentary: analysis || ""
|
||||
}
|
||||
};
|
||||
results.push(standardObj);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(
|
||||
"Failing is not unexpected; see utils/pullSuperforecastsManually.sh/js"
|
||||
);
|
||||
console.log("Failing is not unexpected; see utils/pullSuperforecastsManually.sh/js");
|
||||
|
||||
return results;
|
||||
},
|
||||
|
@ -124,5 +104,5 @@ export const goodjudgment: Platform = {
|
|||
let starsDecimal = average([nuno()]); // , eli(), misha()])
|
||||
let starsInteger = Math.round(starsDecimal);
|
||||
return starsInteger;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ const getMarketEndpoint = (id : number) => `https://insightprediction.com/api/ma
|
|||
|
||||
/* Support functions */
|
||||
|
||||
/*
|
||||
async function fetchQuestionStats(bearer : string, marketId : number) {
|
||||
const response = await axios({
|
||||
url: getMarketEndpoint(marketId),
|
||||
|
@ -110,19 +111,19 @@ async function processPredictions(predictions: any[]) {
|
|||
});
|
||||
return results; // resultsProcessed
|
||||
}
|
||||
*/
|
||||
|
||||
/* Body */
|
||||
|
||||
export const insight: Platform = {
|
||||
name: platformName,
|
||||
label: "Insight Prediction",
|
||||
color: "#ff0000",
|
||||
version: "v0",
|
||||
version: "v1",
|
||||
async fetcher() {
|
||||
let bearer = process.env.INSIGHT_BEARER;
|
||||
let data = await fetchData(bearer);
|
||||
// let data = await fetchData(bearer);
|
||||
// console.log(data);
|
||||
let results = []; // await processPredictions(data); // somehow needed
|
||||
let results: FetchedQuestion[] = []; // await processPredictions(data); // somehow needed
|
||||
return results;
|
||||
},
|
||||
calculateStars(data) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user