Loading .gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -165,3 +165,4 @@ cython_debug/ # End of https://www.toptal.com/developers/gitignore/api/python variables.txt variables.nani features/min_max_stats_finder.py +8 −3 Original line number Diff line number Diff line import json import logging import networkx as nx import matplotlib.pyplot as plt from loguru import logger OUTPUT_FILE = "variables.txt" OUTPUT_FILE = "variables.nani" def min_max_scores(content): logger.info("Computing scores for all scenes. It may take a bit of time...") Loading Loading @@ -84,6 +83,11 @@ def create_graph(scene): end_nodes.add(current_node) return graph, end_nodes def normalize_string(text): """Normalize an input string""" return text.lower().replace(" ", "_").replace("é", "e") \ .replace("ê", "e").replace("è", "e").replace("à", "a") def show_graph(graph): pos = nx.spring_layout(graph, seed=7) nx.draw_networkx_nodes(graph, pos, node_size=700) Loading @@ -102,7 +106,8 @@ def write_vars_to_file(scores): with open(OUTPUT_FILE, 'w', encoding='utf-8') as f: for key in scores: for emotion in scores[key]: f.write(key.upper()+"_"+emotion.upper()+"="+str(scores[key][emotion])+"\n") f.write("@set "+normalize_string(key.upper())+"_"+normalize_string(emotion.upper())+"="+str(scores[key][emotion])+"\n") f.write("@stop") if __name__ == "__main__": Loading Loading
.gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -165,3 +165,4 @@ cython_debug/ # End of https://www.toptal.com/developers/gitignore/api/python variables.txt variables.nani
features/min_max_stats_finder.py +8 −3 Original line number Diff line number Diff line import json import logging import networkx as nx import matplotlib.pyplot as plt from loguru import logger OUTPUT_FILE = "variables.txt" OUTPUT_FILE = "variables.nani" def min_max_scores(content): logger.info("Computing scores for all scenes. It may take a bit of time...") Loading Loading @@ -84,6 +83,11 @@ def create_graph(scene): end_nodes.add(current_node) return graph, end_nodes def normalize_string(text): """Normalize an input string""" return text.lower().replace(" ", "_").replace("é", "e") \ .replace("ê", "e").replace("è", "e").replace("à", "a") def show_graph(graph): pos = nx.spring_layout(graph, seed=7) nx.draw_networkx_nodes(graph, pos, node_size=700) Loading @@ -102,7 +106,8 @@ def write_vars_to_file(scores): with open(OUTPUT_FILE, 'w', encoding='utf-8') as f: for key in scores: for emotion in scores[key]: f.write(key.upper()+"_"+emotion.upper()+"="+str(scores[key][emotion])+"\n") f.write("@set "+normalize_string(key.upper())+"_"+normalize_string(emotion.upper())+"="+str(scores[key][emotion])+"\n") f.write("@stop") if __name__ == "__main__": Loading