[update]add data
Browse files- chinese_chitchat.py +2 -0
- data/tieba.jsonl +3 -0
- data/xiaohuangji.jsonl +3 -0
- examples/process/process_tieba.py +62 -0
- examples/process/process_xiaohuangji.py +69 -0
chinese_chitchat.py
CHANGED
|
@@ -13,7 +13,9 @@ _URLS = {
|
|
| 13 |
"douban": "data/douban.jsonl",
|
| 14 |
"ptt": "data/ptt.jsonl",
|
| 15 |
"subtitle": "data/subtitle.jsonl",
|
|
|
|
| 16 |
"weibo": "data/weibo.jsonl",
|
|
|
|
| 17 |
|
| 18 |
}
|
| 19 |
|
|
|
|
| 13 |
"douban": "data/douban.jsonl",
|
| 14 |
"ptt": "data/ptt.jsonl",
|
| 15 |
"subtitle": "data/subtitle.jsonl",
|
| 16 |
+
"tieba": "data/tieba.jsonl",
|
| 17 |
"weibo": "data/weibo.jsonl",
|
| 18 |
+
"xiaohuangji": "data/xiaohuangji.jsonl",
|
| 19 |
|
| 20 |
}
|
| 21 |
|
data/tieba.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bd3d58d1afc448cf349c78b825b00b452490d2322702e14ceb9688af32ef2378
|
| 3 |
+
size 850248357
|
data/xiaohuangji.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62ec8b92824c26a977462180b572c2d4a2674d50661991023df450f0561fc627
|
| 3 |
+
size 84380813
|
examples/process/process_tieba.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_file",
|
| 17 |
+
default=(project_path / "original_data/tieba.dialogues").as_posix(),
|
| 18 |
+
type=str
|
| 19 |
+
)
|
| 20 |
+
parser.add_argument(
|
| 21 |
+
"--output_file",
|
| 22 |
+
default=(project_path / "data/tieba.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 |
+
with open(args.output_file, "w", encoding="utf-8") as fout:
|
| 34 |
+
with open(args.data_file, "r", encoding="utf-8") as fin:
|
| 35 |
+
for row in fin:
|
| 36 |
+
splits = str(row).strip().split("\t")
|
| 37 |
+
if len(splits) != 2:
|
| 38 |
+
print(row)
|
| 39 |
+
raise AssertionError
|
| 40 |
+
|
| 41 |
+
row = {
|
| 42 |
+
"conversation": [
|
| 43 |
+
{
|
| 44 |
+
"role": "human",
|
| 45 |
+
"message": splits[0],
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"role": "assistant",
|
| 49 |
+
"message": splits[1],
|
| 50 |
+
}
|
| 51 |
+
],
|
| 52 |
+
"category": None,
|
| 53 |
+
"data_source": "tieba",
|
| 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()
|
examples/process/process_xiaohuangji.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
import pandas as pd
|
| 8 |
+
from tqdm import tqdm
|
| 9 |
+
|
| 10 |
+
from project_settings import project_path
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def get_args():
|
| 14 |
+
parser = argparse.ArgumentParser()
|
| 15 |
+
|
| 16 |
+
parser.add_argument(
|
| 17 |
+
"--data_file",
|
| 18 |
+
default=(project_path / "original_data/Dialog_Corpus-master/xiaohuangji50w_nofenci.conv/xiaohuangji50w_nofenci.conv").as_posix(),
|
| 19 |
+
type=str
|
| 20 |
+
)
|
| 21 |
+
parser.add_argument(
|
| 22 |
+
"--output_file",
|
| 23 |
+
default=(project_path / "data/xiaohuangji.jsonl"),
|
| 24 |
+
type=str
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
args = parser.parse_args()
|
| 28 |
+
return args
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def main():
|
| 32 |
+
args = get_args()
|
| 33 |
+
|
| 34 |
+
with open(args.output_file, "w", encoding="utf-8") as fout:
|
| 35 |
+
with open(args.data_file, "r", encoding="utf-8") as fin:
|
| 36 |
+
conversation = list()
|
| 37 |
+
for row in fin:
|
| 38 |
+
splits = str(row).strip().split(maxsplit=1)
|
| 39 |
+
if len(splits) == 0:
|
| 40 |
+
continue
|
| 41 |
+
|
| 42 |
+
if len(splits) == 1:
|
| 43 |
+
if len(conversation) == 0:
|
| 44 |
+
continue
|
| 45 |
+
|
| 46 |
+
if len(conversation) == 2:
|
| 47 |
+
conversation[0]["role"] = "human"
|
| 48 |
+
conversation[1]["role"] = "assistant"
|
| 49 |
+
row_ = {
|
| 50 |
+
"conversation": conversation,
|
| 51 |
+
"category": None,
|
| 52 |
+
"data_source": "xiaohuangji",
|
| 53 |
+
}
|
| 54 |
+
row_ = json.dumps(row_, ensure_ascii=False)
|
| 55 |
+
fout.write("{}\n".format(row_))
|
| 56 |
+
conversation = list()
|
| 57 |
+
else:
|
| 58 |
+
message = splits[1]
|
| 59 |
+
|
| 60 |
+
conversation.append({
|
| 61 |
+
"role": "unknown",
|
| 62 |
+
"message": message,
|
| 63 |
+
})
|
| 64 |
+
|
| 65 |
+
return
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
if __name__ == '__main__':
|
| 69 |
+
main()
|