Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions schemas/model.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"timestamp": "2026-10-05T12:00:00Z",
"name": "nertoy-261005",
"family": "NERToy",
"operations": ["ner"],
"depends_on": [],
"files": [
{
"name": "nertoy-261005.zip",
"url": "https://ufal.mff.cuni.cz/~strakova/linpipe_repo/nertoy-261005/nertoy-261005.zip",
"unpack": true,
"sha256": "d8d7e2bca79d41f8ae1859a29fd04175b474a80cfbbd71f7eccb8694791515a1",
"size": 188
}
]
}
99 changes: 99 additions & 0 deletions schemas/model.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/schemas/model.schema.json",
"title": "model",
"description": "Configuration of a single LinPipe model. Besides the fields listed here, a model may carry any number of model-specific parameters (e.g. 'tagsets').",
"type": "object",
"properties": {
"timestamp": {
"description": "When this config was generated (ISO 8601 date-time).",
"type": "string",
"format": "date-time"
},
"name": {
"description": "Model name; should match its key in models.json.",
"type": "string",
"minLength": 1
},
"family": {
"description": "The model family this model belongs to.",
"type": "string",
"minLength": 1
},
"languages": {
"description": "Languages the model supports.",
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"uniqueItems": true,
"minItems": 1
},
"operations": {
"description": "Kinds of operations the model can respond to.",
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"uniqueItems": true,
"minItems": 1
},
"depends_on": {
"description": "Names of other models that this model depends on.",
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"uniqueItems": true,
"default": []
},
"files": {
"description": "Files that belong to the model, usually a single archive to download and unpack.",
"type": "array",
"items": {
"$ref": "#/$defs/file"
},
"minItems": 1
}
},
"required": ["timestamp", "name", "files"],
"additionalProperties": true,

"$defs": {
"file": {
"type": "object",
"properties": {
"name": {
"description": "File name, as stored locally after download.",
"type": "string",
"minLength": 1
},
"url": {
"description": "Where to download the file from.",
"type": "string",
"format": "uri"
},
"unpack": {
"description": "Whether the file is an archive that should be unpacked after download.",
"type": "boolean",
"default": false
},
"sha256": {
"description": "SHA-256 checksum of the file, as 64 hex characters.",
"type": "string",
"pattern": "^[0-9a-fA-F]{64}$"
},
"size": {
"description": "File size in bytes.",
"type": "integer",
"minimum": 0
}
},
"required": ["name", "url", "sha256", "size"],
"additionalProperties": false
}
}
}
12 changes: 12 additions & 0 deletions schemas/models.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"timestamp": "2026-10-05T12:00:00Z",
"models": {
"nertoy-261005": {
"url": "https://ufal.mff.cuni.cz/~strakova/linpipe_repo/nertoy-261005/model.json",
"family": "NERToy",
"date": "2026-10-05",
"operations": ["ner"],
"depends_on": []
}
}
}
86 changes: 86 additions & 0 deletions schemas/models.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/schemas/models.schema.json",
"title": "models",
"description": "A timestamped collection of LinPipe models, keyed by model name.",
"type": "object",
"properties": {
"timestamp": {
"description": "When this document was generated (ISO 8601 date-time).",
"type": "string",
"format": "date-time"
},
"models": {
"description": "Map of model name to model details.",
"type": "object",
"propertyNames": {
"minLength": 1
},
"additionalProperties": {
"$ref": "#/$defs/model"
}
}
},
"required": [
"timestamp",
"models"
],
"additionalProperties": false,
"$defs": {
"model": {
"type": "object",
"properties": {
"url": {
"description": "Link to the model's JSON config.",
"type": "string",
"format": "uri"
},
"family": {
"description": "The model family this model belongs to.",
"type": "string",
"minLength": 1
},
"languages": {
"description": "Languages the model supports.",
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"uniqueItems": true,
"minItems": 1
},
"date": {
"description": "Release date of the model (ISO 8601 date, YYYY-MM-DD).",
"type": "string",
"format": "date"
},
"operations": {
"description": "Operations the model can respond to.",
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"uniqueItems": true,
"minItems": 1
},
"depends_on": {
"description": "Names of other models (keys in the top-level 'models' map) that this model depends on.",
"type": "array",
"items": {
"type": "string",
"minLength": 1
},
"uniqueItems": true,
"default": []
}
},
"required": [
"url",
"date"
],
"additionalProperties": false
}
}
}
3 changes: 3 additions & 0 deletions src/models/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

LINPIPE_OBJECTS += models/model
LINPIPE_OBJECTS += models/model_hub
LINPIPE_OBJECTS += models/model_manager
LINPIPE_OBJECTS += models/ner_toy

LINPIPE_TESTS += models/model_hub_test
2 changes: 1 addition & 1 deletion src/models/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const std::string& Model::name() {
}

std::unique_ptr<Model> Model::create(std::string& name, std::istream& input) {
if (name == "ner_toy") return std::make_unique<models::NERToy>(name, input);
if (name == "NERToy") return std::make_unique<models::NERToy>(name, input);

throw LinpipeError{"Model::create: Cannot load model of uknown name '", name, "'"};
}
Expand Down
Loading
Loading