Dateien nach "mod/butadien" hochladen

This commit is contained in:
2026-08-28 12:57:51 +02:00
parent 3ac040b1c6
commit 482c067501
2 changed files with 207 additions and 5 deletions
+13 -5
View File
@@ -6,9 +6,11 @@ import re
#for edge in graph:
#dir(edge)
HYPERGRAPH = {}
HYPERGRAPH = {
1: ([], ['Butadien']),
}
with open('out/014_dg_0_11100.dot', 'r') as file:
with open('014_dg_0_11100.dot', 'r') as file:
graph = file.read()
#print(re.findall( "// id = [0-9]+\\{ ('Butadien' |'p_\\{0,[0-9]\\} ){1,2}\\}, 'r_\\{[0|1]\\}', \\{ ('Butadien' |'p_\\{0,[0-9]\\} ){1,2}\\}", graph)[0])
for edge in re.findall( "// id = [0-9]+\\{ [A-Za-z0-9_,{} ']+ \\}, 'r_\\{[0|1]\\}', \\{ [A-Za-z0-9_,{} ']+ \\}", graph):
@@ -16,7 +18,13 @@ with open('out/014_dg_0_11100.dot', 'r') as file:
index = int(re.findall("(?<=id = )(.*?)(?=\\{)", edge)[0])
educts = re.findall("(?<=\\{)(.*?)(?=\\}, 'r_\\{[0-1]\\}',)", edge)[0]
educt = re.findall("(?<= ')(.*?)(?=' )", educts)
products = re.findall("(?<='r_\\{[0-1]\\}', \\{)(.*?)(?=\\})", edge)[0]
product = re.findall("(?<= ')(.*?)(?=' )", products)
products = re.findall("(?<='r_\\{[0-1]\\}', \\{)(.*?)(?=\\ })", edge)[0]
product = re.findall("(?<= ')(.*?)(?=')", products)
HYPERGRAPH[index] = (educt, product)
print(HYPERGRAPH)
with open('hypergraph.txt', 'w') as f:
f.write("HYPERGRAPH = {")
for edge, (head, tail) in HYPERGRAPH.items():
f.write(f'\t {edge}, ({head}, {tail}),\n')
f.write('}')
f.close