File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 173173 function changeDataset ( ) {
174174 if ( this . selectedIndex > 0 ) {
175175 parser . readJson ( `./data/data${ this . selectedIndex } .json` , function ( ) {
176- console . log ( parser ) ;
177176 var words = parser . tokens . map ( ( token , i ) => new Word ( token , i ) ) ;
177+ [ ] . concat ( parser . data . entities , parser . data . triggers ) . forEach ( el => {
178+ if ( words [ el . tokenIndex ] ) {
179+ words [ el . tokenIndex ] . tag = el . type ;
180+ }
181+ } ) ;
178182 resetDrawing ( words , [ ] ) ;
183+ console . log ( parser ) ;
179184 } ) ;
180185 }
181186 } ;
184189 draw . clear ( ) ;
185190 rowGroup = draw . group ( ) ;
186191 groupAllElements = linkG = textG = arrowG = undefined ;
187- dragElem = null ;
188192 isDragging = false ;
189193 rowOffsetX = 0 ;
190194 rowOffsetWord = null ;
191195 prevX = - 1 ;
196+ styles = setupStyles ( draw ) ; //creates an associative array of whatever
197+ dragElem = null ;
192198
193199 rows = [ ] ;
194200 wordObjs = words || createTestWords ( 5 , 6 , 10 ) ;
Original file line number Diff line number Diff line change @@ -39,18 +39,23 @@ class Parser {
3939 parseData ( data ) {
4040 /* first get string tokens from the syntaxData */
4141 this . text = data . syntaxData . text ;
42+
43+ const offsets = { } ;
4244 this . tokens = data . syntaxData . entities
4345 . map ( x => x [ 2 ] [ 0 ] )
4446 . sort ( ( a , b ) => a [ 0 ] - b [ 0 ] )
45- . map ( interval => this . text . substring ( interval [ 0 ] , interval [ 1 ] ) ) ;
47+ . map ( ( interval , i ) => {
48+ offsets [ interval [ 0 ] ] = i ;
49+ return this . text . substring ( interval [ 0 ] , interval [ 1 ] ) ;
50+ } ) ;
4651
4752 /* parse the event data: entities, triggers, events, and relations */
4853 const e = data . eventData ;
4954 const entities = e . entities . map ( arr => {
5055 return {
5156 id : arr [ 0 ] ,
5257 type : arr [ 1 ] ,
53- interval : arr [ 2 ] [ 0 ] ,
58+ tokenIndex : offsets [ arr [ 2 ] [ 0 ] [ 0 ] ] ,
5459 string : e . text . substring ( arr [ 2 ] [ 0 ] [ 0 ] , arr [ 2 ] [ 0 ] [ 1 ] )
5560 } ;
5661 } ) ;
@@ -59,7 +64,7 @@ class Parser {
5964 return {
6065 id : arr [ 0 ] ,
6166 type : arr [ 1 ] ,
62- interval : arr [ 2 ] [ 0 ] ,
67+ tokenIndex : offsets [ arr [ 2 ] [ 0 ] [ 0 ] ] ,
6368 string : e . text . substring ( arr [ 2 ] [ 0 ] [ 0 ] , arr [ 2 ] [ 0 ] [ 1 ] )
6469 } ;
6570 } ) ;
You can’t perform that action at this time.
0 commit comments