{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "道德经八十一章四级知识网站数据包",
  "description": "校验将六个数据文件组装成的对象。跨文件引用、编号唯一、引文真实性、关系比例及内容正确性另须语义校验。",
  "type": "object",
  "required": [
    "global",
    "units",
    "chapters",
    "relations",
    "concepts",
    "versions"
  ],
  "properties": {
    "global": {
      "$ref": "#/definitions/global"
    },
    "units": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/unit"
      },
      "minItems": 8,
      "maxItems": 8
    },
    "chapters": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/chapter"
      },
      "minItems": 81,
      "maxItems": 81
    },
    "relations": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/relation"
      },
      "minItems": 243,
      "maxItems": 648
    },
    "concepts": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/concept"
      },
      "minItems": 10
    },
    "versions": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/versionComparison"
      },
      "minItems": 0
    }
  },
  "additionalProperties": true,
  "definitions": {
    "chapterNumber": {
      "type": "integer",
      "minimum": 1,
      "maximum": 81
    },
    "unitId": {
      "type": "string",
      "enum": [
        "u1",
        "u2",
        "u3",
        "u4",
        "u5",
        "u6",
        "u7",
        "u8"
      ]
    },
    "conceptId": {
      "type": "string",
      "enum": [
        "dao",
        "de",
        "wuwei",
        "ziran",
        "rou",
        "bu-zheng",
        "fan",
        "you-wu",
        "xuantong",
        "sanbao",
        "zhizu",
        "jing",
        "pu",
        "zhi",
        "ming",
        "shen",
        "ci",
        "qian",
        "tian-dao"
      ]
    },
    "chapterList": {
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 1,
        "maximum": 81
      },
      "minItems": 1,
      "maxItems": 81,
      "uniqueItems": true
    },
    "range": {
      "type": "array",
      "items": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 81
        },
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 81
        }
      ],
      "minItems": 2,
      "maxItems": 2,
      "additionalItems": false
    },
    "misreading": {
      "type": "object",
      "properties": {
        "claim": {
          "type": "string",
          "minLength": 1
        },
        "correction": {
          "type": "string",
          "minLength": 1
        },
        "chapters": {
          "$ref": "#/definitions/chapterList"
        }
      },
      "required": [
        "claim",
        "correction"
      ],
      "additionalProperties": true
    },
    "interpretation": {
      "type": "object",
      "properties": {
        "topic": {
          "type": "string",
          "minLength": 1
        },
        "mainstream": {
          "type": "string",
          "minLength": 1
        },
        "alternative": {
          "type": "string",
          "minLength": 1
        },
        "editorial": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "topic",
        "mainstream",
        "alternative",
        "editorial"
      ],
      "additionalProperties": true
    },
    "textualSegment": {
      "type": "object",
      "properties": {
        "quote": {
          "type": "string",
          "minLength": 1
        },
        "explanation": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "quote",
        "explanation"
      ],
      "additionalProperties": true
    },
    "relationSource": {
      "type": "object",
      "properties": {
        "from_quote": {
          "type": "string",
          "minLength": 1
        },
        "to_quote": {
          "type": "string",
          "minLength": 1
        },
        "reference": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "from_quote",
        "to_quote",
        "reference"
      ],
      "additionalProperties": true
    },
    "relationInChapter": {
      "type": "object",
      "properties": {
        "to": {
          "type": "integer",
          "minimum": 1,
          "maximum": 81
        },
        "type": {
          "type": "string",
          "enum": [
            "承接",
            "开启",
            "递进",
            "对比",
            "呼应",
            "因果",
            "总纲—分述",
            "互文",
            "反衬"
          ]
        },
        "strength": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "$ref": "#/definitions/relationSource"
        }
      },
      "required": [
        "to",
        "type",
        "strength",
        "reason",
        "source"
      ],
      "additionalProperties": true,
      "not": {
        "required": [
          "from"
        ]
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "strength": {
                "maximum": 2
              }
            },
            "required": [
              "strength"
            ]
          },
          "then": {
            "properties": {
              "reason": {
                "type": "string",
                "pattern": "弱关联"
              }
            }
          }
        }
      ]
    },
    "relation": {
      "type": "object",
      "properties": {
        "from": {
          "type": "integer",
          "minimum": 1,
          "maximum": 81
        },
        "to": {
          "type": "integer",
          "minimum": 1,
          "maximum": 81
        },
        "type": {
          "type": "string",
          "enum": [
            "承接",
            "开启",
            "递进",
            "对比",
            "呼应",
            "因果",
            "总纲—分述",
            "互文",
            "反衬"
          ]
        },
        "strength": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "$ref": "#/definitions/relationSource"
        }
      },
      "required": [
        "from",
        "to",
        "type",
        "strength",
        "reason",
        "source"
      ],
      "additionalProperties": true,
      "allOf": [
        {
          "if": {
            "properties": {
              "strength": {
                "maximum": 2
              }
            },
            "required": [
              "strength"
            ]
          },
          "then": {
            "properties": {
              "reason": {
                "type": "string",
                "pattern": "弱关联"
              }
            }
          }
        }
      ]
    },
    "versionSummary": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "wangbi",
            "silk",
            "guodian"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "date": {
          "type": "string",
          "minLength": 1
        },
        "order": {
          "type": "string",
          "minLength": 1
        },
        "coverage": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "pattern": "^https?://[^\\s]+$"
        }
      },
      "required": [
        "id",
        "name",
        "date",
        "order",
        "coverage",
        "description",
        "source"
      ],
      "additionalProperties": true
    },
    "versionComparison": {
      "type": "object",
      "properties": {
        "chapter": {
          "type": "integer",
          "minimum": 1,
          "maximum": 81
        },
        "topic": {
          "type": "string",
          "minLength": 1
        },
        "received": {
          "type": "string",
          "minLength": 1
        },
        "silk_a": {
          "type": "string",
          "minLength": 1
        },
        "silk_b": {
          "type": "string",
          "minLength": 1
        },
        "guodian": {
          "type": "string",
          "minLength": 1
        },
        "note": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "pattern": "^https?://[^\\s]+$"
        }
      },
      "required": [
        "chapter",
        "topic",
        "received",
        "silk_a",
        "silk_b",
        "guodian",
        "note",
        "source"
      ],
      "additionalProperties": true
    },
    "originalSource": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "pattern": "^https?://[^\\s]+$"
        },
        "revision": {
          "type": [
            "integer",
            "string"
          ]
        },
        "anchor": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "url",
        "revision",
        "anchor"
      ],
      "additionalProperties": true
    },
    "sections": {
      "type": "object",
      "properties": {
        "textual": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/textualSegment"
          },
          "minItems": 2
        },
        "philosophical": {
          "type": "string",
          "minLength": 1
        },
        "practice": {
          "type": "string",
          "minLength": 1
        },
        "management": {
          "type": "string",
          "minLength": 1
        },
        "governance": {
          "type": "string",
          "minLength": 1
        },
        "misreadings": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/misreading"
          },
          "minItems": 1
        }
      },
      "required": [
        "textual",
        "philosophical",
        "practice",
        "management",
        "governance",
        "misreadings"
      ],
      "additionalProperties": true
    },
    "chapter": {
      "type": "object",
      "properties": {
        "number": {
          "type": "integer",
          "minimum": 1,
          "maximum": 81
        },
        "title": {
          "type": "string",
          "minLength": 4,
          "maxLength": 8
        },
        "original": {
          "type": "string",
          "minLength": 1
        },
        "unit": {
          "type": "string",
          "enum": [
            "u1",
            "u2",
            "u3",
            "u4",
            "u5",
            "u6",
            "u7",
            "u8"
          ]
        },
        "translation": {
          "type": "string",
          "minLength": 1
        },
        "core": {
          "type": "string",
          "minLength": 80
        },
        "keywords": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 3,
          "maxItems": 5,
          "uniqueItems": true
        },
        "sections": {
          "$ref": "#/definitions/sections"
        },
        "interpretations": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/interpretation"
          },
          "minItems": 0
        },
        "versions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/versionComparison"
          },
          "minItems": 0
        },
        "concepts": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "dao",
              "de",
              "wuwei",
              "ziran",
              "rou",
              "bu-zheng",
              "fan",
              "you-wu",
              "xuantong",
              "sanbao",
              "zhizu",
              "jing",
              "pu",
              "zhi",
              "ming",
              "shen",
              "ci",
              "qian",
              "tian-dao"
            ]
          },
          "minItems": 2,
          "maxItems": 19,
          "uniqueItems": true
        },
        "relations": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/relationInChapter"
          },
          "minItems": 3,
          "maxItems": 8
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "original_source": {
          "$ref": "#/definitions/originalSource"
        }
      },
      "required": [
        "number",
        "title",
        "original",
        "unit",
        "translation",
        "core",
        "keywords",
        "sections",
        "interpretations",
        "versions",
        "concepts",
        "relations",
        "summary"
      ],
      "additionalProperties": true,
      "allOf": [
        {
          "if": {
            "properties": {
              "number": {
                "minimum": 1,
                "maximum": 6
              }
            },
            "required": [
              "number"
            ]
          },
          "then": {
            "properties": {
              "unit": {
                "const": "u1"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "number": {
                "minimum": 7,
                "maximum": 13
              }
            },
            "required": [
              "number"
            ]
          },
          "then": {
            "properties": {
              "unit": {
                "const": "u2"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "number": {
                "minimum": 14,
                "maximum": 20
              }
            },
            "required": [
              "number"
            ]
          },
          "then": {
            "properties": {
              "unit": {
                "const": "u3"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "number": {
                "minimum": 21,
                "maximum": 27
              }
            },
            "required": [
              "number"
            ]
          },
          "then": {
            "properties": {
              "unit": {
                "const": "u4"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "number": {
                "minimum": 28,
                "maximum": 37
              }
            },
            "required": [
              "number"
            ]
          },
          "then": {
            "properties": {
              "unit": {
                "const": "u5"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "number": {
                "minimum": 38,
                "maximum": 46
              }
            },
            "required": [
              "number"
            ]
          },
          "then": {
            "properties": {
              "unit": {
                "const": "u6"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "number": {
                "minimum": 47,
                "maximum": 56
              }
            },
            "required": [
              "number"
            ]
          },
          "then": {
            "properties": {
              "unit": {
                "const": "u7"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "number": {
                "minimum": 57,
                "maximum": 81
              }
            },
            "required": [
              "number"
            ]
          },
          "then": {
            "properties": {
              "unit": {
                "const": "u8"
              }
            }
          }
        }
      ]
    },
    "unit": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "u1",
            "u2",
            "u3",
            "u4",
            "u5",
            "u6",
            "u7",
            "u8"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "range": {
          "$ref": "#/definitions/range"
        },
        "theme": {
          "type": "string",
          "minLength": 1
        },
        "core_question": {
          "type": "string",
          "minLength": 1
        },
        "keywords": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1,
          "maxItems": 10,
          "uniqueItems": true
        },
        "logic": {
          "type": "string",
          "minLength": 1
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "relations": {
          "type": "object",
          "properties": {
            "previous": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "u1",
                    "u2",
                    "u3",
                    "u4",
                    "u5",
                    "u6",
                    "u7",
                    "u8"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "next": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "u1",
                    "u2",
                    "u3",
                    "u4",
                    "u5",
                    "u6",
                    "u7",
                    "u8"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "previous",
            "next",
            "description"
          ],
          "additionalProperties": true
        }
      },
      "required": [
        "id",
        "name",
        "range",
        "theme",
        "core_question",
        "keywords",
        "logic",
        "summary",
        "relations"
      ],
      "additionalProperties": true,
      "allOf": [
        {
          "if": {
            "properties": {
              "id": {
                "const": "u1"
              }
            },
            "required": [
              "id"
            ]
          },
          "then": {
            "properties": {
              "range": {
                "const": [
                  1,
                  6
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "id": {
                "const": "u2"
              }
            },
            "required": [
              "id"
            ]
          },
          "then": {
            "properties": {
              "range": {
                "const": [
                  7,
                  13
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "id": {
                "const": "u3"
              }
            },
            "required": [
              "id"
            ]
          },
          "then": {
            "properties": {
              "range": {
                "const": [
                  14,
                  20
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "id": {
                "const": "u4"
              }
            },
            "required": [
              "id"
            ]
          },
          "then": {
            "properties": {
              "range": {
                "const": [
                  21,
                  27
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "id": {
                "const": "u5"
              }
            },
            "required": [
              "id"
            ]
          },
          "then": {
            "properties": {
              "range": {
                "const": [
                  28,
                  37
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "id": {
                "const": "u6"
              }
            },
            "required": [
              "id"
            ]
          },
          "then": {
            "properties": {
              "range": {
                "const": [
                  38,
                  46
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "id": {
                "const": "u7"
              }
            },
            "required": [
              "id"
            ]
          },
          "then": {
            "properties": {
              "range": {
                "const": [
                  47,
                  56
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "id": {
                "const": "u8"
              }
            },
            "required": [
              "id"
            ]
          },
          "then": {
            "properties": {
              "range": {
                "const": [
                  57,
                  81
                ]
              }
            }
          }
        }
      ]
    },
    "concept": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "dao",
            "de",
            "wuwei",
            "ziran",
            "rou",
            "bu-zheng",
            "fan",
            "you-wu",
            "xuantong",
            "sanbao",
            "zhizu",
            "jing",
            "pu",
            "zhi",
            "ming",
            "shen",
            "ci",
            "qian",
            "tian-dao"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "english": {
          "type": "string",
          "minLength": 1
        },
        "definition": {
          "type": "string",
          "minLength": 40,
          "maxLength": 80
        },
        "first_appearance": {
          "type": "integer",
          "minimum": 1,
          "maximum": 81
        },
        "chapters": {
          "$ref": "#/definitions/chapterList"
        },
        "key_chapters": {
          "$ref": "#/definitions/chapterList"
        },
        "evolution": {
          "type": "string",
          "minLength": 1
        },
        "related": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "dao",
              "de",
              "wuwei",
              "ziran",
              "rou",
              "bu-zheng",
              "fan",
              "you-wu",
              "xuantong",
              "sanbao",
              "zhizu",
              "jing",
              "pu",
              "zhi",
              "ming",
              "shen",
              "ci",
              "qian",
              "tian-dao"
            ]
          },
          "minItems": 1,
          "maxItems": 19,
          "uniqueItems": true
        },
        "misreading": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "id",
        "name",
        "english",
        "definition",
        "first_appearance",
        "chapters",
        "evolution",
        "related",
        "misreading"
      ],
      "additionalProperties": true
    },
    "globalConcept": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "definition": {
          "type": "string",
          "minLength": 40,
          "maxLength": 80
        },
        "chapters": {
          "$ref": "#/definitions/chapterList"
        },
        "evolution": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "name",
        "definition",
        "chapters",
        "evolution"
      ],
      "additionalProperties": true
    },
    "readingPath": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "enum": [
            "philosophy",
            "self",
            "management",
            "politics",
            "literature"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "subtitle": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "chapters": {
          "$ref": "#/definitions/chapterList"
        },
        "steps": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1,
          "maxItems": 81
        }
      },
      "required": [
        "id",
        "name",
        "subtitle",
        "description",
        "chapters",
        "steps"
      ],
      "additionalProperties": true
    },
    "global": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "formation": {
          "type": "string",
          "minLength": 1
        },
        "structure": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "enum": [
                  "道经",
                  "德经"
                ]
              },
              "range": {
                "$ref": "#/definitions/range"
              },
              "description": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "name",
              "range",
              "description"
            ],
            "additionalProperties": true
          },
          "minItems": 2,
          "maxItems": 2
        },
        "principles": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "minLength": 1
              },
              "chapter": {
                "type": "integer",
                "minimum": 1,
                "maximum": 81
              },
              "description": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "title",
              "chapter",
              "description"
            ],
            "additionalProperties": true
          },
          "minItems": 4
        },
        "concepts": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/globalConcept"
          },
          "minItems": 10
        },
        "reading_paths": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/readingPath"
          },
          "minItems": 5,
          "maxItems": 5
        },
        "versions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/versionSummary"
          },
          "minItems": 3,
          "maxItems": 3
        },
        "commentaries": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "period": {
                "type": "string",
                "minLength": 1
              },
              "description": {
                "type": "string",
                "minLength": 1
              },
              "source": {
                "type": "string",
                "pattern": "^https?://[^\\s]+$"
              }
            },
            "required": [
              "name",
              "period",
              "description",
              "source"
            ],
            "additionalProperties": true
          },
          "minItems": 5
        },
        "misreadings": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/misreading"
          },
          "minItems": 3
        },
        "editorial_note": {
          "type": "string",
          "minLength": 1
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "minLength": 1
              },
              "url": {
                "type": "string",
                "pattern": "^https?://[^\\s]+$"
              }
            },
            "required": [
              "title",
              "url"
            ],
            "additionalProperties": true
          },
          "minItems": 1
        }
      },
      "required": [
        "title",
        "summary",
        "formation",
        "structure",
        "principles",
        "concepts",
        "reading_paths",
        "versions",
        "commentaries",
        "misreadings",
        "editorial_note",
        "sources"
      ],
      "additionalProperties": true
    }
  }
}