@@ -50,7 +50,7 @@ import { Row } from './Row'
50
50
import { RectBox } from './RectBox'
51
51
import { AttributeType , ValType } from './AttributeType'
52
52
import { CollectionLoadedResponse } from './CollectionLoadedResponse'
53
- import { RelationTypeDto , EntityTypeDto , EntityDto , CommentDto , SourceData , TriggerDto , AttributeDto , EquivDto , ColorCode , MarkerType , MarkerDto , RelationDto , EDITED , FOCUS , MATCH_FOCUS , MATCH , RoleDto , VID } from '../protocol/Protocol'
53
+ import { RelationTypeDto , EntityTypeDto , EntityDto , CommentDto , SourceData , TriggerDto , AttributeDto , EquivDto , ColorCode , MarkerType , MarkerDto , RelationDto , EDITED , FOCUS , MATCH_FOCUS , MATCH , RoleDto , VID , WARN } from '../protocol/Protocol'
54
54
import type { Dispatcher , Message } from '../dispatcher/Dispatcher'
55
55
import * as jsonpatch from 'fast-json-patch'
56
56
import { Operation } from 'fast-json-patch'
@@ -349,50 +349,60 @@ export class Visualizer {
349
349
}
350
350
351
351
setMarked ( docData : DocumentData , sourceData : SourceData , markedType : MarkerType ) {
352
- if ( ! this . args [ markedType ] ) {
352
+ if ( ! this . data || ! this . args [ markedType ] ) {
353
353
return
354
354
}
355
355
356
356
for ( const marker of this . args [ markedType ] ) {
357
+ // Sentence marker
357
358
if ( marker [ 0 ] === 'sent' ) {
358
359
docData . markedSent [ marker [ 1 ] ] = true
359
360
continue
360
361
}
361
362
362
- if ( marker [ 0 ] === 'equiv' ) { // [equiv, Equiv, T1]
363
- for ( const equiv of sourceData . equivs ) {
364
- if ( equiv [ 1 ] === marker [ 1 ] ) {
365
- let len = equiv . length
366
- for ( let i = 2 ; i < len ; i ++ ) {
367
- if ( equiv [ i ] === marker [ 2 ] ) {
368
- // found it
369
- len -= 3
370
- for ( let n = 1 ; n <= len ; n ++ ) {
371
- const arc = docData . eventDescs [ equiv [ 0 ] + '*' + n ] . equivArc
372
- arc . marked = markedType
373
- }
374
- continue // next equiv
375
- }
376
- }
377
- }
378
- }
379
-
363
+ // INCEpTION does not use equivs, so we should not need this
364
+ // if (marker[0] === 'equiv') { // [equiv, Equiv, T1]
365
+ // for (const equiv of sourceData.equivs) {
366
+ // if (equiv[1] === marker[1]) {
367
+ // let len = equiv.length
368
+ // for (let i = 2; i < len; i++) {
369
+ // if (equiv[i] === marker[2]) {
370
+ // // found it
371
+ // len -= 3
372
+ // for (let n = 1; n <= len; n++) {
373
+ // const arc = docData.eventDescs[equiv[0] + '*' + n].equivArc
374
+ // arc.marked = markedType
375
+ // }
376
+ // continue // next equiv
377
+ // }
378
+ // }
379
+ // }
380
+ // }
381
+
382
+ // continue
383
+ // }
384
+
385
+ if ( ! Array . isArray ( marker ) ) {
380
386
continue
381
387
}
382
388
389
+ // Text marker
383
390
if ( marker . length === 2 ) {
384
- this . markedText . push ( [ parseInt ( marker [ 0 ] , 10 ) , parseInt ( marker [ 1 ] , 10 ) , markedType ] )
391
+ const begin = parseInt ( marker [ 0 ] , 10 )
392
+ const end = parseInt ( marker [ 1 ] , 10 )
393
+ this . markedText . push ( [ begin , end , markedType ] )
385
394
continue
386
395
}
387
396
397
+ // Annotation marker (span or arc)
388
398
const span = this . data . spans [ marker [ 0 ] ]
389
399
if ( span ) {
390
400
if ( marker . length === 3 ) { // arc
391
- $ . each ( span . outgoing , ( arcNo , arc ) => {
401
+ for ( const arc of span . outgoing ) {
392
402
if ( arc . target === marker [ 2 ] && arc . type === marker [ 1 ] ) {
393
- arc . marked = markedType
403
+ arc . marked = markedType ;
394
404
}
395
- } )
405
+ }
396
406
} else { // span
397
407
span . marked = markedType
398
408
}
@@ -438,9 +448,10 @@ export class Visualizer {
438
448
applyHighlighting ( docData : DocumentData , sourceData : SourceData ) {
439
449
this . markedText = [ ]
440
450
this . setMarked ( docData , sourceData , EDITED ) // set by editing process
441
- this . setMarked ( docData , sourceData , FOCUS ) // set by URL
442
451
this . setMarked ( docData , sourceData , MATCH_FOCUS ) // set by search process, focused match
443
452
this . setMarked ( docData , sourceData , MATCH ) // set by search process, other (non-focused) match
453
+ this . setMarked ( docData , sourceData , WARN ) // set by editing process
454
+ this . setMarked ( docData , sourceData , FOCUS ) // set by URL
444
455
}
445
456
446
457
/**
@@ -1289,7 +1300,6 @@ export class Visualizer {
1289
1300
textMeasureGroup . addClass ( cssClass )
1290
1301
}
1291
1302
1292
- // changed from $.each because of #264 ('length' can appear)
1293
1303
for ( const text in textsHash ) {
1294
1304
if ( Object . prototype . hasOwnProperty . call ( textsHash , text ) ) {
1295
1305
this . svg . plain ( text ) . addTo ( textMeasureGroup )
@@ -1360,8 +1370,9 @@ export class Visualizer {
1360
1370
// Adjust for the browser collapsing whitespace
1361
1371
let lastCharSpace = true
1362
1372
let collapsedSpaces = 0
1373
+ const tc = text . textContent || "" ;
1363
1374
for ( let i = 0 ; i < fragment [ 2 ] ; i ++ ) {
1364
- const c = text . textContent [ i ]
1375
+ const c = tc [ i ]
1365
1376
if ( / \s / . test ( c ) ) {
1366
1377
if ( lastCharSpace ) {
1367
1378
collapsedSpaces ++
@@ -1637,8 +1648,8 @@ export class Visualizer {
1637
1648
let width = 5
1638
1649
let height = 5
1639
1650
let color = 'black'
1640
- if ( $ . isNumeric ( parsedSpec [ 1 ] ) && parsedSpec [ 2 ] ) {
1641
- if ( $ . isNumeric ( parsedSpec [ 2 ] ) && parsedSpec [ 3 ] ) {
1651
+ if ( ! isNaN ( parseFloat ( parsedSpec [ 1 ] ) ) && parsedSpec [ 2 ] ) {
1652
+ if ( ! isNaN ( parseFloat ( parsedSpec [ 2 ] ) ) && parsedSpec [ 3 ] ) {
1642
1653
// 3 args, 2 numeric: assume width, height, color
1643
1654
width = parseFloat ( parsedSpec [ 1 ] )
1644
1655
height = parseFloat ( parsedSpec [ 2 ] )
@@ -1734,7 +1745,8 @@ export class Visualizer {
1734
1745
const thisCurlyHeight = span . drawCurly ? Configuration . visual . curlyHeight : 0
1735
1746
const height = docData . sizes . fragments . height + thisCurlyHeight + Configuration . visual . boxSpacing +
1736
1747
2 * Configuration . visual . margin . y - 3
1737
- $ . each ( floors , ( floorNo , floor ) => {
1748
+
1749
+ for ( const floor in floors ) {
1738
1750
let floorAvailable = true
1739
1751
for ( let i = i1 ; i <= i2 ; i ++ ) {
1740
1752
if ( ! ( reservations [ i ] && reservations [ i ] [ floor ] ) ) {
@@ -1760,7 +1772,7 @@ export class Visualizer {
1760
1772
} else {
1761
1773
carpet = null
1762
1774
}
1763
- } )
1775
+ }
1764
1776
1765
1777
const reslen = reservations . length
1766
1778
const makeNewFloorIfNeeded = function ( floor : number ) {
@@ -1919,7 +1931,7 @@ export class Visualizer {
1919
1931
hh -= 2 * this . boxTextMargin . y
1920
1932
xx += this . boxTextMargin . x
1921
1933
ww -= 2 * this . boxTextMargin . x
1922
- let rectClass = 'span_' + ( span . cue || span . type ) + ' span_default' // TODO XXX first part unneeded I think; remove
1934
+ let rectClass = 'span_default'
1923
1935
1924
1936
// attach e.g. "False_positive" into the type
1925
1937
if ( span . comment && span . comment . type ) {
@@ -2196,18 +2208,18 @@ export class Visualizer {
2196
2208
}
2197
2209
2198
2210
// open text highlights
2199
- $ . each ( chunk . markedTextStart , ( textNo , textDesc ) => {
2200
- textDesc [ 3 ] += currentX + ( this . rtlmode ? - boxX : boxX )
2201
- openTextHighlights [ textDesc [ 0 ] ] = textDesc
2202
- } )
2211
+ for ( const textDesc of chunk . markedTextStart ) {
2212
+ textDesc [ 3 ] += currentX + ( this . rtlmode ? - boxX : boxX ) ;
2213
+ openTextHighlights [ textDesc [ 0 ] ] = textDesc ;
2214
+ }
2203
2215
2204
2216
// close text highlights
2205
- $ . each ( chunk . markedTextEnd , ( textNo , textDesc ) => {
2206
- textDesc [ 3 ] += currentX + ( this . rtlmode ? - boxX : boxX )
2207
- const startDesc = openTextHighlights [ textDesc [ 0 ] ]
2208
- delete openTextHighlights [ textDesc [ 0 ] ]
2209
- textMarkedRows . push ( [ row , startDesc [ 3 ] , textDesc [ 3 ] , startDesc [ 4 ] ] )
2210
- } )
2217
+ for ( const textDesc of chunk . markedTextEnd ) {
2218
+ textDesc [ 3 ] += currentX + ( this . rtlmode ? - boxX : boxX ) ;
2219
+ const startDesc = openTextHighlights [ textDesc [ 0 ] ] ;
2220
+ delete openTextHighlights [ textDesc [ 0 ] ] ;
2221
+ textMarkedRows . push ( [ row , startDesc [ 3 ] , textDesc [ 3 ] , startDesc [ 4 ] ] ) ;
2222
+ }
2211
2223
2212
2224
// XXX check this - is it used? should it be lastRow?
2213
2225
if ( hasAnnotations ) {
@@ -3975,23 +3987,24 @@ export class Visualizer {
3975
3987
}
3976
3988
}
3977
3989
3978
- loadAttributeTypes ( responseTypes ) {
3979
- const processed = { }
3980
- $ . each ( responseTypes , ( aTypeNo , aType ) => {
3981
- processed [ aType . type ] = aType
3982
- // count the values; if only one, it's a boolean attribute
3983
- const values : string [ ] = [ ]
3984
- for ( const i in aType . values ) {
3985
- if ( Object . prototype . hasOwnProperty . call ( aType . values , i ) ) {
3986
- values . push ( i )
3987
- }
3988
- }
3989
- if ( values . length === 1 ) {
3990
- aType . bool = values [ 0 ]
3991
- }
3992
- } )
3993
- return processed
3994
- }
3990
+ // INCEpTION does not use event attributes and entity attributes
3991
+ // loadAttributeTypes (responseTypes) {
3992
+ // const processed = {}
3993
+ // for (const type of responseTypes) {
3994
+ // processed[type.type] = type
3995
+ // // count the values; if only one, it's a boolean attribute
3996
+ // const values: string[] = []
3997
+ // for (const i in type.values) {
3998
+ // if (Object.prototype.hasOwnProperty.call(type.values, i)) {
3999
+ // values.push(i)
4000
+ // }
4001
+ // }
4002
+ // if (values.length === 1) {
4003
+ // type.bool = values[0]
4004
+ // }
4005
+ // }
4006
+ // return processed
4007
+ // }
3995
4008
3996
4009
loadRelationTypes ( relationTypes : RelationTypeDto [ ] ) {
3997
4010
for ( const relType of relationTypes ) {
0 commit comments