Skip to content

Instantly share code, notes, and snippets.

@sam-writer
Created June 12, 2019 21:18
Show Gist options
  • Save sam-writer/2e549af40fb7a269f67783f0f9a14d2f to your computer and use it in GitHub Desktop.
Save sam-writer/2e549af40fb7a269f67783f0f9a14d2f to your computer and use it in GitHub Desktop.
Spacy Match and Replace Schema
{
"title": "Schema for validation Qordoba Spacy Match/Replace format",
"type": "object",
"definitions": {
"spacyMatch": {
"type": "array",
"items": {
"$ref": "#/definitions/spacyAttribute"
},
"minItems": 1
},
"spacyAttribute": {
"type": "object",
"properties": {
"ORTH": {
"$ref": "#/definitions/spacyValue"
},
"TEXT": {
"$ref": "#/definitions/spacyValue"
},
"LOWER": {
"$ref": "#/definitions/spacyValue"
},
"LENGTH": {
"$ref": "#/definitions/spacyValue"
},
"POS": {
"$ref": "#/definitions/spacyValue"
},
"TAG": {
"$ref": "#/definitions/spacyValue"
},
"DEP": {
"$ref": "#/definitions/spacyValue"
},
"SHAPE": {
"$ref": "#/definitions/spacyValue"
},
"ENT_TYPE": {
"$ref": "#/definitions/spacyValue"
},
"OP": {
"enum": [
"!",
"?",
"*",
"+"
]
}
},
"patternProperties": {
"^IS_[A-Z]*$": {
"type": "boolean"
}
}
},
"spacyOperator": {
"type": "object",
"additionalProperties": false,
"properties": {
"REGEX": {
"type": "string"
},
"IN": {
"type": "array",
"items": {
"type": "string"
}
},
"NOT_IN": {
"type": "array",
"items": {
"type": "string"
}
},
"==": {
"type": "number"
},
">=": {
"type": "number"
},
">": {
"type": "number"
},
"<=": {
"type": "number"
},
"<": {
"type": "number"
}
}
},
"spacyValue": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
},
{
"$ref": "#/definitions/spacyOperator"
}
]
}
},
"patternProperties": {
"^[a-z_][A-Za-z0-9_]*$": {
"type": "object",
"properties": {
"patterns": {
"type": "array",
"items": {
"$ref": "#/definitions/spacyMatch"
},
"minItems": 1
}
},
"required": [
"patterns",
"suggestions"
]
}
}
}
@sam-writer
Copy link
Author

For VS Code integration with a given service located at path/to/service/... if it doesn't already exist, create path/to/service/.vscode/settings.json. In that file, add:

{
    // ... other settings
    "json.schemas": [
        {
            "fileMatch": [
                "file_to_validate.json"
            ],
            "url": "https://gist.githubusercontent.com/sam-qordoba/2e549af40fb7a269f67783f0f9a14d2f/raw/2e58582d14636d2282d6b524cd4ef1714aa53973/spacy_match_replace_schema.json"
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment