stackoverflow-posts / README.md
mikex86's picture
Update README.md
eb1fd0b
|
raw
history blame
5.55 kB
metadata
license: other
language:
  - code
  - en
task_categories:
  - question-answering
  - text-generation
  - text2text-generation
tags:
  - code
pretty_name: StackOverflow Posts
size_categories:
  - 10M<n<100M

Dataset Summary

This dataset contains all posts submitted to StackOverflow before the 14th of June 2023 formatted as Markdown text.
The dataset contains over 60 Million posts, totaling ~40GB in size and ~65 billion characters of text.
The data is sourced from Internet Archive StackExchange Data Dump.

Data Fields

Id: long,
PostTypeId: long
AcceptedAnswerId long | null,
ParentId: long | null,
Score: long,
ViewCount: long | null,
Body: string | null,
Title: string | null
ContentLicense: string | null,
FavoriteCount: long | null,
CreationDate: string | null,
LastActivityDate: string | null,
LastEditDate: string | null,
LastEditorUserId: long | null,
OwnerUserId: long | null
Tags: array<string> | null

How is the text stored?

The original Data Dump formats the "Body" field as html, using tags such as <code>, <h1>, <ul>, etc. This HTML format has been converted to markdown

This post is contained in the dataset formatted as follows:

Body of an example record

According to the docs:

​> `componentDidUpdate()` is invoked immediately after updating occurs. This method is not called for the initial render.

We can use the new `useEffect()` hook to simulate `componentDidUpdate()`, but it seems like `useEffect()` is being ran after every render, even the first time. How do I get it to not run on initial render?

As you can see in the example below, `componentDidUpdateFunction` is printed during the initial render but `componentDidUpdateClass` was not printed during the initial render.

​`​`​`
function ComponentDidUpdateFunction() {
  const [count, setCount] = React.useState(0);
  React.useEffect(() => {
    console.log(""componentDidUpdateFunction"");
  });

  return (
    <div>
      <p>componentDidUpdateFunction: {count} times</p>
      <button
        onClick={() => {
          setCount(count + 1);
        }}
      >
        Click Me
      </button>
    </div>
  );
}
​`​`​`
...

Details on the HTML to Markdown conversion

Using Jsoup, the original Body field was converted into a Jsoup Document. This child nodes (has special meaning in context of Jsoup) of this document were recursively traversed in a depth-first order.

Jsoup defines .text() as follows:

... the normalized, combined text of this element and all its children. Whitespace is normalized and trimmed. For example, given HTML <p>Hello <b>there</b> now! </p>, p.text() returns "Hello there now!"

Jsoup defines a Node as follows:

The base, abstract Node model. Elements, Documents, Comments etc are all Node instances.

Additionally the existence of the TextNode should be noted, which represents floating text inside an HTML document that is not itself an HTML element. Thus this text tag <p>Hello<code>World</code></p> would have two Jsoup child nodes TextNode(value="Hello") and Element(tag="code", value="World"). The value fieldof aTextNode` contains the free standing text without any further treatment (no whitespace stripping, etc.)

Traversing Rules

  • When ecountering a html tag for which a rule exists, children are not further traversed, unless explicitly stated otherwise.

  • When encountering an <a> tag, [${element.text()}](${element.attr("href")}) is emitted.

  • When encountering an <h1> tag, \n# ${element.text()}\n\n is emitted.

  • When encountering an <h2> tag, \n## ${element.text()}\n\n is emitted.

  • When encountering an <h3> tag, \n### ${element.text()}\n\n is emitted.

  • When encountering an <h4> tag, \n#### ${element.text()}\n\n is emitted.

  • When encountering an <h5> tag, \n##### ${element.text()}\n\n is emitted.

  • When encountering an <h6> tag, \n###### ${element.text()}\n\n is emitted.

  • When encountering a <code> tag, `${element.text()}`is emitted

  • When encountering a <pre> tag and said element has a <code> child tag, ​`​`​`\n${element.text()}`\n​`​`​`\n is emitted.

  • When encountering a <pre> tag and said element does not have a <code> child tag, children are traversed further.

  • When encountering an <li> tag, - is emitted and children are traversed further.

  • When encountering a <blockquote> tag, > is emitted and children are traversed further.

  • When encountering an <hr> tag, \n---\n\n is emitted

  • When encountering an <img> tag, ![${element.attr("alt")}](${element.attr("src")}) is emitted.

  • When encountering a <table> tag

    • \n| is emitted
    • For each element of element.select("th")
      • ${element.text()} |
    • After the loop \n| is emitted
    • --- | is emitted exactly as many times as the number of <th> children previously iterated over.
    • \n is emitted
    • For each element of element.select("tr")
      • | is emitted
      • For each element of element.select("td")
        • ${td.text()} | is emitted
      • After the loop over <td> elements, \n is emitted
    • After the loop over <tr> elements, \n is emitted
  • When encountering a jsoup TextNode, ${node.attr(node.nodeName())} (which is equivalent to accessing the private field node.value) is emitted.