Skip to content

Commit

Permalink
* Fixed that an argument underneath a node that is shown as its negat…
Browse files Browse the repository at this point in the history
…ion, would have its "True, because" / "False, because" text showing the opposite of what it should.
  • Loading branch information
Venryx committed Jan 8, 2024
1 parent c8e71ad commit 0bf66f2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ export class TitlePanel extends BaseComponentPlus(
//isSubnode && {margin: "4px 0 1px 0"},
titleAttachment == null && missingTitleStrings.Contains(displayText) && {color: "rgba(255,255,255,.3)"},
)}>
{/*argNode != null &&
<Row style={{float: "left", whiteSpace: "pre", background: "black", borderRadius: "5px 0 0 0", marginLeft: -5, marginRight: 5, marginTop: -5, marginBottom: -5, height: 28, padding: "0 5px"}}>
<Text>{argNode?.link?.polarity == Polarity.supporting ? "Pro:" : "Con:"}</Text>
</Row>*/}
{titleAttachment?.equation && latex && <NodeMathUI text={titleAttachment.equation.text}
onTermHover={(id, hovered)=>this.OnTermHover([id], hovered)}
onTermClick={id=>this.OnTermClick([id])}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class MI_MoveUpOrDown extends BaseComponent<MI_SharedProps & {direction:
if (ownIndexAmongPeers == -1) return null; // defensive; this shouldn't happen, but if it does, cancel rendering until data resolves properly

let towardMin = direction == "up";
const directionInDataIsOpposite = node.link?.polarity == Polarity.supporting && node.link?.group != ChildGroup.freeform;
const directionInDataIsOpposite = node.link?.polarity == Polarity.supporting && node.link?.group != ChildGroup.freeform; // todo: make sure this is correct
if (directionInDataIsOpposite) towardMin = !towardMin;

// todo: make-so this jumping occurs relative to only the peers in the same rendered-child-group (though might be full list, eg. if "flat" view is used)
Expand Down
78 changes: 1 addition & 77 deletions Packages/js-common/Source/DB/nodeRatings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {GetRatingTypeInfo, NodeRatingType, RatingType_Info} from "./nodeRatings/
import {NodeRating, NodeRating_MaybePseudo} from "./nodeRatings/@NodeRating.js";
import {RS_GetAllValues} from "./nodeRatings/ReasonScore.js";
import {GetNodeChildrenL2, GetNode} from "./nodes.js";
import {GetMainRatingType, GetNodeL2} from "./nodes/$node.js";
import {GetMainRatingType, GetNodeL2, ShouldRatingTypeBeReversed} from "./nodes/$node.js";
import {ClaimForm, NodeL2, NodeL3, RatingSummary} from "./nodes/@Node.js";
import {ChildGroup, NodeType} from "./nodes/@NodeType.js";
import {MeID} from "./users.js";
Expand Down Expand Up @@ -181,86 +181,10 @@ export const GetMarkerPercent_AtPath = CreateAccessor((node: NodeL3, path: strin
}
});

/* export function GetPaths_MainRatingSet(node: NodeL1) {
let mainRatingType = NodeL1.GetMainRatingTypes(node)[0];
return [`nodeRatings/${node._id}/${mainRatingType}`];
}
export function GetPaths_MainRatingAverage(node: NodeL1) {
let result = GetPaths_MainRatingSet(node);
if (node.type == NodeType.Argument || node.type == NodeType.Argument)
result.AddRange(GetPaths_CalculateArgumentStrength(node, GetNodeChildren(node)));
return result;
} */

/** Returns an int from 0 to 100. */
/* export function GetMainRatingAverage(node: NodeL1, resultIfNoData = null): number {
// if static category, always show full bar
if (node._id < 100)
return 100;
return GetRatingAverage(node._id, NodeL1.GetMainRatingTypes(node)[0], resultIfNoData);
} */

/** Returns an int from 0 to 100. */
/* export function GetMainRatingFillPercent(node: NodeL1) {
let mainRatingAverage = GetMainRatingAverage(node);
if (node.current.impactPremise && (node.current.impactPremise.thenType == ImpactPremise_ThenType.StrengthenParent || node.current.impactPremise.thenType == ImpactPremise_ThenType.WeakenParent))
return mainRatingAverage != null ? mainRatingAverage.Distance(50) * 2 : 0;
return mainRatingAverage || 0;
} */

/* export function GetFillPercentForRatingAverage(node: NodeL1, ratingAverage: number, reverseRating?: boolean) {
ratingAverage = TransformRatingForContext(ratingAverage, reverseRating);
/*if (node.current.impactPremise && (node.current.impactPremise.thenType == ImpactPremise_ThenType.StrengthenParent || node.current.impactPremise.thenType == ImpactPremise_ThenType.WeakenParent))
return ratingAverage != null ? ratingAverage.Distance(50) * 2 : 0;*#/
return ratingAverage || 0;
}
export function TransformRatingForContext(ratingValue: number, reverseRating: boolean) {
if (ratingValue == null) return null;
if (reverseRating) return 100 - ratingValue;
return ratingValue;
} */

/*export class RatingFilter {
constructor(initialData: Partial<RatingFilter>) {
CE(this).VSet(initialData);
}
includeUser = null as string;
}
export function FilterRatings(ratings: Rating[], filter: RatingFilter) {
return ratings.filter(a=>filter == null || filter.includeUser == a.id);
}*/

export function TransformRatingForContext(ratingValue: number, reverseRating: boolean): number;
export function TransformRatingForContext(ratingValue: number|n, reverseRating: boolean): number|n;
export function TransformRatingForContext(ratingValue: number|n, reverseRating: boolean) {
if (ratingValue == null) return null;
if (reverseRating) return 100 - ratingValue;
return ratingValue;
}
/* export function GetFillPercentForRatingType(node: NodeL3, path: string, ratingType: RatingType, filter?: RatingFilter) {
if (ratingType == "impact") {
let nodeChildren = GetNodeChildrenL3(node, path);
//let nodeChildren = GetNodeChildrenL2(node).map(child=>AsNodeL3(child, Polarity.Supporting, GetLinkUnderParent(child._id, node)));
if (nodeChildren.Any(a=>a == null)) return 0;
let premises = nodeChildren.filter(a=>a.type == NodeType.Claim);
let averageTruth = premises.map(premise=>GetRatingAverage_AtPath(premise, "truth", filter, null)).Average();
//Log(`Node: ${node._id} @averageTruth: ${averageTruth}`);
let averageRelevance = GetRatingAverage(node._id, "relevance", filter);
return ((averageTruth / 100) * (averageRelevance / 100)) * 100;
}
return GetRatingAverage_AtPath(node, ratingType, filter) || 0;
} */

/* export function ShouldRatingTypeBeReversed(ratingType: RatingType, nodeReversed: boolean, contextReversed: boolean) {
//return nodeReversed || (contextReversed && ratingType == "adjustment");
return nodeReversed;
} */
export function ShouldRatingTypeBeReversed(node: NodeL3, ratingType: NodeRatingType) {
// return node.type == NodeType.Argument && node.finalPolarity != node.link.polarity;
// if (["impact", "relevance"].Contains(ratingType)) return false;
return node.link?.form == ClaimForm.negation;
}
19 changes: 14 additions & 5 deletions Packages/js-common/Source/DB/nodes/$node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {GetNiceNameForMediaType, MediaType} from "../media/@Media.js";
import {Map} from "../maps/@Map.js";
import {NodeRatingType} from "../nodeRatings/@NodeRatingType.js";
import {GetNodeRevision, GetNodeRevisions} from "../nodeRevisions.js";
import {CheckLinkIsValid, CheckNewLinkIsValid, GetNode, GetNodeChildrenL2, GetNodeID, GetParentNode, GetParentNodeL2, GetNodeChildrenL3} from "../nodes.js";
import {CheckLinkIsValid, CheckNewLinkIsValid, GetNode, GetNodeChildrenL2, GetNodeID, GetParentNode, GetParentNodeL2, GetNodeChildrenL3, GetParentNodeL3} from "../nodes.js";
import {ClaimForm, NodeL1, NodeL2, NodeL3, Polarity} from "./@Node.js";
import {ChildLayout, GetChildLayout_Final, NodeRevision} from "./@NodeRevision.js";
import {ChildGroup, NodeType} from "./@NodeType.js";
Expand Down Expand Up @@ -106,6 +106,7 @@ export function GetSortByRatingType(node: NodeL3): NodeRatingType|n {
export function ReversePolarity(polarity: Polarity) {
return polarity == Polarity.supporting ? Polarity.opposing : Polarity.supporting;
}
/** If returns `Polarity.supporting`, then `node` supports the display form of its parent and shows as green; if returns `Polarity.opposing`, it opposes that displayed form and shows as red. */
export const GetDisplayPolarityAtPath = CreateAccessor((node: NodeL2, path: string, tagsToIgnore?: string[]): Polarity=>{
Assert(node.type == NodeType.argument, "Only argument nodes have polarity.");
const parent = GetParentNodeL2(path);
Expand All @@ -125,6 +126,13 @@ export function GetDisplayPolarity(basePolarity: Polarity, parentForm: ClaimForm
}
return result;
}
/** If returns true, then node's form is `ClaimForm.negation`, thus its ratings need reversing in the UI. */
export function ShouldRatingTypeBeReversed(node: NodeL3, ratingType: NodeRatingType) {
// return node.type == NodeType.Argument && node.finalPolarity != node.link.polarity;
// if (["impact", "relevance"].Contains(ratingType)) return false;
return node.link?.form == ClaimForm.negation;
}

export function IsNodeL1(node): node is NodeL1 {
return !node["current"];
}
Expand Down Expand Up @@ -370,13 +378,14 @@ export const GetNodeDisplayText = CreateAccessor((node: NodeL2, path?: string|n,
if (node.type == NodeType.argument && UseStandardArgTitleOverCustom(rawTitle)) {
const nodeL3 = GetNodeL3(path);
if (nodeL3 != null && nodeL3.link?.polarity != null) {
const displayPolarity = GetDisplayPolarityAtPath(node, path ?? node.id);
if (nodeL3.link.group == ChildGroup.truth) {
resultTitle = nodeL3.link.polarity == Polarity.supporting ? "True, because 🡫" : "False, because 🡫";
resultTitle = displayPolarity == Polarity.supporting ? "True, because 🡫" : "False, because 🡫";
} else if (nodeL3.link.group == ChildGroup.relevance) {
//resultTitle = nodeL3.link.polarity == Polarity.supporting ? "Relevance increaser 🡫" : "Relevance decreaser 🡫";
resultTitle = nodeL3.link.polarity == Polarity.supporting ? "Relevance increaser 🡫" : "Relevance reducer 🡫";
//resultTitle = displayPolarity == Polarity.supporting ? "Relevance increaser 🡫" : "Relevance decreaser 🡫";
resultTitle = displayPolarity == Polarity.supporting ? "Relevance increaser 🡫" : "Relevance reducer 🡫";
} else {
resultTitle = nodeL3.link.polarity == Polarity.supporting ? "Argument (supporting)" : "Argument (opposing)";
resultTitle = displayPolarity == Polarity.supporting ? "Argument (supporting)" : "Argument (opposing)";
}
} else {
resultTitle = "Argument (unknown polarity)";
Expand Down

0 comments on commit 0bf66f2

Please sign in to comment.