Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,18 @@ import gradio as gr
|
|
2 |
from sentence_transformers import SentenceTransformer
|
3 |
from sklearn.metrics.pairwise import cosine_similarity
|
4 |
import spacy
|
|
|
5 |
|
6 |
-
#
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Carica il modello SentenceTransformer
|
10 |
model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2', device='cpu')
|
|
|
2 |
from sentence_transformers import SentenceTransformer
|
3 |
from sklearn.metrics.pairwise import cosine_similarity
|
4 |
import spacy
|
5 |
+
import zipfile
|
6 |
|
7 |
+
# Estrai il file ZIP
|
8 |
+
zip_path = os.path.join(os.getcwd(), "en_core_web_sm.zip")
|
9 |
+
extract_dir = os.path.join(os.getcwd(), "en_core_web_sm")
|
10 |
+
|
11 |
+
if not os.path.exists(extract_dir):
|
12 |
+
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
13 |
+
zip_ref.extractall(extract_dir)
|
14 |
+
|
15 |
+
# Carica il modello
|
16 |
+
nlp = spacy.load(extract_dir)
|
17 |
|
18 |
# Carica il modello SentenceTransformer
|
19 |
model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2', device='cpu')
|