DINGOLANI commited on
Commit
28c99b4
·
verified ·
1 Parent(s): 335d436

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +102 -2
app.py CHANGED
@@ -1,3 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import kagglehub
3
  from sentence_transformers import SentenceTransformer, util
@@ -38,10 +136,11 @@ model = SentenceTransformer(model_name)
38
  # Function to find synonyms dynamically with fallback
39
  def find_synonym(word, top_n=1):
40
  query_embedding = model.encode(word, convert_to_tensor=True)
41
- results = util.semantic_search(query_embedding, model.encode(designer_data + category_data, convert_to_tensor=True), top_k=top_n)
 
42
  # Check if results exist
43
  if results and len(results[0]) > 0:
44
- return [designer_data + category_data[result['corpus_id']] for result in results[0] if result['score'] > 0.6]
45
  return [] # Return an empty list if no results
46
 
47
  # Function to correct spellings
@@ -94,3 +193,4 @@ with gr.Blocks() as demo:
94
  )
95
 
96
  demo.launch(share=True)
 
 
1
+ Vestiaire Autocomplete
2
+ 1
3
+ 2
4
+ 3
5
+ 4
6
+ 5
7
+ 6
8
+ 7
9
+ 8
10
+ 9
11
+ 10
12
+ 11
13
+ 12
14
+ 13
15
+ 14
16
+ 15
17
+ 16
18
+ 17
19
+ 18
20
+ 19
21
+ 20
22
+ 21
23
+ 22
24
+ 23
25
+ 24
26
+ 25
27
+ 26
28
+ 27
29
+ 28
30
+ 29
31
+ 30
32
+ 31
33
+ 32
34
+ 33
35
+ 34
36
+ 35
37
+ 36
38
+ 37
39
+ 38
40
+ 39
41
+ 40
42
+ 41
43
+ 42
44
+ 43
45
+ 44
46
+ 45
47
+ 46
48
+ 47
49
+ 48
50
+ 49
51
+ 50
52
+ 51
53
+ 52
54
+ 53
55
+ 54
56
+ 55
57
+ 56
58
+ 57
59
+ 58
60
+ 59
61
+ 60
62
+ 61
63
+ 62
64
+ 63
65
+ 64
66
+ 65
67
+ 66
68
+ 67
69
+ 68
70
+ 69
71
+ 70
72
+ 71
73
+ 72
74
+ 73
75
+ 74
76
+ 75
77
+ 76
78
+ 77
79
+ 78
80
+ 79
81
+ 80
82
+ 81
83
+ 82
84
+ 83
85
+ 84
86
+ 85
87
+ 86
88
+ 87
89
+ 88
90
+ 89
91
+ 90
92
+ 91
93
+ 92
94
+ 93
95
+ 94
96
+ 95
97
+ 96
98
+ 97
99
  import gradio as gr
100
  import kagglehub
101
  from sentence_transformers import SentenceTransformer, util
 
136
  # Function to find synonyms dynamically with fallback
137
  def find_synonym(word, top_n=1):
138
  query_embedding = model.encode(word, convert_to_tensor=True)
139
+ combined_data = designer_data + category_data
140
+ results = util.semantic_search(query_embedding, model.encode(combined_data, convert_to_tensor=True), top_k=top_n)
141
  # Check if results exist
142
  if results and len(results[0]) > 0:
143
+ return [combined_data[result['corpus_id']] for result in results[0] if result['score'] > 0.6]
144
  return [] # Return an empty list if no results
145
 
146
  # Function to correct spellings
 
193
  )
194
 
195
  demo.launch(share=True)
196
+