Skip to content

Commit

Permalink
Fixed display of annotation focus class highlights when a set definit…
Browse files Browse the repository at this point in the history
…ion is available #190
  • Loading branch information
proycon committed Jul 5, 2024
1 parent db90d2b commit beafa70
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion flat/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.11.4"
VERSION = "0.11.5"
33 changes: 18 additions & 15 deletions flat/script/flat.viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,17 @@ function getspantext(annotation, explicit) {

function getclasslabel_helper(c, key) {
var label = key;
c.subclasses.forEach(function(subc){
if (label != key) return;
if (subc.id == key) {
label = subc.label;
return;
}
label = getclasslabel_helper(subc, key);
if (label != key) return;
});
if (c.subclasses) {
c.subclasses.forEach(function(subc){
if (label != key) return;
if (subc.id == key) {
label = subc.label;
return;
}
label = getclasslabel_helper(subc, key);
if (label != key) return;
});
}
return label;
}

Expand Down Expand Up @@ -915,8 +917,9 @@ function computeclassfreq() {
if ((!configuration.colorbyfreq) && (setdefinitions[annotation.set]) && (setdefinitions[annotation.set].classes)) {
//not a real class frequency, simply assign the rank number
var i = -1;
for (i = 0; i < setdefinitions[annotation.set].classes.length; i++) {
if (setdefinitions[annotation.set].classes[i].id == annotation.class) {
for (var c in setdefinitions[annotation.set].classes) {
i += 1;
if (c == annotation.class) {
break;
}
}
Expand All @@ -938,14 +941,14 @@ function computeclassfreq() {
}

function setclasscolors() {
//count class distribution
//count class distribution and assign colours based on rank

var legendtype = annotationfocus.type;
var legendset = annotationfocus.set;
var legendtitle = folia_label(legendtype, legendset);
var classfreq = computeclassfreq();

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

$('#legend').html(s);
$('#legend').show();

forallannotations(function(structureelement, annotation){
if ((annotation.type == annotationfocus.type) && (annotation.set == annotationfocus.set) && (annotation.class)) {
Expand All @@ -985,8 +990,6 @@ function setclasscolors() {
}
});

$('#legend').html(s);
$('#legend').show();
}

function showdeletions() {
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def read(fname):

setup(
name = "FoLiA-Linguistic-Annotation-Tool",
version = "0.11.4", #Also change in flat/__init__.py !!
version = "0.11.5", #Also change in flat/__init__.py !!
author = "Maarten van Gompel",
author_email = "[email protected]",
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."),
Expand Down

0 comments on commit beafa70

Please sign in to comment.