OCR-D / spec

Specification of the @OCR-D technical architecture, interface definitions and data exchange format(s)
https://ocr-d.de/en/spec/
17 stars 5 forks source link

describing ocrd-tool.json parameter object properties, rev'std #229

Open bertsky opened 1 year ago

bertsky commented 1 year ago

Since #206 we can moderately restrict an ocrd-tool parameter of type object's properties and even set additionalProperties:

https://github.com/OCR-D/spec/blob/506b33936d89080a683fa8a26837f2a23b23e5e2/ocrd_tool.schema.yml#L95-L100

However, according to the JSON data schema, additionalProperties is either false or an object (i.e. dict) itself.

For example, in ocrd-kraken-recognize I'd like to have:

        "blla_classes": {
          "description": "Class mapping for the region types trained into blla_model.",
          "type": "object",
          "minProperties": 2,
          "additionalProperties": { "type": "string",
                                    "enum": ["TextRegion", "ImageRegion", "LineDrawingRegion",
                                             "GraphicRegion", "TableRegion", "ChartRegion",
                                             "MapRegion", "SeparatorRegion", "MathsRegion",
                                             "ChemRegion", "MusicRegion", "AdvertRegion",
                                             "NoiseRegion", "UnknownRegion", "CustomRegion"] },
          "default": {"text": "TextRegion", "image": "ImageRegion", "line drawing": "LineDrawingRegion",
                      "graphic": "GraphicRegion", "table": "TableRegion", "chart": "ChartRegion",
                      "map": "MapRegion", "separator": "SeparatorRegion", "maths": "MathsRegion",
                      "chem": "ChemRegion", "music": "MusicRegion", "advert": "AdvertRegion",
                      "noise": "NoiseRegion", "unknown": "UnknownRegion", "custom": "CustomRegion"}

That is: allow only certain types of properties (namely all PAGE-XML region type names).

This is currently not possible to express.

Also, minProperties and maxProperties is missing entirely.