Skip to content

Instantly share code, notes, and snippets.

@halfak
Created June 6, 2017 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halfak/10183548a4d754935481b9bddf9544e8 to your computer and use it in GitHub Desktop.
Save halfak/10183548a4d754935481b9bddf9544e8 to your computer and use it in GitHub Desktop.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Score precache response format for ORES (v3)",
"type": "object",
"properties": {
"warnings": {
"description": "A list of warnings raised while generating a response",
"items": {
"$ref": "#/definitions/ErrorWarningDocument"
},
"type": "array"
},
"error": {
"$ref": "#/definitions/ErrorWarningDocument"
}
},
"additionalProperties": {
"$ref": "#/definitions/ContextDocument"
},
"definitions": {
"ContextDocument": {
"description": "A mapping of scores and model information",
"type": "object",
"properties": {
"scores": {
"description": "The scores generated.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/RevisionScoresDocument"
}
},
"models": {
"description": "The models with information requested.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/ModelInfoDocument"
}
}
}
},
"ErrorWarningDocument": {
"description": "A warning or error message.",
"type": "object",
"properties": {
"type": {
"description": "A short string identifying the error",
"type": "string"
},
"message": {
"description": "A human-readable explanation of what went wrong",
"type": "string"
}
}
},
"ModelInfoDocument": {
"description": "Information about the model",
"type": "object",
"properties": {
"version": {
"description": "A semantic version string",
"type": "string"
},
"trained": {
"description": "The datetime at which the model was trained (in seconds since Jan. 1st 1970)",
"type": "number"
},
"params": {
"description": "A list of parameters used when constructing the model",
"additionalProperties": true,
"type": "object"
},
"type": {
"description": "The type of model used to score",
"type": "string"
},
"test_stats": {
"description": "A list of test statistics used on the model.",
"additionalProperties": true,
"type": "object"
}
}
},
"RevisionScoresDocument": {
"type": "object",
"description": "A collection of scores for a single revision (or an error)",
"additionalProperties": {
"$ref": "#/definitions/ModelScoreDocument"
}
},
"ModelScoreDocument": {
"type": "object",
"properties": {
"features": {
"description": "A mapping of feature names to the values generated in scoring",
"additionalProperties": {
"type": [
"number",
"boolean",
"array"
]
},
"type": "object"
},
"score": {
"description": "The generated score",
"additionalProperties": {
"type": [
"number",
"string",
"boolean",
"array",
"object"
]
},
"type": "object"
},
"error": {
"description": "The an error generated while trying to generate a score",
"type": "object",
"$ref": "#/definitions/ErrorWarningDocument"
}
}
}
}
}
@halfak
Copy link
Author

halfak commented Jun 6, 2017

Validates against https://ores.wikimedia.org/v3/scores/enwiki/2

{
  "enwiki": {
    "models": {
      "damaging": {
        "version": "0.3.0"
      },
      "draftquality": {
        "version": "0.0.1"
      },
      "goodfaith": {
        "version": "0.3.0"
      },
      "reverted": {
        "version": "0.3.0"
      },
      "wp10": {
        "version": "0.5.0"
      }
    },
    "scores": {
      "2": {
        "damaging": {
          "error": {
            "message": "RevisionNotFound: Could not find revision ({revision}:2)",
            "type": "RevisionNotFound"
          }
        },
        "draftquality": {
          "error": {
            "message": "RevisionNotFound: Could not find revision ({revision}:2)",
            "type": "RevisionNotFound"
          }
        },
        "goodfaith": {
          "error": {
            "message": "RevisionNotFound: Could not find revision ({revision}:2)",
            "type": "RevisionNotFound"
          }
        },
        "reverted": {
          "error": {
            "message": "RevisionNotFound: Could not find revision ({revision}:2)",
            "type": "RevisionNotFound"
          }
        },
        "wp10": {
          "error": {
            "message": "RevisionNotFound: Could not find revision ({revision}:2)",
            "type": "RevisionNotFound"
          }
        }
      }
    }
  }
}

And https://ores.wikimedia.org/v3/scores/enwiki/781154471

{
  "enwiki": {
    "models": {
      "damaging": {
        "version": "0.3.0"
      },
      "draftquality": {
        "version": "0.0.1"
      },
      "goodfaith": {
        "version": "0.3.0"
      },
      "reverted": {
        "version": "0.3.0"
      },
      "wp10": {
        "version": "0.5.0"
      }
    },
    "scores": {
      "781154471": {
        "damaging": {
          "score": {
            "prediction": true,
            "probability": {
              "false": 0.054307439234872024,
              "true": 0.945692560765128
            }
          }
        },
        "draftquality": {
          "score": {
            "prediction": "OK",
            "probability": {
              "OK": 0.9810709736581131,
              "attack": 0.0006846993767415235,
              "spam": 0.009949582893064926,
              "vandalism": 0.008294744072080232
            }
          }
        },
        "goodfaith": {
          "score": {
            "prediction": false,
            "probability": {
              "false": 0.9315315190813148,
              "true": 0.06846848091868515
            }
          }
        },
        "reverted": {
          "score": {
            "prediction": true,
            "probability": {
              "false": 0.04262343907101196,
              "true": 0.957376560928988
            }
          }
        },
        "wp10": {
          "score": {
            "prediction": "FA",
            "probability": {
              "B": 0.0700491337327893,
              "C": 0.030694531038553623,
              "FA": 0.5762056078795728,
              "GA": 0.3167543037816635,
              "Start": 0.005066343424624012,
              "Stub": 0.0012300801427969764
            }
          }
        }
      }
    }
  }
}

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