Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -9,7 +9,127 @@ task_categories:
|
|
| 9 |
- text2text-generation
|
| 10 |
tags:
|
| 11 |
- code
|
| 12 |
-
pretty_name:
|
| 13 |
size_categories:
|
| 14 |
-
- 10M
|
| 15 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
- text2text-generation
|
| 10 |
tags:
|
| 11 |
- code
|
| 12 |
+
pretty_name: StackOverflow Posts
|
| 13 |
size_categories:
|
| 14 |
+
- 10M<n<100M
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Dataset Summary
|
| 18 |
+
|
| 19 |
+
This dataset contains all posts submitted to StackOverflow before the 14th of June 2023 formatted as **Markdown text**.<br>
|
| 20 |
+
The dataset contains over 60 Million posts, totaling ~40GB in size and ~65 billion characters of text.<br>
|
| 21 |
+
The data is sourced from [Internet Archive StackExchange Data Dump](https://archive.org/download/stackexchange).
|
| 22 |
+
|
| 23 |
+
# Data Fields
|
| 24 |
+
```
|
| 25 |
+
Id: long,
|
| 26 |
+
PostTypeId: long
|
| 27 |
+
AcceptedAnswerId long | null,
|
| 28 |
+
ParentId: long | null,
|
| 29 |
+
Score: long,
|
| 30 |
+
ViewCount: long | null,
|
| 31 |
+
Body: string | null,
|
| 32 |
+
Title: string | null
|
| 33 |
+
ContentLicense: string | null,
|
| 34 |
+
FavoriteCount: long | null,
|
| 35 |
+
CreationDate: string | null,
|
| 36 |
+
LastActivityDate: string | null,
|
| 37 |
+
LastEditDate: string | null,
|
| 38 |
+
LastEditorUserId: long | null,
|
| 39 |
+
OwnerUserId: long | null
|
| 40 |
+
Tags: array<string> | null
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
# How is the text stored?
|
| 44 |
+
|
| 45 |
+
The original Data Dump formats the "Body" field as html, using tags such as `<code>`, `<h1>`, `<ul>`, etc.
|
| 46 |
+
This HTML format has been converted to markdown
|
| 47 |
+
|
| 48 |
+
[This post](https://stackoverflow.com/questions/53253940/make-react-useeffect-hook-not-run-on-initial-render) is contained in the dataset formatted as follows:
|
| 49 |
+
|
| 50 |
+
## Body of an example record
|
| 51 |
+
```markdown
|
| 52 |
+
According to the docs:
|
| 53 |
+
|
| 54 |
+
> `componentDidUpdate()` is invoked immediately after updating occurs. This method is not called for the initial render.
|
| 55 |
+
|
| 56 |
+
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?
|
| 57 |
+
|
| 58 |
+
As you can see in the example below, `componentDidUpdateFunction` is printed during the initial render but `componentDidUpdateClass` was not printed during the initial render.
|
| 59 |
+
|
| 60 |
+
```
|
| 61 |
+
function ComponentDidUpdateFunction() {
|
| 62 |
+
const [count, setCount] = React.useState(0);
|
| 63 |
+
React.useEffect(() => {
|
| 64 |
+
console.log(""componentDidUpdateFunction"");
|
| 65 |
+
});
|
| 66 |
+
|
| 67 |
+
return (
|
| 68 |
+
<div>
|
| 69 |
+
<p>componentDidUpdateFunction: {count} times</p>
|
| 70 |
+
<button
|
| 71 |
+
onClick={() => {
|
| 72 |
+
setCount(count + 1);
|
| 73 |
+
}}
|
| 74 |
+
>
|
| 75 |
+
Click Me
|
| 76 |
+
</button>
|
| 77 |
+
</div>
|
| 78 |
+
);
|
| 79 |
+
}
|
| 80 |
+
```
|
| 81 |
+
...
|
| 82 |
+
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
# Details on the HTML to Markdown conversion
|
| 86 |
+
|
| 87 |
+
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.
|
| 88 |
+
|
| 89 |
+
Jsoup defines `.text()` as follows:
|
| 90 |
+
> ... the normalized, combined text of this element and all its children. Whitespace is normalized and trimmed. For example, given HTML <code><p>Hello <b>there</b> now! </p><code>, p.text() returns "Hello there now!"
|
| 91 |
+
|
| 92 |
+
Jsoup defines a `Node` as follows:
|
| 93 |
+
> The base, abstract Node model. Elements, Documents, Comments etc are all Node instances.
|
| 94 |
+
|
| 95 |
+
Additionally the existence of the `TextNode` should be noted, which represents floating text inside an HTML document that is not itself an HTML element.
|
| 96 |
+
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")`.
|
| 97 |
+
The value `field` of a `TextNode` contains the free standing text without any further treatment (no whitespace stripping, etc.)
|
| 98 |
+
|
| 99 |
+
## Traversing Rules
|
| 100 |
+
|
| 101 |
+
- When ecountering a html tag for which a rule exists, children are not further traversed, **unless explicitly stated otherwise**.
|
| 102 |
+
- When encountering an `<a>` tag, `[${element.text()}](${element.attr("href")})` is emitted.
|
| 103 |
+
|
| 104 |
+
- When encountering an `<h1>` tag, `\n# ${element.text()}\n\n` is emitted.
|
| 105 |
+
- When encountering an `<h2>` tag, `\n## ${element.text()}\n\n` is emitted.
|
| 106 |
+
- When encountering an `<h3>` tag, `\n### ${element.text()}\n\n` is emitted.
|
| 107 |
+
- When encountering an `<h4>` tag, `\n#### ${element.text()}\n\n` is emitted.
|
| 108 |
+
- When encountering an `<h5>` tag, `\n##### ${element.text()}\n\n` is emitted.
|
| 109 |
+
- When encountering an `<h6>` tag, `\n###### ${element.text()}\n\n` is emitted.
|
| 110 |
+
|
| 111 |
+
- When encountering a `<code>` tag, `` `${element.text()}` ``is emitted
|
| 112 |
+
- When encountering a `<pre>` tag and said element **has** a `<code>` child tag, `` ```\n${element.text()}`\n```\n`` is emitted.
|
| 113 |
+
- When encountering a `<pre>` tag and said element **does not** have a `<code>` child tag, **children are traversed further**.
|
| 114 |
+
- When encountering an `<li>` tag, `- ` is emitted and **children are traversed further**.
|
| 115 |
+
- When encountering a `<blockquote>` tag, `> ` is emitted and **children are traversed further**.
|
| 116 |
+
- When encountering an `<hr>` tag, `\n---\n\n` is emitted
|
| 117 |
+
- When encountering an `<img>` tag, `})` is emitted.
|
| 118 |
+
- When encountering a `<table>` tag
|
| 119 |
+
- `\n| ` is emitted
|
| 120 |
+
- For each element of `element.select("th")`
|
| 121 |
+
- `${element.text()} | `
|
| 122 |
+
- After the loop `\n| ` is emitted
|
| 123 |
+
- `--- | ` is emitted exactly as many times as the number of `<th>` children previously iterated over.
|
| 124 |
+
- `\n` is emitted
|
| 125 |
+
- For each element of `element.select("tr")`
|
| 126 |
+
- `| ` is emitted
|
| 127 |
+
- For each element of `element.select("td")`
|
| 128 |
+
- `${td.text()} | ` is emitted
|
| 129 |
+
- After the loop over `<td>` elements, `\n` is emitted
|
| 130 |
+
- After the loop over `<tr>` elements, `\n` is emitted
|
| 131 |
+
- When encountering a jsoup `TextNode`, `${node.attr(node.nodeName())}` (which is equivalent to accessing the private field `node.value`) is emitted.
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
```
|
| 135 |
+
|