Datasets:

Languages:
Polish
License:
File size: 1,064 Bytes
7d7c9a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import json
import random

FILES = {
  'CEN': './kgr10/CEN',
  'openbooks': './kgr10/openbooks',
  'open_science': './kgr10/open_science',
  'wikisources-pl': './kgr10/wikisources-pl',
  'sejm': './kgr10/sejm/',
}


def main():
    idnum = 0
    kgr10 = []
    for sname, spath in FILES.items():
        for fname in os.listdir(spath):
            with open(os.path.join(spath, fname), 'rt') as fin:
                content = fin.readlines()
                content = "\n".join(content).strip()
                kgr10.append(
                    json.dumps(
                        {
                            'id': idnum,
                            'corpora': sname.strip(),
                            'filename': fname.strip(),
                            'text': content
                        }
                    )
                )
            idnum += 1

    random.shuffle(kgr10)

    with open('./kgr10.jsonl', 'wt') as fout:
        for kgr10_item in kgr10:
            fout.write(kgr10_item + "\n")

if __name__ == '__main__':
    main()