abdullahmeda commited on
Commit
3ef3c02
·
1 Parent(s): a6d5bbc
Files changed (2) hide show
  1. app.py +2 -1
  2. cw2.py +4 -13
app.py CHANGED
@@ -130,7 +130,8 @@ with gr.Blocks(css="""
130
 
131
  For the above “also like” functionality, this section generates a graph that displays the relationship between the input document and all documents that have been found as “also like” documents (and only these documents)
132
  """)
133
- also_likes_graph = gr.Image('output_test.png')
 
134
 
135
  req_5_submit.click(fn=req_5_and_6, inputs=[t5_doc_uuid, t5_visitor_uuid, t5_sorting, selected_dataset_5], outputs=[also_likes_df, also_likes_graph])
136
 
 
130
 
131
  For the above “also like” functionality, this section generates a graph that displays the relationship between the input document and all documents that have been found as “also like” documents (and only these documents)
132
  """)
133
+ also_likes_graph = gr.Image(value=also_like(globals()[f"data_{selected_dataset_5.value}"], t5_doc_uuid.value, t5_visitor_uuid.value,
134
+ t5_sorting.value == 'Ascending'))
135
 
136
  req_5_submit.click(fn=req_5_and_6, inputs=[t5_doc_uuid, t5_visitor_uuid, t5_sorting, selected_dataset_5], outputs=[also_likes_df, also_likes_graph])
137
 
cw2.py CHANGED
@@ -130,10 +130,6 @@ def also_like_graph(data, doc_uuid, visitor_uuid, ascending):
130
  top_docs[0] = top_docs[0].str[-4:]
131
  top_docs[1] = top_docs[1].str[-4:]
132
  print(top_docs)
133
- # y = top_docs[1].value_counts()
134
- # y = pd.DataFrame(y)
135
- # y.loc[len(y.index)] = [visitor_uuid, doc_uuid]
136
- # print(y)
137
  dot = graphviz.Digraph()
138
  dot.node(visitor_uuid[-4:], visitor_uuid[-4:], stle='filled', fillcolor='green')
139
  dot.node(doc_uuid[-4:], doc_uuid[-4:], stle='filled', fillcolor='green')
@@ -142,16 +138,11 @@ def also_like_graph(data, doc_uuid, visitor_uuid, ascending):
142
  dot.node(str(row[0]), str(row[0]))
143
  dot.node(str(row[1]), str(row[1]))
144
  dot.edge(str(row[0]), str(row[1]))
145
- # # if(index <= 7):
146
- # # print(row[0], row[1])
147
- # dot.node(str(row[0]), str(row[0])[-4:])
148
- # dot.node(str(row[1]), str(row[1])[-4:])
149
- # dot.edge(str(row[0]), str(row[1]))
150
- #
151
- print(dot.source)
152
- #
153
  dot.render('output.dot').replace('\\', '/')
154
- #
155
  (graph,) = pydot.graph_from_dot_file('output.dot')
156
  graph.write_png('output.png')
157
  return 'output.png'
 
130
  top_docs[0] = top_docs[0].str[-4:]
131
  top_docs[1] = top_docs[1].str[-4:]
132
  print(top_docs)
 
 
 
 
133
  dot = graphviz.Digraph()
134
  dot.node(visitor_uuid[-4:], visitor_uuid[-4:], stle='filled', fillcolor='green')
135
  dot.node(doc_uuid[-4:], doc_uuid[-4:], stle='filled', fillcolor='green')
 
138
  dot.node(str(row[0]), str(row[0]))
139
  dot.node(str(row[1]), str(row[1]))
140
  dot.edge(str(row[0]), str(row[1]))
141
+
142
+ # print(dot.source)
143
+
 
 
 
 
 
144
  dot.render('output.dot').replace('\\', '/')
145
+
146
  (graph,) = pydot.graph_from_dot_file('output.dot')
147
  graph.write_png('output.png')
148
  return 'output.png'