@@ -29,34 +29,62 @@ class CorefForm extends OneToManyForm {
29
29
super . loadForm ( ) ;
30
30
}
31
31
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
+
32
43
handleEventSelection ( currentFocusEvent , checkedItems , uncheckedItems ) {
33
- let discrepancies = [ ] ;
44
+ let allEventClustersBefore = new Set ( ) ;
45
+ this . addToCorefSet ( Array . from ( this . _allAxes . getMainAxis ( ) . getEventIds ( ) ) , allEventClustersBefore ) ;
34
46
47
+ const axis = this . _allAxes . getMainAxis ( ) ;
35
48
// Handle focused with all in list
36
49
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 ) ;
39
51
}
40
52
41
53
// Handle all in list that coref with focused (should coref to eachother)
42
54
for ( let i = 0 ; i < checkedItems . length ; i ++ ) {
43
55
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 ) ;
46
57
}
47
58
}
48
59
49
60
// Handle focused with all unchecked items
50
61
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 ) ;
53
63
}
54
64
55
65
// Handle all unchecked/checked items (should not coref to each-other)
56
66
for ( let i = 0 ; i < uncheckedItems . length ; i ++ ) {
57
67
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
+ }
60
88
}
61
89
}
62
90
0 commit comments