src/bigfive2alchi: better handle ambiguous results
This commit is contained in:
parent
463e339b05
commit
f661a26efb
|
@ -83,9 +83,10 @@ const cardinalElementOfDiagonal = { '12': 'e3', '34': 'e1' };
|
|||
const fixedElementOfDiagonal = { '12': 'e4', '34': 'e2' };
|
||||
|
||||
// round
|
||||
function num(n) {
|
||||
return Math.round(n);
|
||||
return n.toFixed(1);
|
||||
function num(n, digits = 0) {
|
||||
if (n == undefined) return 'undefined';
|
||||
return parseFloat(n.toFixed(digits));
|
||||
//return Math.round(n);
|
||||
}
|
||||
|
||||
function getInterpretation(bigfive, elementObject) {
|
||||
|
@ -94,25 +95,74 @@ function getInterpretation(bigfive, elementObject) {
|
|||
const elementList = Object.keys(elementObject).map(elm => [elm, elementObject[elm]]);
|
||||
elementList.sort((a, b) => b[1] - a[1]); // sort descending
|
||||
|
||||
const range = elementList[0][1] - elementList[3][1];
|
||||
if (range < 10) {
|
||||
return 'result is ambiguous.';
|
||||
let range;
|
||||
let rangeStrong;
|
||||
let rangeWeak;
|
||||
let fireScore;
|
||||
let airScore;
|
||||
let virtualAgree;
|
||||
let diagonalSign;
|
||||
let diagonal;
|
||||
let baseElement;
|
||||
|
||||
const rangeMinimum = 10;
|
||||
|
||||
function ambiguousInterpretation(bigfive, reason = '') {
|
||||
const { o, c, e, a, n } = bigfive;
|
||||
|
||||
// TODO verify: result is ambiguous. this is a sign of element earth or element water.
|
||||
|
||||
return `\
|
||||
result is ambiguous.${!reason ? '' : ` \n${reason}.`}
|
||||
|
||||
we expect these correlations:
|
||||
|
||||
* high O = high E
|
||||
* high C = low N
|
||||
* high A = air (high OEN + low C) or water (low OEN + high C)
|
||||
|
||||
generated by [bigfive2alchi.html](https://milahu.github.io/alchi/src/bigfive2alchi.html#ocean=${o}.${c}.${e}.${a}.${n})
|
||||
|
||||
\\--
|
||||
|
||||
debug:
|
||||
|
||||
* range = ${num(range)}
|
||||
* rangeStrong = ${num(rangeStrong)}
|
||||
* rangeWeak = ${num(rangeWeak)}
|
||||
* fireScore = ${num(fireScore)}
|
||||
* airScore = ${num(airScore)}
|
||||
* virtualAgree = ${num(virtualAgree)}
|
||||
* diagonalSign = ${diagonalSign}
|
||||
* diagonal = ${diagonal}
|
||||
`;
|
||||
}
|
||||
|
||||
const rangeStrong = elementList[0][1] - elementList[2][1];
|
||||
const rangeWeak = elementList[1][1] - elementList[3][1];
|
||||
range = elementList[0][1] - elementList[3][1];
|
||||
if (range < rangeMinimum) {
|
||||
return ambiguousInterpretation(bigfive, `strongest and weakest element are too close together (range = ${num(range, 1)} < ${rangeMinimum})`);
|
||||
}
|
||||
|
||||
rangeStrong = elementList[0][1] - elementList[2][1];
|
||||
rangeWeak = elementList[1][1] - elementList[3][1];
|
||||
|
||||
// score vs opposite element
|
||||
const fireScore = elementObject.e1 - elementObject.e2;
|
||||
const airScore = elementObject.e3 - elementObject.e4;
|
||||
fireScore = elementObject.e1 - elementObject.e2;
|
||||
airScore = elementObject.e3 - elementObject.e4;
|
||||
|
||||
//const virtualAgree = 50 + 5/8*(Math.abs(airScore) - Math.abs(fireScore)); // formula 1
|
||||
const virtualAgree = (200/3 + (Math.abs(airScore) - Math.abs(fireScore)))/(4/3); // formula 2
|
||||
virtualAgree = (200/3 + (Math.abs(airScore) - Math.abs(fireScore)))/(4/3); // formula 2
|
||||
|
||||
const diagonalSign = Math.sign(Math.abs(fireScore) - Math.abs(airScore));
|
||||
const diagonalTolerance = 10;
|
||||
//const diagonalSign = Math.sign(Math.abs(fireScore) - Math.abs(airScore));
|
||||
diagonalSign = Math.sign(
|
||||
Math.round((
|
||||
Math.abs(fireScore) - Math.abs(airScore)
|
||||
) * diagonalTolerance) / diagonalTolerance
|
||||
);
|
||||
|
||||
const diagonalMap = { '-1': '34', '0': '?', '1': '12' };
|
||||
const diagonal = diagonalMap[diagonalSign];
|
||||
diagonal = diagonalMap[diagonalSign];
|
||||
|
||||
const baseElementFromDiagonal =
|
||||
diagonal == '?' ? '?' :
|
||||
|
@ -120,7 +170,7 @@ function getInterpretation(bigfive, elementObject) {
|
|||
? ( fireScore == 0 ? '?' : fireScore > 0 ? 'e1' : 'e2' )
|
||||
: ( airScore == 0 ? '?' : airScore > 0 ? 'e3' : 'e4' )
|
||||
;
|
||||
const baseElement = baseElementFromDiagonal;
|
||||
baseElement = baseElementFromDiagonal;
|
||||
|
||||
const cardinalElement = cardinalElementOfDiagonal[diagonal];
|
||||
const fixedElement = fixedElementOfDiagonal[diagonal];
|
||||
|
@ -134,19 +184,34 @@ function getInterpretation(bigfive, elementObject) {
|
|||
;
|
||||
|
||||
res += `\
|
||||
\\--
|
||||
|
||||
derivation: element and modality:
|
||||
|
||||
* diagonalRange: ${num(fireScore)} fire-earth + ${num(airScore)} air-water
|
||||
* diagonalRange: ${num(fireScore, 2)} fire-earth + ${num(airScore, 2)} air-water
|
||||
* element ${nameOfElement[baseElementFromDiagonal]}
|
||||
* valid modalities (cardinal mutable fixed): ${nameOfElement[cardinalElement]} ${nameOfElement[baseElement]} ${nameOfElement[fixedElement]}
|
||||
* modalityRange: ${num(modalityRange)} ${nameOfElement[cardinalElement]}-${nameOfElement[fixedElement]}
|
||||
* modalityRange: ${num(modalityRange, 2)} ${nameOfElement[cardinalElement]}-${nameOfElement[fixedElement]}
|
||||
* ${modality} modality
|
||||
* ${nameOfElement[baseElementFromDiagonal]} plays ${nameOfElement[modalityElement]}
|
||||
|
||||
verification: virtual diagonal, computed from O C E N:
|
||||
verification: virtual diagonal, derived from O C E N:
|
||||
|
||||
* virtualAgree ${num(virtualAgree)}
|
||||
* virtualDiagonal ${nameOfDiagonal[diagonal]}
|
||||
|
||||
\\--
|
||||
|
||||
debug:
|
||||
|
||||
* range = ${num(range)}
|
||||
* rangeStrong = ${num(rangeStrong)}
|
||||
* rangeWeak = ${num(rangeWeak)}
|
||||
* fireScore = ${num(fireScore)}
|
||||
* airScore = ${num(airScore)}
|
||||
* virtualAgree = ${num(virtualAgree)}
|
||||
* diagonalSign = ${diagonalSign}
|
||||
* diagonal = ${diagonal}
|
||||
`;
|
||||
|
||||
|
||||
|
@ -160,16 +225,7 @@ verification: virtual diagonal, computed from O C E N:
|
|||
|
||||
//console.log(`baseElement ${baseElement}`);
|
||||
if (baseElement == '?') {
|
||||
res = `\
|
||||
result is ambiguous. this is a sign of element earth or element water.
|
||||
|
||||
we expect these correlations:
|
||||
|
||||
* high O = high E
|
||||
* high C = low N
|
||||
|
||||
generated by [bigfive2alchi.html](https://milahu.github.io/alchi/src/bigfive2alchi.html#ocean=${o}.${c}.${e}.${a}.${n})
|
||||
`;
|
||||
return ambiguousInterpretation(bigfive, 'base element was not found');;
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -180,12 +236,12 @@ short: ${nameOfElement[baseElement]} plays ${nameOfElement[modalityElement]}
|
|||
translations:
|
||||
|
||||
* ${mbtiOfElements(baseElement, modalityElement)} in MBTI
|
||||
* ${zodiacOfElements(baseElement, modalityElement)} = ${modalityOfElements(baseElement, modalityElement)} ${nameOfElement[baseElement]} in zodiac (not calendar-astrology)
|
||||
* ${zodiacOfElements(baseElement, modalityElement)} = ${modalityOfElements(baseElement, modalityElement)} ${nameOfElement[baseElement]} in zodiac (calendar-astrology is fake)
|
||||
* ${carlJungNameOfModality[modality]} ${carlJungNameOfElement[baseElement]} in Carl Jung
|
||||
|
||||
generated by [bigfive2alchi.html](https://milahu.github.io/alchi/src/bigfive2alchi.html#ocean=${o}.${c}.${e}.${a}.${n})
|
||||
|
||||
--
|
||||
\\--
|
||||
${modality != 'mutable' ? `
|
||||
note: verbal tests (questionnaires) easily confuse element and modality,
|
||||
so element and modality can be swapped:
|
||||
|
@ -194,6 +250,13 @@ so element and modality can be swapped:
|
|||
* ${mbtiOfElements(modalityElement, baseElement)}
|
||||
* ${zodiacOfElements(modalityElement, baseElement)}
|
||||
* ${modalityOfElements(modalityElement, baseElement)} ${nameOfElement[modalityElement]}
|
||||
|
||||
to find your element, try to find your body type:
|
||||
|
||||
* heart-shape → fire
|
||||
* pear-shape → earth
|
||||
* endo-morph → air
|
||||
* ecto-morph → water
|
||||
` : ''}
|
||||
element ${nameOfElement[baseElement]} translations:
|
||||
|
||||
|
@ -210,9 +273,13 @@ element ${nameOfElement[baseElement]} translations:
|
|||
}
|
||||
|
||||
/*
|
||||
|
||||
[ note: verbal tests (questionnaires) easily confuse element and modality, ]
|
||||
|
||||
... or element and modality show your two modalities (cardinal and fixed).
|
||||
|
||||
to find your element, try to find your body type: heart-shape → fire, pear-shape → earth, endo-morph → air, ecto-morph → water.`;
|
||||
TODO verify
|
||||
|
||||
*/
|
||||
|
||||
return res;
|
||||
|
@ -289,8 +356,6 @@ const flowprofileNameOfElement = {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
function sortedElements(elementObject) {
|
||||
const elementList = Object.keys(elementObject).map(elm => [elm, elementObject[elm]]);
|
||||
elementList.sort((a, b) => b[1] - a[1]); // sort descending
|
||||
|
@ -451,6 +516,7 @@ if (m) {
|
|||
setInput(bigfive);
|
||||
} else {
|
||||
// init result
|
||||
console.log('init result');
|
||||
handle_form_change(document.getElementById('input'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue