File size: 2,069 Bytes
67dfbba
 
46d159a
 
9351de1
67dfbba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2df0659
5e9bb0a
67dfbba
 
 
 
 
42b7c18
08b0d82
 
 
 
 
42b7c18
 
d361597
67dfbba
 
 
 
 
7946381
 
4576920
67dfbba
 
 
08b0d82
67dfbba
 
 
 
 
08b0d82
67dfbba
 
08b0d82
f49738c
67dfbba
d361597
08b0d82
f49738c
41c919b
67dfbba
 
 
 
 
713c69a
9351de1
713c69a
 
4576920
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""The BookCorpus dataset."""

import datasets
import os
import json


_DESCRIPTION = """\
Dataset of jira comments from different projects of Apache and more.
"""

_CITATION = """\
@InProceedings{Zhu_2015_ICCV,
    title = {Jira commentaries},
    author = {Filipp Abapolov},
    month = {Fubruary},
    year = {2023}
}
"""


_REPO = "https://huggingface.co/datasets/pheepa/jira-comments/resolve/main"
_URL = f"{_REPO}/data/jira-comments.tar.gz"


class JiraComments(datasets.GeneratorBasedBuilder):
    """JiraComments dataset."""

    BUILDER_CONFIGS = [
        datasets.BuilderConfig(
            name='jira-comments', 
            version=datasets.Version("1.0.0"), 
            description=_DESCRIPTION
            )
    ]


    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "sentence_a": datasets.Value("string"),
                    "sentence_b": datasets.Value("string"),
                    "next_sentence_label": datasets.Value("int32")
                }
            ),
            supervised_keys=None,
            citation=_CITATION
        )

    def _split_generators(self, dl_manager):
        """Returns SplitGenerators."""
        data_dir = dl_manager.download_and_extract(_URL)

        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={"filepath": os.path.join(data_dir, "train-pairs-jira-comments.txt")}
            ),
            datasets.SplitGenerator(
                name=datasets.Split.TEST,
                gen_kwargs={"filepath": os.path.join(data_dir,  "test-pairs-jira-comments.txt")}
            )
        ]

    def _generate_examples(self, filepath):
        """Yields examples."""
        with open(filepath, 'r') as f:
            triples = f.read().split('\n')

        for i in range(0, len(triples) - 1, 3):
            l, a, b = triples[i:i+3]
            yield i // 3, {"sentence_a": a, 'sentence_b': b, 'next_sentence_label': int(l)}