Hamda commited on
Commit
83a58a9
1 Parent(s): 70763ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -59,13 +59,21 @@ if (st.checkbox('الاستعانة بالرسم البياني المعرفي
59
 
60
  #@st.cache
61
  def Query2id(voc, query):
62
- return [voc.index[voc['word'] == word].values[0] for word in query.split()]
 
 
 
 
 
 
 
 
 
63
 
64
  id_list = Query2id(df3, sent)
65
  #@st.cache
66
  def setQueriesVoc(df, id_list):
67
  res = []
68
-
69
  for e in id_list:
70
  try:
71
  res.extend(list(df.loc[e]['ID2'].values))
@@ -91,9 +99,6 @@ if (st.checkbox('الاستعانة بالرسم البياني المعرفي
91
  return tmt
92
  tmt = compute_score(L, id_list)
93
  exp_terms = []
94
- for e in sent:
95
- if (e in tmt):
96
- del tmt[e]
97
  t_li = tmt.values()
98
  tmexp = sorted(tmt.items(), key=lambda x: x[1], reverse=True)
99
  i = 0
 
59
 
60
  #@st.cache
61
  def Query2id(voc, query):
62
+ res= []
63
+ for word in query.split():
64
+ try:
65
+ res.append(voc.index[voc['word'] == word].values[0])
66
+ except KeyError:
67
+ st.write('Token Unfound')
68
+ continue
69
+ return res
70
+ #return [voc.index[voc['word'] == word].values[0] for word in query.split()]
71
+ #return [voc.index[voc['word'] == word].values[0] for word in query.split()]
72
 
73
  id_list = Query2id(df3, sent)
74
  #@st.cache
75
  def setQueriesVoc(df, id_list):
76
  res = []
 
77
  for e in id_list:
78
  try:
79
  res.extend(list(df.loc[e]['ID2'].values))
 
99
  return tmt
100
  tmt = compute_score(L, id_list)
101
  exp_terms = []
 
 
 
102
  t_li = tmt.values()
103
  tmexp = sorted(tmt.items(), key=lambda x: x[1], reverse=True)
104
  i = 0