[update]add data
Browse files- chinese_chitchat.py +2 -0
- data/douban.jsonl +3 -0
- examples/process/process_chatterbot.py +0 -4
- examples/process/process_douban.py +62 -0
chinese_chitchat.py
CHANGED
@@ -10,6 +10,8 @@ import datasets
|
|
10 |
|
11 |
_URLS = {
|
12 |
"chatterbot": "data/chatterbot.jsonl",
|
|
|
|
|
13 |
}
|
14 |
|
15 |
|
|
|
10 |
|
11 |
_URLS = {
|
12 |
"chatterbot": "data/chatterbot.jsonl",
|
13 |
+
"douban": "data/douban.jsonl",
|
14 |
+
|
15 |
}
|
16 |
|
17 |
|
data/douban.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5f483ffe4eb53c49e00d437ce7ca069ff19ade13a5a083f1e63fde64f4e1898b
|
3 |
+
size 472520216
|
examples/process/process_chatterbot.py
CHANGED
@@ -2,11 +2,7 @@
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import argparse
|
4 |
import json
|
5 |
-
import os
|
6 |
from pathlib import Path
|
7 |
-
import re
|
8 |
-
import tempfile
|
9 |
-
from typing import List
|
10 |
import yaml
|
11 |
|
12 |
from tqdm import tqdm
|
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import argparse
|
4 |
import json
|
|
|
5 |
from pathlib import Path
|
|
|
|
|
|
|
6 |
import yaml
|
7 |
|
8 |
from tqdm import tqdm
|
examples/process/process_douban.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/python3
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import argparse
|
4 |
+
import json
|
5 |
+
from pathlib import Path
|
6 |
+
|
7 |
+
from tqdm import tqdm
|
8 |
+
|
9 |
+
from project_settings import project_path
|
10 |
+
|
11 |
+
|
12 |
+
def get_args():
|
13 |
+
parser = argparse.ArgumentParser()
|
14 |
+
|
15 |
+
parser.add_argument(
|
16 |
+
"--data_dir",
|
17 |
+
default=(project_path / "original_data/DoubanConversaionCorpus").as_posix(),
|
18 |
+
type=str
|
19 |
+
)
|
20 |
+
parser.add_argument(
|
21 |
+
"--output_file",
|
22 |
+
default=(project_path / "data/douban.jsonl"),
|
23 |
+
type=str
|
24 |
+
)
|
25 |
+
|
26 |
+
args = parser.parse_args()
|
27 |
+
return args
|
28 |
+
|
29 |
+
|
30 |
+
def main():
|
31 |
+
args = get_args()
|
32 |
+
|
33 |
+
data_dir = Path(args.data_dir)
|
34 |
+
with open(args.output_file, "w", encoding="utf-8") as fout:
|
35 |
+
for filename in tqdm(data_dir.glob("*.txt")):
|
36 |
+
with open(filename, "r", encoding="utf-8") as fin:
|
37 |
+
for row in fin:
|
38 |
+
splits = row.split("\t")
|
39 |
+
label = splits[0]
|
40 |
+
conversation = splits[1:]
|
41 |
+
if label != "1":
|
42 |
+
continue
|
43 |
+
|
44 |
+
row = {
|
45 |
+
"conversation": [
|
46 |
+
{
|
47 |
+
"role": "human" if i % 2 == 0 else "assistant",
|
48 |
+
"message": "".join(str(c).strip().split())
|
49 |
+
}
|
50 |
+
for i, c in enumerate(conversation)
|
51 |
+
],
|
52 |
+
"category": filename.stem,
|
53 |
+
"data_source": "chatterbot",
|
54 |
+
}
|
55 |
+
row = json.dumps(row, ensure_ascii=False)
|
56 |
+
fout.write("{}\n".format(row))
|
57 |
+
|
58 |
+
return
|
59 |
+
|
60 |
+
|
61 |
+
if __name__ == '__main__':
|
62 |
+
main()
|