|
import emoji |
|
|
|
import json |
|
with open(r'E:\tmp\kajiwoto_sharegpt-len_gt_6-upvotes_gt_0-sampled.json', encoding='utf-8') as f: |
|
tmp = json.load(f) |
|
|
|
sc = [] |
|
for conversations in tmp: |
|
conversations = conversations['conversations'] |
|
cc = [] |
|
ss = False |
|
for conversation in conversations: |
|
cc.append(conversation['from'] + ':' + conversation['value'].replace('\n', '\\n')) |
|
if conversation['from'] == 'gpt' and emoji.emoji_count(conversation['value']) > 0: |
|
ss = True |
|
if ss: |
|
sc.extend(cc) |
|
|
|
with open(r'D:\datasets\b-corpus\emoji\kajiwoto.txt', 'w', encoding='utf-8') as f: |
|
f.write('\n'.join(sc)) |