File size: 1,362 Bytes
b2196c8
 
 
 
 
 
 
 
a1e15cd
4ae6d05
e817104
a1e15cd
 
 
 
 
 
 
 
 
 
9f4bfb9
c755297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
def clean_pinecone(response):
    #Dict for metadata that is removed from duplicate classes
    additional_metadata = {}
    classes = [] 
    unique_codes = set()

    for entry in response['matches']:
        code = entry['metadata']['code']
        score = float(entry['score'])
        # score = 
        if score > 0.785: #Threshold from personal testing
            if code not in unique_codes:
                #Where class is unique
                classes.append(entry)
                unique_codes.add(code)
            else:
                #Class already added, but need to save alternate sessions
                time = entry['metadata']['time']
                days = entry['metadata']['days']
                additional_metadata[code] = {'time': time, 'days': days}

    return classes, additional_metadata

def build_filter(json_response):
    filter = {}

    days_list = json_response['Days']
    # Days
    if "[" in days_list:
        days = str(days_list[0])

        for i in range(len(days_list)-1):
            days += ', '
            days += str(days_list[i+1])
        filter["days"] = days

    # Units
    units = json_response['Units']

    if units != "":
        filter["units"] = units

    # Program
    program = json_response['Program']

    if program != "":
        filter["program"] = program

    # Time

    return filter