diff --git a/inception/inception-diam-editor/src/main/java/de/tudarmstadt/ukp/inception/diam/sidebar/DiamSidebarFactoryUserPreferences.schema.json b/inception/inception-diam-editor/src/main/java/de/tudarmstadt/ukp/inception/diam/sidebar/DiamSidebarFactoryUserPreferences.schema.json index 712bbd83d9b..0dde7a48c2e 100644 --- a/inception/inception-diam-editor/src/main/java/de/tudarmstadt/ukp/inception/diam/sidebar/DiamSidebarFactoryUserPreferences.schema.json +++ b/inception/inception-diam-editor/src/main/java/de/tudarmstadt/ukp/inception/diam/sidebar/DiamSidebarFactoryUserPreferences.schema.json @@ -4,7 +4,7 @@ "properties": { "mode": { "type": "string", - "enum": ["by-label", "by-position"] + "enum": ["by-label", "by-position", "by-layer"] }, "sortByScore": { "type": "boolean" diff --git a/inception/inception-diam-editor/src/main/ts/src/AnnotationsByLayerList.svelte b/inception/inception-diam-editor/src/main/ts/src/AnnotationsByLayerList.svelte new file mode 100644 index 00000000000..d908231e2f9 --- /dev/null +++ b/inception/inception-diam-editor/src/main/ts/src/AnnotationsByLayerList.svelte @@ -0,0 +1,221 @@ + + +{#if !data} +
+
+
+ Loading... +
+
+
+{:else} +
+
+ + +
+
+ + +
+
+
+ {#if sortedLayers || sortedLayers?.length} + + {/if} +
+{/if} + + diff --git a/inception/inception-diam-editor/src/main/ts/src/DiamAnnotationBrowser.svelte b/inception/inception-diam-editor/src/main/ts/src/DiamAnnotationBrowser.svelte index 81dc231898c..679af6a063d 100644 --- a/inception/inception-diam-editor/src/main/ts/src/DiamAnnotationBrowser.svelte +++ b/inception/inception-diam-editor/src/main/ts/src/DiamAnnotationBrowser.svelte @@ -31,6 +31,7 @@ } from "./AnnotationBrowserState"; import AnnotationsByPositionList from "./AnnotationsByPositionList.svelte"; import AnnotationsByLabelList from "./AnnotationsByLabelList.svelte"; + import AnnotationsByLayerList from "./AnnotationsByLayerList.svelte"; import AnnotationDetailPopOver from "@inception-project/inception-js-api/src/widget/AnnotationDetailPopOver.svelte" export let wsEndpointUrl: string; @@ -52,6 +53,7 @@ let modes = { "by-position": "Group by position", "by-label": "Group by label", + "by-layer": "Group by layer", }; let tooManyAnnotations = false; @@ -154,6 +156,8 @@ {:else if $groupingMode == "by-position"} + {:else if $groupingMode == "by-layer"} + {:else} {/if} diff --git a/inception/inception-diam-editor/src/main/ts/src/Utils.ts b/inception/inception-diam-editor/src/main/ts/src/Utils.ts index cf32ca6d5d6..23fa0cbfe3b 100644 --- a/inception/inception-diam-editor/src/main/ts/src/Utils.ts +++ b/inception/inception-diam-editor/src/main/ts/src/Utils.ts @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AnnotatedText, Annotation, Offsets, Relation, Span, VID } from '@inception-project/inception-js-api' +import { AnnotatedText, Annotation, Layer, Offsets, Relation, Span, VID } from '@inception-project/inception-js-api' import { compareOffsets } from '@inception-project/inception-js-api/src/model/Offsets' export function renderLabel (ann?: Annotation): string { @@ -29,6 +29,22 @@ export function renderLabel (ann?: Annotation): string { return label } +export function uniqueLayers (data: AnnotatedText): Layer[] { + if (!data) return [] + + const sortedLayersWithDuplicates = Array.from(data.annotations(), (ann) => ann.layer) + .sort((a, b) => a.name.localeCompare(b.name, undefined, { usage: 'sort', sensitivity: 'variant' })) + + const sortedLayers: Layer[] = [] + for (let i = 0; i < sortedLayersWithDuplicates.length; i++) { + if (i === 0 || sortedLayersWithDuplicates[i - 1] !== sortedLayersWithDuplicates[i]) { + sortedLayers.push(sortedLayersWithDuplicates[i]) + } + } + + return sortedLayers +} + export function uniqueLabels (data: AnnotatedText): string[] { if (!data) return []