{
  "$schema": "https://datapackage.org/profiles/2.0/tableschema.json",
  "title": "判定",
  "description": "1 件のエンティティについての、1 件の自動判定です。規則の集まりが出す問いへのモデルの答え（確率付き）と、その結果の行動を持ちます。refersTo、externalReference のどれか 1 つは必須です。属性をまたぐ他の規則は JSON Schema にあります：https://datamodels.jp/schema/decision/Decision/v1.0.0.json。",
  "x-type": "Decision",
  "x-typeIri": "https://datamodels.jp/ns/decision/Decision",
  "x-version": "1.0.0",
  "x-schema": "https://datamodels.jp/schema/decision/Decision/v1.0.0.json",
  "x-context": "https://datamodels.jp/context/decision/v1.jsonld",
  "x-translations": {
    "en": {
      "title": "Decision",
      "description": "One automated decision about one entity: a model's answers to the questions of a rule set, with probabilities, and the resulting action. At least one of refersTo, externalReference is needed. More rules that span attributes are in the JSON Schema: https://datamodels.jp/schema/decision/Decision/v1.0.0.json."
    }
  },
  "fields": [
    {
      "name": "id",
      "title": "エンティティの ID",
      "description": "エンティティの ID（URI。例：urn:ngsi-ld:Decision:001）",
      "type": "string",
      "constraints": {
        "required": true,
        "unique": true
      },
      "x-translations": {
        "en": {
          "title": "Entity id",
          "description": "Entity id: a URI, for example urn:ngsi-ld:Decision:001"
        }
      }
    },
    {
      "name": "refersTo",
      "title": "判定の対象",
      "description": "判定の対象（入力）のエンティティ。refersTo か externalReference のどちらかが必須です。",
      "type": "string",
      "format": "uri",
      "x-iri": "http://www.w3.org/ns/prov#used",
      "x-translations": {
        "en": {
          "title": "The entity the decision is about",
          "description": "The entity the decision is about (the input). One of refersTo or externalReference is required"
        }
      }
    },
    {
      "name": "externalReference",
      "title": "対象がブローカーのエンティティでないときの参照",
      "description": "対象がブローカーのエンティティでないときの参照（例：Issue の URL）",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/decision/externalReference",
      "x-translations": {
        "en": {
          "description": "What the decision is about when it is not an entity in the broker, for example an issue URL"
        }
      }
    },
    {
      "name": "action",
      "title": "規則が出した行動",
      "description": "規則が出した行動。次に何が起きるかを表します（例：auto、review、publish、urgent）。値は規則の集まりが定めます。",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/decision/action",
      "constraints": {
        "required": true
      },
      "x-translations": {
        "en": {
          "description": "The action the rules gave, meaning what happens next (for example auto, review, publish, urgent). The values are defined by the rule set"
        }
      }
    },
    {
      "name": "answers",
      "title": "モデルの答え",
      "description": "モデルの答え。問いごとに 1 つで、それぞれに確率が付きます。各要素は name（問いの名前）、type、value、probability（value の確率）を持ちます。type は noul（はい・いいえ）、choice（選択肢から 1 つ）、score（順序のある段階）のどれかです。choice と score では、probabilities（選択肢や段階ごとの確率）も持ちます。",
      "type": "array",
      "x-iri": "https://datamodels.jp/ns/decision/answers",
      "constraints": {
        "required": true,
        "jsonSchema": {
          "type": "array",
          "minItems": 1,
          "items": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "type",
                  "value",
                  "probability"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Question name, as in the rule set"
                  },
                  "type": {
                    "const": "noul"
                  },
                  "value": {
                    "type": "boolean",
                    "description": "Yes (true) or no (false)"
                  },
                  "probability": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "Probability of this value, as given by the model"
                  }
                },
                "description": "A yes/no answer"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "type",
                  "value",
                  "probability",
                  "probabilities"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Question name, as in the rule set"
                  },
                  "type": {
                    "const": "choice"
                  },
                  "value": {
                    "type": "string",
                    "description": "The chosen option"
                  },
                  "probability": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "Probability of this value, as given by the model"
                  },
                  "probabilities": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "description": "Probability of each option (choice) or level (score)",
                    "minProperties": 1
                  }
                },
                "description": "One option from a list"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "type",
                  "value",
                  "probability",
                  "probabilities"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Question name, as in the rule set"
                  },
                  "type": {
                    "const": "score"
                  },
                  "value": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "The most likely level, from 0 (lowest)"
                  },
                  "probability": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "Probability of this value, as given by the model"
                  },
                  "probabilities": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "description": "Probability of each option (choice) or level (score)",
                    "minProperties": 1,
                    "propertyNames": {
                      "pattern": "^(0|[1-9][0-9]*)$"
                    }
                  }
                },
                "description": "A level on an ordered scale"
              }
            ]
          },
          "description": "The model's answers, one per question, each with its probability"
        }
      },
      "x-translations": {
        "en": {
          "description": "The model's answers, one per question, each with its probability. Each item has name (the question), type (noul for yes or no, choice for one of a list of options, score for a level on an ordered scale), value, probability (of that value) and, for choice and score, probabilities (per option or level)"
        }
      }
    },
    {
      "name": "facts",
      "title": "規則の集まりが求めた空間の事実を、この判定のために調べた結果です",
      "description": "規則の集まりが求めた空間の事実を、この判定のために調べた結果です（当たった規則が使ったかどうかは問いません）。モデルではなく、空間の演算で求めた値です（例：浸水想定区域の中か、最寄りの避難場所までの距離）。各要素は name と missing を持ちます。求められたときは values（項目ごとの値）と source（出どころ）、求められなかったときは reason（no_location、unavailable、timeout、error）も持ちます。求められなかった事実を使う規則は当たりません。",
      "type": "array",
      "x-iri": "https://datamodels.jp/ns/decision/facts",
      "constraints": {
        "jsonSchema": {
          "type": "array",
          "minItems": 1,
          "items": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "missing",
                  "values",
                  "source"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Fact name, as in the rule set"
                  },
                  "missing": {
                    "const": false
                  },
                  "values": {
                    "type": "object",
                    "additionalProperties": {
                      "type": [
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    },
                    "description": "The fact's fields, for example inside, rank and class for an area, or distance_m and name for the nearest feature; null when a field has no value"
                  },
                  "source": {
                    "type": "string",
                    "description": "Where the value came from, for example a layer and its date"
                  }
                },
                "description": "A fact that was looked up"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "missing",
                  "reason"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Fact name, as in the rule set"
                  },
                  "missing": {
                    "const": true
                  },
                  "reason": {
                    "enum": [
                      "no_location",
                      "unavailable",
                      "timeout",
                      "error"
                    ],
                    "description": "Why it is missing: no location in the input, no source configured, too slow, or an error"
                  }
                },
                "description": "A fact that could not be looked up; rules that need it do not match"
              }
            ]
          },
          "description": "Every spatial fact the rule set asks for, as looked up for this decision (whether or not the matching rule used it), computed by spatial operations, not by the model: for example whether the place is inside a flood zone, or the distance to the nearest evacuation site"
        }
      },
      "x-translations": {
        "en": {
          "description": "Every spatial fact the rule set asks for, as looked up for this decision (whether or not the matching rule used it), computed by spatial operations, not by the model (for example inside a flood zone, or the distance to the nearest evacuation site). Each item has name and missing, and either values (per field) and source, or, when it could not be looked up, reason (no_location, unavailable, timeout, error). Rules that need a missing fact do not match"
        }
      }
    },
    {
      "name": "profile",
      "title": "問いを出し、答えを行動に変えた規則の集まりの ID",
      "description": "問いを出し、答えを行動に変えた規則の集まりの ID",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/decision/profile",
      "constraints": {
        "required": true
      },
      "x-translations": {
        "en": {
          "description": "Id of the rule set that asked the questions and turned the answers into the action"
        }
      }
    },
    {
      "name": "profileVersion",
      "title": "規則の集まりの版",
      "description": "規則の集まりの版",
      "type": "integer",
      "x-iri": "https://datamodels.jp/ns/decision/profileVersion",
      "constraints": {
        "required": true,
        "minimum": 1
      },
      "x-translations": {
        "en": {
          "title": "Version of the rule set",
          "description": "Version of the rule set"
        }
      }
    },
    {
      "name": "policyRule",
      "title": "行動を出した規則",
      "description": "行動を出した規則。0 から数えた番号を文字列で書き（\"0\"、\"1\" など）、どの規則にも当たらなかったときは \"default\" です。判定の根拠になります。",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/decision/policyRule",
      "constraints": {
        "pattern": "(0|[1-9][0-9]*|default)"
      },
      "x-translations": {
        "en": {
          "title": "Which rule gave the action",
          "description": "Which rule gave the action: its index from 0 as text (\"0\", \"1\", ...), or \"default\" when no rule matched. The reason for the result"
        }
      }
    },
    {
      "name": "model",
      "title": "答えたモデルの ID",
      "description": "答えたモデルの ID",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/decision/model",
      "constraints": {
        "required": true
      },
      "x-translations": {
        "en": {
          "title": "Id of the model that answered",
          "description": "Id of the model that answered"
        }
      }
    },
    {
      "name": "decidedAt",
      "title": "判定した日時",
      "description": "判定した日時",
      "type": "datetime",
      "x-iri": "http://www.w3.org/ns/prov#endedAtTime",
      "constraints": {
        "required": true
      },
      "x-translations": {
        "en": {
          "title": "When the decision was made",
          "description": "When the decision was made"
        }
      }
    },
    {
      "name": "humanInvolvement",
      "title": "人の関わり方",
      "description": "人の関わり方（W3C DPV の語）：dpv:HumanInvolvementForVerification（行動の前に人が確認する）、dpv:HumanInvolvementForOversight（行動はそのまま行い、人が後から確認・修正できる）、dpv:HumanInvolvementForDecision（人が決め、答えは参考にする）、dpv:HumanNotInvolved（人は関わらない）",
      "type": "string",
      "x-iri": "https://w3id.org/dpv#hasHumanInvolvement",
      "constraints": {
        "enum": [
          "dpv:HumanInvolvementForVerification",
          "dpv:HumanInvolvementForOversight",
          "dpv:HumanInvolvementForDecision",
          "dpv:HumanNotInvolved"
        ]
      },
      "x-translations": {
        "en": {
          "description": "How a person takes part, as a W3C DPV term: dpv:HumanInvolvementForVerification (a person checks before the action is taken), dpv:HumanInvolvementForOversight (the action is taken, and a person can check and correct it later), dpv:HumanInvolvementForDecision (a person decides, and the answers only inform), dpv:HumanNotInvolved"
        }
      }
    },
    {
      "name": "reviewStatus",
      "title": "人による確認の状態",
      "description": "人による確認の状態：pending（確認待ち）か resolved（確認済み）。確認を求めないときは省きます。",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/decision/reviewStatus",
      "constraints": {
        "enum": [
          "pending",
          "resolved"
        ]
      },
      "x-translations": {
        "en": {
          "description": "State of the check by a person, pending or resolved. Absent when no check was asked"
        }
      }
    },
    {
      "name": "finalAction",
      "title": "人が確認した後の行動",
      "description": "人が確認した後の行動",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/decision/finalAction",
      "x-translations": {
        "en": {
          "title": "The action after the check by a person",
          "description": "The action after the check by a person"
        }
      }
    },
    {
      "name": "reviewedBy",
      "title": "確認した人",
      "description": "確認した人。アカウント、役割、チームの識別子で、個人名は入れません。",
      "type": "string",
      "x-iri": "https://datamodels.jp/ns/decision/reviewedBy",
      "x-translations": {
        "en": {
          "description": "Who resolved the check, as an account, role or team identifier, not a personal name"
        }
      }
    },
    {
      "name": "reviewedAt",
      "title": "確認した日時",
      "description": "確認した日時",
      "type": "datetime",
      "x-iri": "https://datamodels.jp/ns/decision/reviewedAt",
      "x-translations": {
        "en": {
          "title": "When the check was resolved",
          "description": "When the check was resolved"
        }
      }
    },
    {
      "name": "corrections",
      "title": "人が直した答え",
      "description": "人が直した答え（モデルの正しさを測るための正解データ）。各要素は name、value、by（識別子）、at を持ち、note は任意です。",
      "type": "array",
      "x-iri": "https://datamodels.jp/ns/decision/corrections",
      "constraints": {
        "jsonSchema": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name",
              "value",
              "by",
              "at"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Question name"
              },
              "value": {
                "type": [
                  "boolean",
                  "string",
                  "integer"
                ],
                "description": "The right answer according to a person"
              },
              "by": {
                "type": "string",
                "description": "Who corrected it: an account or role identifier, not a personal name"
              },
              "at": {
                "type": "string",
                "format": "date-time",
                "description": "When"
              },
              "note": {
                "type": "string",
                "description": "Why, in a sentence"
              }
            }
          },
          "description": "Answers corrected by a person (the ground truth for measuring the model)"
        }
      },
      "x-translations": {
        "en": {
          "title": "Answers corrected by a person",
          "description": "Answers corrected by a person (the ground truth for measuring the model). Each item has name, value, by (an identifier), at and optionally note"
        }
      }
    },
    {
      "name": "wasInformedBy",
      "title": "判定が続いているときの、この判定の前の判定",
      "description": "判定が続いているときの、この判定の前の判定",
      "type": "string",
      "format": "uri",
      "x-iri": "http://www.w3.org/ns/prov#wasInformedBy",
      "x-translations": {
        "en": {
          "description": "The decision this one followed, in a chain of decisions"
        }
      }
    }
  ],
  "primaryKey": [
    "id"
  ],
  "missingValues": [
    ""
  ]
}
