Skip to content

Commit

Permalink
extend MMT template-matrix to have subject-controller/subject-outcome…
Browse files Browse the repository at this point in the history
… configurations (#5160)
  • Loading branch information
mwdchang authored Oct 16, 2024
1 parent 5d9a2e9 commit 180ba23
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ export const extractOutcomeControllersMatrix = (

export const extractTemplateMatrix = (templates: MiraTemplate[]) => {
const rowNames = extractConceptNames(templates, 'subject');
const colNames = extractConceptNames(templates, 'outcome');

const colNames = templates[0]?.controller
? extractConceptNames(templates, 'controllers')
: extractConceptNames(templates, 'outcome');

// Not sure how to parse templates with no subject or no outcomes
// and interacts with only controllers and itself, return a matrix
Expand Down Expand Up @@ -200,13 +203,19 @@ export const extractTemplateMatrix = (templates: MiraTemplate[]) => {
if (template.subject) {
rowIdx = rowNames.indexOf(template.subject.name);
}
if (template.outcome) {

// Use subject-controller matrix if possible, otherwise fallback to subject-outcome matrix
// Note we still use the subject-outcome matrix grid
if (template.controller) {
colIdx = colNames.indexOf(template.controller.name);
} else if (template.outcome) {
colIdx = colNames.indexOf(template.outcome.name);
}
matrix[rowIdx][colIdx].content = {
value: template.rate_law,
id: template.name
};
}

return { rowNames, colNames, matrix };
};

0 comments on commit 180ba23

Please sign in to comment.