Skip to content

Commit 7839fc4

Browse files
committed
feat: LEAP-1972: Ensure initial plugins are ready for release
1 parent 1fbd209 commit 7839fc4

File tree

51 files changed

+587
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+587
-431
lines changed

custom-scripts/bulk_labeling/script.js renamed to custom-scripts/bulk-labeling/script.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1+
/**
2+
* Automatically creates all the text regions containing all instances of the selected text.
3+
*/
4+
5+
// It will be triggered when a text selection happens
16
LSI.on('entityCreate', region => {
27
if (window.BULK_REGIONS) return;
8+
39
window.BULK_REGIONS = true;
410
setTimeout(() => window.BULK_REGIONS = false, 1000);
5-
console.log('matches', region.object._value.matchAll(region.text));
11+
612
setTimeout(() => {
13+
// Find all the text regions matching the selection
714
region.object._value.matchAll(new RegExp(region.text, "gi")).forEach(m => {
815
if (m.index === region.startOffset) return;
16+
17+
// Include them in the results as new selections
918
Htx.annotationStore.selected.createResult(
1019
{ text: region.text, start: "/span[1]/text()[1]", startOffset: m.index, end: "/span[1]/text()[1]", endOffset: m.index + region.text.length },
1120
{ labels: [...region.labeling.value.labels] },

custom-scripts/bulk-labeling/view.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<View>
2+
<Labels name="label" toName="text">
3+
<Label value="PER" background="red"/>
4+
<Label value="ORG" background="darkorange"/>
5+
<Label value="LOC" background="orange"/>
6+
<Label value="MISC" background="green"/>
7+
</Labels>
8+
9+
<Text name="text" value="$text"/>
10+
</View>
11+
12+
<!--
13+
{
14+
"data": {
15+
"text": [
16+
"Opossums, commonly known as possums in North America, are marsupials found primarily in the Americas. The most well-known species is the Virginia opossum (Didelphis virginiana), which ranges from Central America and the eastern United States to southern Canada. These adaptable creatures are known for their ability to thrive in a variety of environments, including both rural and urban areas. Opossums are also found in South America, where different species inhabit a range of ecosystems, from tropical rainforests to temperate forests.",
17+
"Opossums are highly adaptable in terms of habitat, often residing in woodlands, farmland, and even suburban backyards. They typically seek shelter in hollow trees, abandoned burrows, or any dark, enclosed space they can find. Opossums are nocturnal and omnivorous, with a diet that includes fruits, insects, small animals, and even carrion. Their opportunistic feeding habits contribute to their resilience and ability to live in close proximity to human settlements.",
18+
"In terms of behavior, opossums are solitary and nomadic, often moving to different locations in search of food. They are known for their unique defense mechanism of 'playing dead' or 'playing possum' when threatened, which involves mimicking the appearance and smell of a sick or dead animal to deter predators. Opossums have relatively short lifespans, typically living only 2 to 4 years in the wild. Despite their short lives, they reproduce quickly, with females giving birth to large litters of up to 20 young, although not all offspring typically survive to maturity.",
19+
"In popular culture, opossums often appear as symbols of resilience and survival due to their hardy nature and ability to adapt to various environments. They are sometimes depicted in a comical or misunderstood light, given their nocturnal habits and somewhat disheveled appearance. Despite this, they play a crucial role in the ecosystem by controlling insect and rodent populations and cleaning up carrion. Opossums have been featured in various forms of media, from cartoons and children's books to movies, often emphasizing their unique behaviors and survival strategies."
20+
]
21+
}
22+
}
23+
-->

custom-scripts/bulk_labeling/view.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"data": {
3+
"text": "The quick brown fox jumps over the lazy dog."
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1+
/**
2+
* Validates the word count of the entered text to prevent submission if it exceeds a specified threshold
3+
*/
4+
15
let dismissed = false;
26

37
LSI.on("beforeSaveAnnotation", (store, annotation) => {
48
const textAreaResult = annotation.results.find(r => r.type === 'textarea' && r.from_name.name === 'textarea');
9+
510
if (textAreaResult) {
611
words = textAreaResult.value.text[0]
712
word_count = words.split(" ").length;
13+
814
if (word_count > 10) {
915
Htx.showModal("Word count is " + word_count + ". Please reduce to 10 or less.");
1016
dismissed = true;
11-
return false;
17+
return false; // Block submission
1218
}
1319
}
14-
return true;
15-
});
20+
21+
return true; // Allow submission
22+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<View>
2+
<Header value="Classify the text in less than 10 words"/>
3+
<Text name="text" value="$text"/>
4+
<TextArea name="textarea" toName="text" />
5+
</View>
6+
7+
<!--
8+
{
9+
"data": {
10+
"text": "The quick brown fox jumps over the lazy dog.",
11+
}
12+
}
13+
-->

custom-scripts/count_words_in_textarea/view.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"data": {
3+
"image": "/static/custom-scripts/custom-scripts/show_different_images_based_on_label_selected/img/demo-sample.png"
4+
}
5+
}

0 commit comments

Comments
 (0)