File size: 700 Bytes
ecc433e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import emoji
# emoji.emoji_count("😬😍😻😘😚😽") == 6
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)) |