<jupyter_start><jupyter_text>Generate a graphical representation of the Option File   IMPORT LIBRARIES<jupyter_code>import json
import os
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

import options_to_dot as otd

# Some widgets
from ipyfilechooser import FileChooser<jupyter_output><empty_output><jupyter_text>Open the option file<jupyter_code># get the option file using the FileChooser
fc = FileChooser('./')
display(fc)
optionFilePath = fc.selected
optionFile = open(optionFilePath)
options = json.load(optionFile)<jupyter_output><empty_output><jupyter_text>Open the option file A dot file (to be compiled with graphviz) will be produced<jupyter_code>outputFilePath = optionFilePath[:optionFilePath.rfind(".")] + ".gv"
outputFile = open(outputFilePath, 'w')<jupyter_output><empty_output><jupyter_text>Generate the output dot file<jupyter_code>otd.generate_dot_diagram(options, outputFile)<jupyter_output><empty_output><jupyter_text>Compile the png file It will works only if you have dot installed and in the system path<jupyter_code>outputPngPath = optionFilePath[:optionFilePath.rfind(".")] + ".png"
os.system(f"dot -Tpng \"{outputFilePath}\" -o \"{outputPngPath}\"")

img = mpimg.imread(outputPngPath)
imgplot = plt.imshow(img)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10202492211838006, 'fraction_numerical': 0.0, 'mean_word_length': 8.113475177304965, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '387157', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 435, 'n_tokens_neox': 426, 'n_words': 102, 'path': 'scripts/signal_marker_processing/Generate_Option_diagram.ipynb', 'repo_name': 'CsabaWirnhardt/cbm', 'size': '1284'}