Datasets:

ArXiv:
megawika-2 / schema.md
ccmaymay's picture
Add files using upload-large-folder tool
5889057 verified

MegaWika 2.0 Data Schema

MegaWika 2 is structured as a collection of JSON-lines "chunk" files organized by Wikipedia language. Each chunk file contains a collection of Article objects, one (JSON-encoded) Article per line. What follows is documentation for each type in the schema, starting with Article.

Article

Fields

  • title (string): Article title
    • Ex: "Les Hauts de Hurlevent est l'unique roman d'Emily Brontë ..."
  • wikicode (string): Wikimedia source code for article
    • Ex: "<div id=\"mp_header\" class=\"mp_outerbox\"> ..."
  • hash (string): Hash of title and content
    • Ex: "2c0c3bfb0493fb8ddd5661..."
  • last_revision (string): Datetime of last revision
    • Ex: "2023-12-03T10:50:40Z"
  • first_revision (string | null): Datetime of initial article creation, if it could be retrieved.
    • Ex: "2023-09-04T08:19:40Z"
  • first_revision_access_date (string | null): Datetime first revision was retrieved from Wikipedia Action API
    • Ex: "2023-12-03T10:55:40Z"
  • cross_lingual_links (object[string, string] | null): A dictionary mapping this article onto articles on the same topic in other languages; keys represent language codes, values represent the title of the article in that language.
    • Ex: {"en": "Wuthering Heights", "es": "Cumbres Borrascosas"}
  • cross_lingual_links_access_date (string | null): Datetime cross-lingual links were retrieved from Wikipedia Action API
    • Ex: "2023-12-03T10:56:40Z"
  • text (string): Natural-language text of article
    • Ex: "Les Hauts de Hurlevent est l'unique roman d'Emily Brontë ..."
  • elements (array[Heading | Table | Infobox | Paragraph | Math | Code | Preformatted]): Article structure: paragraphs, text and citation elements, etc.
  • excerpts_with_citations (array[ExcerptWithCitations]): A list of all citations from the article and the associated text excerpts they appear in. This data is a postprocessed subset of the data in the elements list and is provided for convenience.

Citation

Fields

  • content (string): Citation content
    • Ex: "<ref>{{Citation |last=Thomas |first=Darcy |year=2013 ..."
  • char_index (integer): Character index of this citation in the enclosing sentence or excerpt
    • Ex: 39
  • name (string | null): Optional citation name
    • Ex: null
    • Ex: "Thomas2013"
  • url (string | null): Extracted URL, if web citation
    • Ex: "https://example.com/emily-bronte/..."
  • source_text (string | null): Extracted source text, if source download and extraction succeeded
    • Ex: "Emily Brontë avait deux sœurs ..."
  • source_code_content_type (string | null): Downloaded source code content type, if download succeeded and content-type header was received
    • Ex: "text/html"
    • Ex: "text/html; charset=ISO-8859-1"
  • source_code_num_bytes (integer | null): Not used
    • Ex: null
  • source_code_num_chars (integer | null): Size of downloaded source code in characters, if source download succeeded and code can be decoded as text
    • Ex: 100000
  • source_download_date (string | null): Datetime source code was downloaded from the web
    • Ex: "2023-12-03T10:50:40Z"
  • source_download_error (string | null): Source download error message, if there was an error
    • Ex: null
    • Ex: "Download is too large (2.4 MB)"
    • Ex: "ConnectTimeoutError: ..."
  • source_extract_error (string | null): Source extraction error message, if there was an error
    • Ex: null
    • Ex: "Text is too short (50 words)"
    • Ex: "Exception: ..."
  • source_snippet (string | null): A relevant snippet from the source document, excertped manually by Wikipedia editor; stored in the quote field of the relevant citation templates.
    • Ex: "Emily Brontë avait deux sœurs"
  • source_quality_label (integer | null): An integer between 1 and 5 representing the predicted relevance and quality of the text extracted from the source page: 1 is irrelevant content like 404 text and paywalls, 2 is likely irrelevant or unreadable content like a list of headlines or mangled table, 3 is potentially relevant content like a book abstract, 4 is likely relevant content but with some quality issues, and 5 is relevant content that is well-formatted.
    • Ex: 4
  • source_quality_raw_score (number | null): The raw score output by the source quality regression model, generally between 0 and 1. The source quality label is computed from the raw score and has a monotonic but non-linear relationship.
    • Ex: 0.8

Example JSON

{
  "content": "<ref>{{Citation |last=Thomas |first=Darcy |year=2013 ...",
  "char_index": 39,
  "name": null,
  "url": "https://example.com/emily-bronte/...",
  "source_text": "Emily Brontë avait deux sœurs ...",
  "source_code_content_type": "text/html",
  "source_code_num_bytes": null,
  "source_code_num_chars": 100000,
  "source_download_date": "2023-12-03T10:50:40Z",
  "source_download_error": null,
  "source_extract_error": null,
  "source_snippet": "Emily Brontë avait deux sœurs",
  "source_quality_label": 4,
  "source_quality_raw_score": 0.8
}

CitationNeeded

Fields

  • type (const string = "citation-needed"): Used to differentiate from other element types
  • content (string): Citation-needed element content
    • Ex: "{{Citation needed|date=September 2015}}"
  • char_index (integer): Character index of this citation-needed in the enclosing sentence or excerpt
    • Ex: 39

Example JSON

{
  "type": "citation-needed",
  "content": "{{Citation needed|date=September 2015}}",
  "char_index": 39
}

Code

Fields

  • type (const string = "code"): Used to differentiate from other element types
  • language (string | null): Code language (as used for syntax highlighting)
    • Ex: "cpp"
  • content (string): Code block content
    • Ex: "int main() { ..."

Example JSON

{
  "type": "code",
  "language": "cpp",
  "content": "int main() { ..."
}

ExcerptWithCitations

Fields

  • text (string): The text of three consecutive sentences from an article
    • Ex: "Les Hauts de Hurlevent est .... défis à la culture victorienne."
  • translated_text (string | null): English translation of the excerpt text, if not in English Wikipedia
    • Ex: "Wuthering Heights is .... challenges to Victorian culture."
  • citations (array[Citation]): Citation(s) appearing in the final sentence of this excerpt

Heading

Fields

  • type (const string = "heading"): Used to differentiate from other element types
  • text (string): Heading text
    • Ex: "Personnages"
  • translated_text (string | null): English translation of heading text, if not in English Wikipedia
    • Ex: "Characters"
  • level (integer): Heading level (1 being top-level/most general, 6 being bottom-level/most specific)
    • Ex: 2
  • citations (array[Citation]): Citations appearing in this heading
  • citations_needed (array[CitationNeeded]): Citation-needed elements appearing in this heading

Infobox

Fields

  • type (const string = "infobox"): Used to differentiate from other element types
  • content (string): Infobox content
    • Ex: "{{Infobox Livre\n| auteur = Emily Brontë\n...\n}"

Example JSON

{
  "type": "infobox",
  "content": "{{Infobox Livre\n| auteur = Emily Brontë\n...\n}"
}

Math

Fields

  • type (const string = "math"): Used to differentiate from other element types
  • content (string): Math block content
    • Ex: "\\sin 2\\pi x + \\ln e ..."

Example JSON

{
  "type": "math",
  "content": "\\sin 2\\pi x + \\ln e ..."
}

Paragraph

Fields

  • type (const string = "paragraph"): Used to differentiate from other element types
  • sentences (array[Sentence]): List of sentences in this paragraph

Preformatted

Fields

  • type (const string = "preformatted"): Used to differentiate from other element types
  • content (string): Preformatted block content
    • Ex: "____\n|DD|____T_\n|_ |_____|<\n @-@-@-oo\\\n"

Example JSON

{
  "type": "preformatted",
  "content": "____\n|DD|____T_\n|_ |_____|<\n  @-@-@-oo\\\n"
}

Sentence

Fields

  • text (string): Sentence text content
    • Ex: "Les Hauts de Hurlevent est l'unique roman d'Emily Brontë."
  • translated_text (string | null): English translation of sentence text content, if not in English Wikipedia
    • Ex: "Wuthering Heights is the only novel by Emily Brontë."
  • trailing_whitespace (string): If the sentence was originally followed by whitespace, this will be a space. If the sentence was not followed by whitespace (for example, if it was followed by a quotation mark), this will be the empty string.
    • Ex: " "
    • Ex: ""
  • citations (array[Citation]): Citations appearing in this sentence
  • citations_needed (array[CitationNeeded]): Citation-needed elements appearing in this sentence

Table

Fields

  • type (const string = "table"): Used to differentiate from other element types
  • content (string): Table content
    • Ex: "{| class=\"wikitable\"\n|+ Personnages\n|-\n! Nom !! ...\n...\n|}"

Example JSON

{
  "type": "table",
  "content": "{| class=\"wikitable\"\n|+ Personnages\n|-\n! Nom !! ...\n...\n|}"
}