From 2c234b9676337555aec1db7c2f2bcb5f1a105f55 Mon Sep 17 00:00:00 2001 From: southeo Date: Fri, 31 May 2024 11:47:48 +0200 Subject: [PATCH] Web batch annotations (#93) * Web batch annotations * example * add examples --- .../example-annotation-event-for-web.json | 36 ++++ .../schema/annotation-event-for-web.json | 189 ++++++++++++++++++ .../0.1.0/schema/annotation-event.json | 18 +- .../0.1.0/schema/batch-metadata.json | 41 ++++ 4 files changed, 270 insertions(+), 14 deletions(-) create mode 100644 data-model/annotations/0.1.0/examples/example-annotation-event-for-web.json create mode 100644 data-model/annotations/0.1.0/schema/annotation-event-for-web.json create mode 100644 data-model/annotations/0.1.0/schema/batch-metadata.json diff --git a/data-model/annotations/0.1.0/examples/example-annotation-event-for-web.json b/data-model/annotations/0.1.0/examples/example-annotation-event-for-web.json new file mode 100644 index 0000000..9687a36 --- /dev/null +++ b/data-model/annotations/0.1.0/examples/example-annotation-event-for-web.json @@ -0,0 +1,36 @@ +{ + "data": { + "type": "annotation", + "attributes": { + "annotations": [ + { + "oa:motivation": "oa:commenting", + "oa:target": { + "ods:id": "https://hdl.handle.net/20.500.125/1111111", + "ods:type": "https://doi.org/21.T11148/894b1e6cad57e921764e", + "oa:selector": { + "ods:type": "ClassSelector", + "oa:class": "specimenName" + } + }, + "oa:body": { + "ods:type": "body", + "oa:value": [], + "dcterms:reference": "reference", + "ods:score": 0.9 + } + } + ], + "batchMetadata": [ + { + "searchParams": [ + { + "inputField": "field", + "inputValue": "value" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/data-model/annotations/0.1.0/schema/annotation-event-for-web.json b/data-model/annotations/0.1.0/schema/annotation-event-for-web.json new file mode 100644 index 0000000..847599b --- /dev/null +++ b/data-model/annotations/0.1.0/schema/annotation-event-for-web.json @@ -0,0 +1,189 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://schemas.dissco.tech/schemas/annotations/0.1.0/annotation-event-for-web.json", + "description": "Web batch annotation. For DiSSCo internal use only.", + "$comment": "Fewer fields are required in this schema because these requests are sent to the backend for processing.", + "properties": { + "data": { + "type": "object", + "properties": { + "type": { + "const": "annotation" + }, + "attributes": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object", + "properties": { + "ods:id": { + "type": "string" + }, + "rdf:type": { + "const": "Annotation" + }, + "oa:motivation": { + "enum": [ + "ods:adding", + "oa:assessing", + "oa:editing", + "oa:commenting" + ] + }, + "oa:motivatedBy": { + "type": "string" + }, + "oa:target": { + "type": "object", + "properties": { + "ods:id": { + "type": "string" + }, + "ods:type": { + "type": "string" + }, + "oa:selector": { + "type": "object", + "oneOf": [ + { + "type": "object", + "properties": { + "ods:type": { + "const": "FieldSelector" + }, + "ods:field": { + "type": "string" + } + }, + "required": [ + "ods:type", + "ods:field" + ] + }, + { + "type": "object", + "properties": { + "ods:type": { + "const": "ClassSelector" + }, + "oa:class": { + "type": "string" + } + }, + "required": [ + "ods:type", + "oa:class" + ] + }, + { + "type": "object", + "properties": { + "ods:type": { + "const": "FragmentSelector" + }, + "ac:hasRoi": { + "type": "object", + "properties": { + "ac:xFrac": { + "type": "number", + "minimum": 0, + "maximum": 1 + }, + "ac:yFrac": { + "type": "number", + "minimum": 0, + "maximum": 1 + }, + "ac:widthFrac": { + "type": "number", + "minimum": 0, + "maximum": 1 + }, + "ac:heightFrac": { + "type": "number", + "minimum": 0, + "maximum": 1 + } + }, + "required": [ + "ac:xFrac", + "ac:yFrac", + "ac:widthFrac", + "ac:heightFrac" + ] + }, + "dcterms:conformsTo": { + "type": "string" + } + }, + "required": [ + "ods:type", + "ac:hasRoi" + ] + } + ] + } + }, + "required": [ + "ods:id", + "ods:type" + ] + }, + "oa:body": { + "type": "object", + "properties": { + "ods:type": { + "type": "string" + }, + "oa:value": { + "type": "array" + }, + "dcterms:reference": { + "type": "string" + }, + "ods:score": { + "type": "number", + "minimum": 0, + "maximum": 1 + } + }, + "required": [ + "ods:type", + "oa:value" + ] + } + }, + "required": [ + "oa:motivation", + "oa:target", + "oa:body" + ] + }, + "minItems": 1, + "maxItems": 1 + }, + "batchMetadata": { + "type": "array", + "items": { + "$ref": "https://schemas.dissco.tech/schemas/fdo-types/0.1.0/annotation-batch-metadata.json" + }, + "minItems": 1, + "maxItems": 1 + } + }, + "required": [ + "annotations", + "batchMetadata" + ] + } + }, + "required": [ + "type", + "attributes" + ] + } + } + +} \ No newline at end of file diff --git a/data-model/annotations/0.1.0/schema/annotation-event.json b/data-model/annotations/0.1.0/schema/annotation-event.json index cc7ff69..b850883 100644 --- a/data-model/annotations/0.1.0/schema/annotation-event.json +++ b/data-model/annotations/0.1.0/schema/annotation-event.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.dissco.tech/schemas/annotations/0.1.0/annotation-event.json", - "description": "Object sent to annotation processing service", + "description": "Object sent to annotation processing service from core backend. Internal use only.", "properties": { "annotations": { "type": "array", @@ -16,19 +16,9 @@ "batchMetadata": { "type": "array", "items": { - "type": "object", - "properties": { - "placeInBatch": { - "type": "integer" - }, - "inputField": { - "type": "string" - }, - "inputValue": { - "type": "string" - } - } - } + "$ref": "https://schemas.dissco.tech/schemas/fdo-types/0.1.0/annotation-batch-metadata.json" + }, + "minItems": 1 }, "required": [ "annotations", diff --git a/data-model/annotations/0.1.0/schema/batch-metadata.json b/data-model/annotations/0.1.0/schema/batch-metadata.json new file mode 100644 index 0000000..eba64f7 --- /dev/null +++ b/data-model/annotations/0.1.0/schema/batch-metadata.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://schemas.dissco.tech/schemas/fdo-types/0.1.0/annotation-batch-metadata.json", + "properties": { + "placeInBatch": { + "type": "integer" + }, + "searchParams": { + "type": "array", + "items": { + "type": "object", + "properties": { + "inputField": { + "type": "string", + "description": "JsonPath (mixed notation) of field used to base annotation reasoning on. Indexes must be wildcards", + "examples": [ + "digitalSpecimenWrapper.occurrences[*].location.dwc:country" + ] + }, + "inputValue": { + "type": "string", + "description": "Value stored at the field indicated in inputField", + "examples": [ + "Netherlands" + ] + } + }, + "required": [ + "inputField", + "inputValue" + ] + }, + "minItems": 1 + } + }, + "required": [ + "placeInBatch", + "searchParams" + ], + "additionalProperties": false +} \ No newline at end of file