Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import json
- # This must be run in the "results" folder.
- def get_summary_files():
- return [f for f in os.listdir() if 'summary' in f.lower() and f.endswith('.json')]
- def extract_json_content(file_path):
- with open(file_path, 'r') as file:
- return json.load(file)
- def process_summaries():
- total_correct = 0
- total_wrong = 0
- categories = {}
- for file in get_summary_files():
- data = extract_json_content(file)
- category = list(data.keys())[0] # Assuming the first key is the category
- total = data['total']
- categories[category] = {
- 'correct': total['corr'],
- 'wrong': total['wrong'],
- 'accuracy': total['acc']
- }
- total_correct += total['corr']
- total_wrong += total['wrong']
- return categories, total_correct, total_wrong
- def main():
- categories, total_correct, total_wrong = process_summaries()
- print("Results by category:")
- for category, results in categories.items():
- print(f"{category.capitalize()}:")
- print(f" Correct: {results['correct']}")
- print(f" Wrong: {results['wrong']}")
- print(f" Accuracy: {results['accuracy']:.2%}")
- print()
- total_questions = 12032 # As per the given table
- total_answered = total_correct + total_wrong
- failed = total_questions - total_answered
- print(f"Total correct: {total_correct}")
- print(f"Total wrong: {total_wrong}")
- print(f"Total answered: {total_answered}")
- print(f"Failed to answer: {failed}")
- print(f"Overall accuracy: {total_correct / total_answered:.2%}")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement