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