File size: 1,071 Bytes
cd85390
 
 
 
 
 
 
4bf038a
cd85390
 
 
 
 
 
 
 
 
 
4bf038a
 
 
 
 
 
 
cd85390
 
 
 
 
 
 
4bf038a
 
 
 
 
 
 
 
 
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
import json



class Test:
    def __init__(self):
        self.data = self.read_test_data()
        self.descriptions = self.read_image_descriptions()

    def __len__(self):
        return len(self.data)

    @staticmethod
    def read_test_data():
        with open("test.json") as f:
            test_data = json.load(f)
        return test_data

    @staticmethod
    def read_image_descriptions():
        with open("images/descriptions.txt") as f:
            lines = f.readlines()
            clean_lines = [line.strip() for line in lines]
        return clean_lines

    def get_question(self, idx):
        question = self.data[idx]["question"]
        return question
    
    def get_answers(self, idx):
        responces = self.data[idx]["responces"]
        answers = [responce["answer"] for responce in responces]
        return answers
    
    def get_description(self, idx):
        description = self.descriptions[idx]
        return description
    
    def get_image_path(self, idx):
        image_path = f"images/{idx}.jpg"
        return image_path