Skip to content

Commit beafa70

Browse files
committed
Fixed display of annotation focus class highlights when a set definition is available #190
1 parent db90d2b commit beafa70

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

flat/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "0.11.4"
1+
VERSION = "0.11.5"

flat/script/flat.viewer.js

+18-15
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,17 @@ function getspantext(annotation, explicit) {
253253

254254
function getclasslabel_helper(c, key) {
255255
var label = key;
256-
c.subclasses.forEach(function(subc){
257-
if (label != key) return;
258-
if (subc.id == key) {
259-
label = subc.label;
260-
return;
261-
}
262-
label = getclasslabel_helper(subc, key);
263-
if (label != key) return;
264-
});
256+
if (c.subclasses) {
257+
c.subclasses.forEach(function(subc){
258+
if (label != key) return;
259+
if (subc.id == key) {
260+
label = subc.label;
261+
return;
262+
}
263+
label = getclasslabel_helper(subc, key);
264+
if (label != key) return;
265+
});
266+
}
265267
return label;
266268
}
267269

@@ -915,8 +917,9 @@ function computeclassfreq() {
915917
if ((!configuration.colorbyfreq) && (setdefinitions[annotation.set]) && (setdefinitions[annotation.set].classes)) {
916918
//not a real class frequency, simply assign the rank number
917919
var i = -1;
918-
for (i = 0; i < setdefinitions[annotation.set].classes.length; i++) {
919-
if (setdefinitions[annotation.set].classes[i].id == annotation.class) {
920+
for (var c in setdefinitions[annotation.set].classes) {
921+
i += 1;
922+
if (c == annotation.class) {
920923
break;
921924
}
922925
}
@@ -938,14 +941,14 @@ function computeclassfreq() {
938941
}
939942

940943
function setclasscolors() {
941-
//count class distribution
944+
//count class distribution and assign colours based on rank
942945

943946
var legendtype = annotationfocus.type;
944947
var legendset = annotationfocus.set;
945948
var legendtitle = folia_label(legendtype, legendset);
946949
var classfreq = computeclassfreq();
947950

948-
s = "<span class=\"title\">Legend &bull; " + legendtitle + "</span>"; //text for legend
951+
var s = "<span class=\"title\">Legend &bull; " + legendtitle + "</span>"; //text for legend
949952
s = s + "(<a href=\"javascript:removeclasscolors(true)\">Hide</a>)<br />";
950953
classrank = {};
951954
currentrank = 1;
@@ -960,6 +963,8 @@ function setclasscolors() {
960963
}
961964
});
962965

966+
$('#legend').html(s);
967+
$('#legend').show();
963968

964969
forallannotations(function(structureelement, annotation){
965970
if ((annotation.type == annotationfocus.type) && (annotation.set == annotationfocus.set) && (annotation.class)) {
@@ -985,8 +990,6 @@ function setclasscolors() {
985990
}
986991
});
987992

988-
$('#legend').html(s);
989-
$('#legend').show();
990993
}
991994

992995
function showdeletions() {

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def read(fname):
2020

2121
setup(
2222
name = "FoLiA-Linguistic-Annotation-Tool",
23-
version = "0.11.4", #Also change in flat/__init__.py !!
23+
version = "0.11.5", #Also change in flat/__init__.py !!
2424
author = "Maarten van Gompel",
2525
author_email = "[email protected]",
2626
description = ("FLAT is a web-based linguistic annotation environment based around the FoLiA format (https://proycon.github.io/folia), a rich XML-based format for linguistic annotation. Flat allows users to view annotated FoLiA documents and enrich these documents with new annotations, a wide variety of linguistic annotation types is supported through the FoLiA paradigm."),

0 commit comments

Comments
 (0)