Commit 2a745a3a authored by Studer Brendan's avatar Studer Brendan
Browse files

begining of scores min max

parent fe4ee281
Loading
Loading
Loading
Loading

features/__init__.py

0 → 100644
+0 −0

Empty file added.

+62 −0
Original line number Diff line number Diff line
import json

def find_min_max_scores(content):
    scenes_array = []
    
    #Ierate over chapters
    for idx_chapter, chapter in enumerate(content["Chapters"]):
        #Iterate over scenes
        for idx_scene, scene in enumerate(chapter["Scenes"]):
            
            scenes_array.append({
                "Authenticity": 0,
                  "Respect": 0,
                  "Compassion": 0,
                  "Hope": 0,
                  "Empathy": 0
            })
            
            #Iterate over interactions
            for interaction in scene["Interactions"]:
                
                    #Iterate over choices
                    for choice in interaction['Responses']:
                        pass
                    

visitedList = [[]]
# algorithm found on https://stackoverflow.com/questions/62656477/python-get-all-paths-from-graph
def depthFirst(graph, currentVertex, visited):
    
    visited.append(currentVertex)
    for vertex in graph[currentVertex]:
        if vertex not in visited:
            depthFirst(graph, vertex, visited.copy())
    visitedList.append(visited)

# depthFirst(graph, 0, [])

def create_graph(scene):
    
    graph = {}
    
    for interaction in scene["Interactions"]:
        current_index = interaction["Id"]
        children = []  
          
        #Iterate over choices
        for choice in interaction['Responses']:
            children.append(choice["Id"])

        graph[current_index] = children
    
    return graph
    
if __name__ == "__main__":
    with open("Chapters.json", 'r', encoding="utf-8") as j:
        contents = json.loads(j.read())
        
        graph = create_graph(contents["Chapters"][0]["Scenes"][0])
        
        depthFirst(graph, 1, [])
        print(visitedList)
 No newline at end of file