From 639e7e793bb41ec303c1e2b777198ba5ccb4ea17 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Thu, 25 Nov 2021 10:45:35 +0000 Subject: [PATCH] feat: Updated the research page as well --- .gitignore | 4 ++ README.md | 2 +- pages/.old/listOfPosts.json | 33 -------------- pages/.old/listOfPosts_full.json | 62 -------------------------- pages/research.js | 76 +++++++++++++++++++++++--------- 5 files changed, 60 insertions(+), 117 deletions(-) delete mode 100644 pages/.old/listOfPosts.json delete mode 100644 pages/.old/listOfPosts_full.json diff --git a/.gitignore b/.gitignore index ef5df06..e87ca9f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,10 @@ # personal notes Notes.md +# convenience old folder +pages/.old/* +pages/.old + # dependencies /node_modules /.pnp diff --git a/README.md b/README.md index fe41683..5229027 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This repository creates a react webpage that allows to extract a utility function from possibly inconsistent binary comparisons ## Object structure -The core structure is json array of objects. Only the "name" attribute is required; the id is also internally required but it's created on the fly if it doesn't exist. The reason that ids are needed is that comparing objects is annoying. +The core structure is json array of objects. Only the "name" attribute is required; the (numerical) id is also internally required but it's created on the fly. The reason that ids are needed is that comparing objects is annoying. The `isReferenceValue` property determines the display at the end, but it is optional. diff --git a/pages/.old/listOfPosts.json b/pages/.old/listOfPosts.json deleted file mode 100644 index 9862bd4..0000000 --- a/pages/.old/listOfPosts.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "name": "Relative Impact of the First 10 EA Forum Prize Winners", - "url": "https://forum.effectivealtruism.org/posts/pqphZhx2nJocGCpwc/relative-impact-of-the-first-10-ea-forum-prize-winners", - "author": "Nuño Sempere", - "karma": 80 - }, - { - "name": "Introducing Metaforecast: A Forecast Aggregator and Search Tool", - "url": "https://forum.effectivealtruism.org/posts/tEo5oXeSNcB3sYr8m/introducing-metaforecast-a-forecast-aggregator-and-search", - "author": "Nuño Sempere", - "karma": 115 - }, - { - "name": "Forecasting Prize Results", - "url": "https://forum.effectivealtruism.org/posts/8QFWHzmur4roAcnCf/forecasting-prize-results", - "author": "Nuño Sempere", - "karma": 44, - "isReferenceValue": true - }, - { - "name": "A Funnel for Cause Candidates", - "url": "https://forum.effectivealtruism.org/posts/iRA4Dd2bfX9nukSo3/a-funnel-for-cause-candidates", - "author": "Nuño Sempere", - "karma": 34 - }, - { - "name": "2020: Forecasting in Review", - "url": "https://forum.effectivealtruism.org/posts/8shCj2eoQygQvtoZP/2020-forecasting-in-review", - "author": "Nuño Sempere", - "karma": 35 - } -] diff --git a/pages/.old/listOfPosts_full.json b/pages/.old/listOfPosts_full.json deleted file mode 100644 index 5f99abe..0000000 --- a/pages/.old/listOfPosts_full.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "name": "Relative Impact of the First 10 EA Forum Prize Winners", - "url": "https://forum.effectivealtruism.org/posts/pqphZhx2nJocGCpwc/relative-impact-of-the-first-10-ea-forum-prize-winners", - "author": "Nuño Sempere", - "karma": 80 - }, - { - "name": "Introducing Metaforecast: A Forecast Aggregator and Search Tool", - "url": "https://forum.effectivealtruism.org/posts/tEo5oXeSNcB3sYr8m/introducing-metaforecast-a-forecast-aggregator-and-search", - "author": "Nuño Sempere", - "karma": 115 - }, - { - "name": "Forecasting Prize Results", - "url": "https://forum.effectivealtruism.org/posts/8QFWHzmur4roAcnCf/forecasting-prize-results", - "author": "Nuño Sempere", - "karma": 44 - }, - { - "name": "A Funnel for Cause Candidates", - "url": "https://forum.effectivealtruism.org/posts/iRA4Dd2bfX9nukSo3/a-funnel-for-cause-candidates", - "author": "Nuño Sempere", - "karma": 34 - }, - { - "name": "2020: Forecasting in Review", - "url": "https://forum.effectivealtruism.org/posts/8shCj2eoQygQvtoZP/2020-forecasting-in-review", - "author": "Nuño Sempere", - "karma": 35 - }, - { - "name": "Big List of Cause Candidates", - "url": "https://forum.effectivealtruism.org/posts/SCqRu6shoa8ySvRAa/big-list-of-cause-candidates", - "author": "Nuño Sempere", - "karma": 182 - }, - { - "name": "An experiment to evaluate the value of one researcher's work", - "url": "https://forum.effectivealtruism.org/posts/udGBF8YWshCKwRKTp/an-experiment-to-evaluate-the-value-of-one-researcher-s-work", - "author": "Nuño Sempere", - "karma": 55 - }, - { - "name": "Predicting the Value of Small Altruistic Projects: A Proof of Concept Experiment", - "url": "https://forum.effectivealtruism.org/posts/qb56nicbnj9asSemx/predicting-the-value-of-small-altruistic-projects-a-proof-of", - "author": "Nuño Sempere", - "karma": 51 - }, - { - "name": "Incentive Problems With Current Forecasting Competitions", - "url": "https://forum.effectivealtruism.org/posts/ztmBA8v6KvGChxw92/incentive-problems-with-current-forecasting-competitions", - "author": "Nuño Sempere", - "karma": 54 - }, - { - "name": "Shapley Values: Better Than Counterfactuals", - "url": "https://forum.effectivealtruism.org/posts/XHZJ9i7QBtAJZ6byW/shapley-values-better-than-counterfactuals", - "author": "Nuño Sempere", - "karma": 92 - } -] diff --git a/pages/research.js b/pages/research.js index d6c9d52..c65298d 100644 --- a/pages/research.js +++ b/pages/research.js @@ -20,6 +20,7 @@ import { DisplayAsMarkdown } from '../lib/displayAsMarkdown' import { CreateTableWithDistances } from '../lib/findPaths' import { TextAreaForJson } from "../lib/textAreaForJson" import { pushToMongo } from "../lib/pushToMongo.js" +import { toLocale, transformSliderValueToPracticalValue, transformSliderValueToActualValue, numToAlphabeticalString } from "../lib/utils.js" /* Helpers */ let increasingList = (n) => Array.from(Array(n).keys()) @@ -42,23 +43,23 @@ let checkIfListIsOrdered = (arr, binaryComparisons) => { return isOrdered } -let transformSliderValueToActualValue = value => 10 ** value //>= 2 ? Math.round(10 ** value) : Math.round(10 * 10 ** value) / 10 -let toLocale = x => Number(x).toLocaleString() -let truncateValueForDisplay = value => value > 10 ? Number(Math.round(value)).toPrecision(2) : Math.round(value * 10) / 10 -let transformSliderValueToPracticalValue = value => truncateValueForDisplay(transformSliderValueToActualValue(value)) - -let displayFunctionSlider = (value) => { +let displayFunctionSliderInner = (value) => { let result if (value >= 0) { result = toLocale(transformSliderValueToPracticalValue(value)) } else { let inverseresult = toLocale(transformSliderValueToPracticalValue(-value)) - if(inverseresult == 1){ + if (inverseresult == 1) { result = '1' - }else{ + } else { result = `1/${inverseresult}` } } + return result +} + +let displayFunctionSlider = (value) => { + let result = displayFunctionSliderInner(value) result = `The first option is ${result}x as valuable as the second one` return result @@ -92,7 +93,7 @@ export default function Home({ listOfElementsDefault }) { //let initialComparePair = [list[list.length-2], list[list.length-1]] let initialComparePair = [initialPosList[initialPosList.length - 2], initialPosList[initialPosList.length - 1]] - let initialSliderValue = 0 + let initialSliderValue = 1 let initialBinaryComparisons = [] let initialQuantitativeComparisons = [] let initialIsListOdered = false @@ -226,19 +227,19 @@ export default function Home({ listOfElementsDefault }) { } let nextStepSlider = ({ posList, binaryComparisons, sliderValue, element1, element2 }) => { - if (sliderValue < 0) { - sliderValue = -sliderValue; + if (sliderValue < 1 && sliderValue > 0) { + sliderValue = 1/sliderValue; [element1, element2] = [element2, element1] } console.log(`posList@nextStepSlider:`) console.log(posList) let successStatus = nextStepSimple(posList, binaryComparisons, element1, element2) - let newQuantitativeComparison = [element1, element2, transformSliderValueToPracticalValue(sliderValue)] + let newQuantitativeComparison = [element1, element2, transformSliderValueToActualValue(sliderValue)] let newQuantitativeComparisons = [...quantitativeComparisons, newQuantitativeComparison] setQuantitativeComparisons(newQuantitativeComparisons) - setSliderValue(0) + setSliderValue(1) if (successStatus) { let jsObject = nicelyFormatLinks(quantitativeComparisons, listOfElements) pushToMongo(jsObject) @@ -272,8 +273,42 @@ export default function Home({ listOfElementsDefault }) { + +
+
+ {/*`is ${displayFunctionSliderInner(sliderValue)}x times as valuable as`*/} +
+ + +
+ + + +
+
nextStep(binaryComparisons, toComparePair[1], toComparePair[0])} >
@@ -282,6 +317,10 @@ export default function Home({ listOfElementsDefault }) {
+
+
+ {/* +
- + */} +