File size: 1,692 Bytes
2b1b387
 
 
162d0e2
fa59d8d
162d0e2
fa59d8d
162d0e2
2b1b387
823e4cd
 
 
 
 
 
 
cd5097e
b0f6513
 
 
 
f8313c6
 
 
 
 
 
 
 
fa59d8d
 
f8313c6
b0f6513
 
 
 
 
 
bf81393
 
2b1b387
 
 
 
 
 
b0f6513
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
import datasets
import pandas as pd

class KinopoiskReviewsConfig(datasets.BuilderConfig):
    def __init__(self, features, **kwargs):
        super(KinopoiskReviewsConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
        self.features = features

class Kinopoisk(datasets.GeneratorBasedBuilder):
    #BUILDER_CONFIGS = [
    #    KinopoiskReviewsConfig(
    #        name="simple",
    #        description="Simple config",
    #        features=["content", "title", "grade3", "movie_name", "part", "review_id", "author", "date", "grade10"],
    #    )
    #]
    
    def _info(self):
        return datasets.DatasetInfo(
            description='Kinopoisk movie reviews dataset.',
            features=datasets.Features(
                {
                    "content": datasets.Value("string"),
                    "title": datasets.Value("string"),
                    "grade3": datasets.Value("string"),
                    "movie_name": datasets.Value("string"),
                    "part": datasets.Value("string"),
                    "review_id": datasets.Value("string"),
                    "author": datasets.Value("string"),
                    "date":datasets.Value("string"),
                    "grade10": datasets.Value("string"),
                }
            ),
            supervised_keys=None,
            homepage='',
            citation='',
        )
        
    def _generate_examples(self, filepath):
        df = pd.read_json(filepath, lines=True)
        rows = df.to_dict(orient="records")
        
        for n, row in enumerate(rows):
            example = row
            example["Idx"] = n

            yield example["Idx"], example