File size: 2,594 Bytes
3382f47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// TODO: Remove the ability to have null values when benchmark implementation is complete
import 'dart:convert';

/// TaskInfo holds information related to a specific benchmark task.
///
/// The class encapsulates various attributes of a task, such as the path to the data file,
/// whether the task is a regression task, the categories it falls under, and specific task details
/// like the task description, expected answer, and so on.
class TaskInfo {
  /// The path to the data file associated with the task.
  /// This is typically a JSON file containing the dataset or resources needed for the task.
  final String dataPath;

  /// A boolean indicating whether the task is a regression task.
  final bool isRegression;

  /// A list of categories to which the task belongs.
  final List<String> category;

  /// The specific task that needs to be performed.
  final String task;

  /// The expected answer for the task.
  final String answer;

  /// A description providing details about the task.
  final String description;

  /// Constructs a new TaskInfo instance.
  ///
  /// [dataPath]: The path to the data file for the task.
  /// [isRegression]: A boolean indicating if the task is a regression task.
  /// [category]: A list of categories to which the task belongs.
  /// [task]: The specific task to be performed.
  /// [answer]: The expected answer for the task.
  /// [description]: A description of the task.
  TaskInfo({
    required this.dataPath,
    required this.isRegression,
    required this.category,
    required this.task,
    required this.answer,
    required this.description,
  });

  /// Creates a TaskInfo instance from a map.
  ///
  /// [json]: A map containing key-value pairs corresponding to TaskInfo fields.
  ///
  /// Returns a new TaskInfo populated with values from the map.
  factory TaskInfo.fromJson(Map<String, dynamic> json) => TaskInfo(
        dataPath: json['data_path'] ?? 'placeholder',
        isRegression: json['is_regression'] ?? false,
        category: List<String>.from(json['category']),
        task: json['task'] ?? 'placeholder',
        answer: json['answer'] ?? 'placeholder',
        description: json['description'] ?? 'placeholder',
      );

  /// Converts the TaskInfo instance to a map.
  ///
  /// Returns a map containing key-value pairs corresponding to TaskInfo fields.
  Map<String, dynamic> toJson() => {
        'data_path': dataPath,
        'is_regression': isRegression,
        'category': jsonEncode(category),
        'task': task,
        'answer': answer,
        'description': description,
      };
}