Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kasnerz committed Dec 23, 2024
1 parent 6662225 commit 999d419
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 19 deletions.
8 changes: 7 additions & 1 deletion factgenie/static/js/campaigns.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ function createLLMCampaign() {
const config = gatherConfig();
var campaignData = gatherSelectedCombinations();

// if no annotation categories are created, show an alert
if (mode != "llm_gen" && config.annotationSpanCategories.length == 0) {
alert("Please add at least one annotation span category.");
return;
}

// if no datasets are selected, show an alert
if (campaignData.length == 0) {
alert("Please select at least one existing combination of dataset, split, and output.");
Expand Down Expand Up @@ -635,7 +641,7 @@ function updateLLMMetricConfig() {
$("#annotation-span-categories").empty();

annotationSpanCategories.forEach((annotationSpanCategory) => {
createAnnotationSpanCategoryElem(annotationSpanCategory.name, annotationSpanCategory.description, annotationSpanCategory.color);
addAnnotationSpanCategory(annotationSpanCategory.name, annotationSpanCategory.description, annotationSpanCategory.color);
});
}
if (mode == "llm_gen") {
Expand Down
52 changes: 36 additions & 16 deletions factgenie/static/js/example-annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function createButtons() {
});

const label = $('<label>', {
class: "btn btn-err-cat-label me-1",
class: "btn btn-err-cat-label me-1",
for: `btnradio${idx}`,
style: `background-color: ${category.color};`
}).text(category.name);
Expand All @@ -94,25 +94,45 @@ function createButtons() {

$('#buttons-area').append(input);
$('#buttons-area').append(label);
}

// Add eraser button
const eraserInput = $('<input>', {
type: "radio",
class: "btn-check btn-outline-secondary btn-eraser",
name: "btnradio",
id: "btnradioeraser",
autocomplete: "off",
"data-cat-idx": "-1"
});

const eraserLabel = $('<label>', {
class: "btn btn-err-cat-label ms-auto",
for: "btnradioeraser",
style: "background-color: #FFF; color: #000 !important;"
}).text("Erase mode");

$('#buttons-area').append(eraserInput);
$('#buttons-area').append(eraserLabel);

// Event handlers
$(".btn-err-cat, .btn-eraser").change(function () {
if (this.checked) {
const cat_idx = $(this).attr("data-cat-idx");
spanAnnotator.setCurrentAnnotationType(cat_idx);
}
});

$(".btn-err-cat").change(function () {
$('.btn-check').on('change', function () {
$('.btn-check').each(function () {
const label = $(`label[for=${this.id}]`);
if (this.checked) {
const cat_idx = $(this).attr("data-cat-idx");
spanAnnotator.setCurrentAnnotationType(cat_idx);
label.addClass('active');
} else {
label.removeClass('active');
}
});

$('.btn-check').on('change', function () {
$('.btn-check').each(function () {
const label = $(`label[for=${this.id}]`);
if (this.checked) {
label.addClass('active');
} else {
label.removeClass('active');
}
});
});
}
});
}

function initAnnotation() {
Expand Down
3 changes: 3 additions & 0 deletions factgenie/static/js/span-annotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ class SpanAnnotator {
const doc = this.documents.get(objectId);
const position = parseInt($span.data('index'));

const removedAnnotations = doc.annotations.filter(a =>
position >= a.start && position < a.start + a.text.length);

doc.annotations = doc.annotations.filter(a =>
position < a.start || position >= a.start + a.text.length);

Expand Down
2 changes: 1 addition & 1 deletion factgenie/templates/crowdsourcing/annotate_body.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h2 class="accordion-header">
<input type="radio" class="btn-check btn-outline-secondary btn-eraser" name="btnradio"
id="btnradioeraser" autocomplete="off" data-cat-idx="-1">
<label class="btn btn-err-cat-label ms-auto" for="btnradioeraser" style="background-color: #FFF; color: #000 !important;">
Eraser mode
Erase mode
</label>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion factgenie/templates/pages/crowdsourcing_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ <h3>New crowdsourcing campaign</h3>
value="1" required>
</div>
<div class="form-group mt-4">
<!-- select for sort order -->
<label for="annotationGranularity">Annotation granularity</label>
<div class="mb-2">
<small class="form-text text-muted">The smallest unit annotators can annotate.</small>
Expand Down

0 comments on commit 999d419

Please sign in to comment.