/
Chriss_Nickell
/
Course_Project
Обзор
Документация
Войти
/
Chriss_Nickell
/
Course_Project
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
HateXplain/Data/abc.py
22 строки
825 B
Norman
first_commit
03 июн 2026, 06:09
03 июн 2026, 06:09
dd02054
Код
Авторство
О чём код?
import json with open('dataset.json', 'r', encoding='utf-8') as f: content = f.read() # Ищем все вхождения "rationales" count_with_ones = 0 total_posts_estimated = content.count('"post_id"') # примерная оценка # Разбиваем по постам (приблизительно) posts = content.split('"post_tokens"') for post in posts: if '"rationales"' in post: # Находим часть после "rationales" rat_part = post.split('"rationales"')[1] if '"rationales"' in post else "" if '1' in rat_part: count_with_ones += 1 print(f"Примерное количество постов: {len(posts)}") print(f"Постов с rationales (содержат 1): {count_with_ones}") print(f"Доля: {count_with_ones/len(posts)*100:.1f}%")