Skip to content

Commit f97d66e

Browse files
committed
improving coref implicit change dialog
1 parent f304bbe commit f97d66e

File tree

5 files changed

+60
-33
lines changed

5 files changed

+60
-33
lines changed

public/forms/causal.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ class CausalForm extends OneToManyForm {
3939

4040
const allFocusedCoreferringEvents = this.getAllCorefEvents(currentFocusEvent).map(event => event.getId());
4141
allFocusedCoreferringEvents.push(currentFocusEvent);
42-
42+
const axis = this._allAxes.getMainAxis();
4343
for (let i = 0; i < checkedItems.length; i++) {
44-
const axis = this._allAxes.getAxisById(this._allAxes.getEventAxisId(this._allAxes.getEventByEventId(checkedItems[i])));
4544
let allCheckedCoreferringEvents = this.getAllCorefEvents(checkedItems[i]).map(event => event.getId());
4645
allCheckedCoreferringEvents.push(checkedItems[i]);
4746
for (let j = 0; j < allFocusedCoreferringEvents.length; j++) {
@@ -52,7 +51,6 @@ class CausalForm extends OneToManyForm {
5251
}
5352

5453
for (let i = 0; i < uncheckedItems.length; i++) {
55-
const axis = this._allAxes.getAxisById(this._allAxes.getEventAxisId(this._allAxes.getEventByEventId(uncheckedItems[i])));
5654
let allUnCheckedCoreferringEvents = this.getAllCorefEvents(uncheckedItems[i]).map(event => event.getId());
5755
allUnCheckedCoreferringEvents.push(uncheckedItems[i]);
5856
for (let j = 0; j < allFocusedCoreferringEvents.length; j++) {

public/forms/coref.js

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,62 @@ class CorefForm extends OneToManyForm {
2929
super.loadForm();
3030
}
3131

32+
addToCorefSet(eventList, clusterSet) {
33+
for (let i = 0; i < eventList.length; i++) {
34+
let allCoreferringEvents = this._allAxes.getMainAxis().getAxisGraph().getAllCoreferringEvents(eventList[i]);
35+
allCoreferringEvents.push(eventList[i]);
36+
let sortedClust = JSON.stringify(allCoreferringEvents.sort());
37+
if(!clusterSet.has(sortedClust)) {
38+
clusterSet.add(sortedClust);
39+
}
40+
}
41+
}
42+
3243
handleEventSelection(currentFocusEvent, checkedItems, uncheckedItems) {
33-
let discrepancies = [];
44+
let allEventClustersBefore = new Set();
45+
this.addToCorefSet(Array.from(this._allAxes.getMainAxis().getEventIds()), allEventClustersBefore);
3446

47+
const axis = this._allAxes.getMainAxis();
3548
// Handle focused with all in list
3649
for (let i = 0; i < checkedItems.length; i++) {
37-
const axis = this._allAxes.getAxisById(this._allAxes.getEventAxisId(this._allAxes.getEventByEventId(checkedItems[i])));
38-
discrepancies = discrepancies.concat(axis.handleFormRelations(currentFocusEvent, checkedItems[i], this.getPosFormRel(), this.formType));
50+
axis.handleFormRelations(currentFocusEvent, checkedItems[i], this.getPosFormRel(), this.formType);
3951
}
4052

4153
// Handle all in list that coref with focused (should coref to eachother)
4254
for (let i = 0; i < checkedItems.length; i++) {
4355
for (let j = i + 1; j < checkedItems.length; j++) {
44-
const axis1 = this._allAxes.getAxisById(this._allAxes.getEventAxisId(this._allAxes.getEventByEventId(checkedItems[i])));
45-
discrepancies = discrepancies.concat(axis1.handleFormRelations(checkedItems[i], checkedItems[j], this.getPosFormRel(), this.formType));
56+
axis.handleFormRelations(checkedItems[i], checkedItems[j], this.getPosFormRel(), this.formType);
4657
}
4758
}
4859

4960
// Handle focused with all unchecked items
5061
for (let i = 0; i < uncheckedItems.length; i++) {
51-
const axis = this._allAxes.getAxisById(this._allAxes.getEventAxisId(this._allAxes.getEventByEventId(uncheckedItems[i])));
52-
discrepancies = discrepancies.concat(axis.handleFormRelations(currentFocusEvent, uncheckedItems[i], this.getNegFormRel(), this.formType));
62+
axis.handleFormRelations(currentFocusEvent, uncheckedItems[i], this.getNegFormRel(), this.formType);
5363
}
5464

5565
// Handle all unchecked/checked items (should not coref to each-other)
5666
for (let i = 0; i < uncheckedItems.length; i++) {
5767
for (let j = 0; j < checkedItems.length; j++) {
58-
const axis1 = this._allAxes.getAxisById(this._allAxes.getEventAxisId(this._allAxes.getEventByEventId(uncheckedItems[i])));
59-
discrepancies = discrepancies.concat(axis1.handleFormRelations(uncheckedItems[i], checkedItems[j], this.getNegFormRel(), this.formType));
68+
axis.handleFormRelations(uncheckedItems[i], checkedItems[j], this.getNegFormRel(), this.formType);
69+
}
70+
}
71+
72+
let focusedCluster = this._allAxes.getMainAxis().getAxisGraph().getAllCoreferringEvents(currentFocusEvent);
73+
focusedCluster.push(currentFocusEvent);
74+
let discrepancies = [];
75+
for (let i = 0; i < checkedItems.length; i++) {
76+
for (let j = 0; j < allEventClustersBefore.size; j++) {
77+
const clust = JSON.parse(Array.from(allEventClustersBefore)[j]);
78+
if (clust.includes(checkedItems[i])) {
79+
if (clust.length === 1) {
80+
break;
81+
} else if (clust.includes(currentFocusEvent)) {
82+
break
83+
} else {
84+
// [Cluster Before, Cluster After]
85+
discrepancies.push([clust, focusedCluster]);
86+
}
87+
}
6088
}
6189
}
6290

public/forms/onetomany.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,26 +175,28 @@ class OneToManyForm extends UIForm {
175175
}
176176

177177
handleDiscrepancies(discrepancy) {
178-
const disRootEdge = this._allAxes.getEventByEventId(discrepancy[0]).getTokens() + " (" + discrepancy[0] + ")";
179-
const disOtherEdge = this._allAxes.getEventByEventId(discrepancy[1]).getTokens() + " (" + discrepancy[1] +")";
180-
// Handle presenting k
181-
const currentRelation = discrepancy[3];
182-
const inferredRelation = discrepancy[4];
178+
const clustBefore = [];
179+
const clustAfter = [];
180+
for (let i = 0; i < discrepancy[0].length; i++) {
181+
clustBefore.push(this._allAxes.getEventByEventId(discrepancy[0][i]).getTokens() + " (" + discrepancy[0][i] + ")");
182+
}
183+
184+
for (let i = 0; i < discrepancy[1].length; i++) {
185+
clustAfter.push(this._allAxes.getEventByEventId(discrepancy[1][i]).getTokens() + " (" + discrepancy[1][i] + ")");
186+
}
183187

184188
Swal.fire({
185189
icon: "info",
186-
title: 'Implicit Relation Update!',
190+
title: 'Implicit Cluster Update!',
187191
html:
188-
'<p>Your last selection has changed the relation between two events.<br/><br/>' +
189-
'The relation currently set between the events: ' +
190-
'<span style=\"color:orangered; font-weight: bold;\">' + disRootEdge + '</span> and ' +
191-
'<span style=\"color:orangered; font-weight: bold;\">' + disOtherEdge + '</span> is ' +
192-
'<span style=\"color:royalblue; font-weight: bold;\">' + currentRelation + '</span>. ' +
193-
'However, due to your last selection, the events can now be inferred as having a ' +
194-
'<span style=\"color:royalblue; font-weight: bold;\">' + inferredRelation + '</span> relation. ' +
195-
'This will be updated automatically to maintain consistency with your last selection.<br/><br/>' +
196-
'<span style=\"font-weight: bold;\">Please ensure this is correct (note that the change is not reflected yet in the graph visualization), ' +
197-
'approve selection by clicking the "Next" button again.</span>' +
192+
'<p>Your last selection has impacted two clusters.<br/><br/>' +
193+
'Before your selection, the following events were considered to refer to the same real-world event: ' +
194+
'<span style=\"color:orangered; font-weight: bold;\">' + clustBefore + '</span>. ' +
195+
'However, after your current selection, the following update has occurred, and these events are now considered to refer to the same real-world event: ' +
196+
'<span style=\"color:royalblue; font-weight: bold;\">' + clustAfter + '</span>.<br/>' +
197+
'This update will be applied automatically to maintain consistency with your last selection.<br/><br/>' +
198+
'<span style=\"font-weight: bold;\">Please ensure this is correct (note that the change is not yet reflected in the graph visualization), ' +
199+
'approve selection by clicking the "Next" or "Next Unhandled" button again.</span>' +
198200
'</p>',
199201

200202
showCancelButton: false,

public/forms/temporal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ class TemporalForm extends UIForm {
186186
}
187187

188188
if (this.isRelationChanged(pair.getRelation(), combSelect)) {
189-
let axisById = this._allAxes.getAxisById(pair.getAxisId());
189+
let mainAxis = this._allAxes.getMainAxis();
190190
const firstId = pair.getFirstId();
191191
const secondId = pair.getSecondId();
192-
this._discrepancy = axisById.handleFormRelations(firstId, secondId, combSelect, this.formType);
192+
this._discrepancy = mainAxis.handleFormRelations(firstId, secondId, combSelect, this.formType);
193193
if (this._discrepancy.length > 0) {
194194
this.handleDiscrepancies(this._discrepancy[0]);
195195
pair.setRelation(combSelect);
@@ -454,8 +454,8 @@ class TemporalForm extends UIForm {
454454
const event1 = this._allAxes.getEventByEventId(this._selectedNodes[0]);
455455
const event2 = this._allAxes.getEventByEventId(this._selectedNodes[1]);
456456
const eventAxisId = this._allAxes.getEventAxisId(event1);
457-
let axisById = this._allAxes.getAxisById(eventAxisId);
458-
const allPairs = axisById.getAxisGraph().exportAllReachAndTransGraphPairs(eventAxisId);
457+
let mainAxis = this._allAxes.getMainAxis();
458+
const allPairs = mainAxis.getAxisGraph().exportAllReachAndTransGraphPairs(eventAxisId);
459459
index = this.findPair(allPairs);
460460
if(this._allAxes.isValidPair(event1, event2)) {
461461
this._annotationIndex = this._annotations.length;

public/objects/all_axes_logic.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ class AllAxes {
151151
for (let i = 0; i < allEvents.length; i++) {
152152
if (mainAxis.getEventIds().has(allEvents[i].getId())) {
153153
finalEvents.push(allEvents[i]);
154-
break;
155154
}
156155
}
157156

0 commit comments

Comments
 (0)