Rakesh30 commited on
Commit
55ab30c
·
1 Parent(s): 2507667

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -59,8 +59,12 @@ def get_pre_processed_data(size):
59
 
60
  def get_top_k_matches(np_array,k,sentences):
61
  indices=[]
 
62
  for idx in heapsort(np_array,k):
63
- i=len(sentences[idx])-1 #based on the index find the sentence- reason for storing idx but not sentence
 
 
 
64
  count=1
65
  number=0
66
  while sentences[idx][i]!='@': #o(8-10 digits)- o(1)
@@ -78,8 +82,7 @@ df=pd.DataFrame({"Title":dataset['train']['Title'],"Plot":dataset['train']['Over
78
  def getOutput(text, size):
79
  sentences=get_pre_processed_data(int(size))
80
  np_array=getSimilarity(sentences,[text])
81
- s=df.iloc[get_top_k_matches(np_array,2,sentences)]['Title']
82
- return f"{s}."
83
 
84
  iface = gr.Interface(fn=getOutput, inputs=[gr.inputs.Textbox(label="Text"), gr.inputs.Number(label="size")], outputs="text")
85
  iface.launch(debug=True)
 
59
 
60
  def get_top_k_matches(np_array,k,sentences):
61
  indices=[]
62
+
63
  for idx in heapsort(np_array,k):
64
+ try:
65
+ i=len(sentences[idx])-1 #based on the index find the sentence- reason for storing idx but not sentence
66
+ catch:
67
+ print(idx)
68
  count=1
69
  number=0
70
  while sentences[idx][i]!='@': #o(8-10 digits)- o(1)
 
82
  def getOutput(text, size):
83
  sentences=get_pre_processed_data(int(size))
84
  np_array=getSimilarity(sentences,[text])
85
+ return df.iloc[get_top_k_matches(np_array,2,sentences)]
 
86
 
87
  iface = gr.Interface(fn=getOutput, inputs=[gr.inputs.Textbox(label="Text"), gr.inputs.Number(label="size")], outputs="text")
88
  iface.launch(debug=True)