Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,13 @@ model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
13 |
def compute_pca(data):
|
14 |
# data is expected to be a list of dictionaries with 'Identifier' and 'Text' keys
|
15 |
df = pd.DataFrame(data)
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
if valid_entries.empty:
|
18 |
return gr.Plot.update(value=None, label="No data to process. Please fill in the boxes.")
|
19 |
|
@@ -25,6 +31,7 @@ def compute_pca(data):
|
|
25 |
pca_result = pca.fit_transform(embeddings)
|
26 |
|
27 |
# Add PCA results to the DataFrame
|
|
|
28 |
valid_entries['PC1'] = pca_result[:, 0]
|
29 |
valid_entries['PC2'] = pca_result[:, 1]
|
30 |
|
|
|
13 |
def compute_pca(data):
|
14 |
# data is expected to be a list of dictionaries with 'Identifier' and 'Text' keys
|
15 |
df = pd.DataFrame(data)
|
16 |
+
|
17 |
+
# Remove rows where 'Identifier' or 'Text' is empty or contains only whitespace
|
18 |
+
valid_entries = df[
|
19 |
+
(df['Identifier'].str.strip() != '') &
|
20 |
+
(df['Text'].str.strip() != '')
|
21 |
+
]
|
22 |
+
|
23 |
if valid_entries.empty:
|
24 |
return gr.Plot.update(value=None, label="No data to process. Please fill in the boxes.")
|
25 |
|
|
|
31 |
pca_result = pca.fit_transform(embeddings)
|
32 |
|
33 |
# Add PCA results to the DataFrame
|
34 |
+
valid_entries = valid_entries.reset_index(drop=True)
|
35 |
valid_entries['PC1'] = pca_result[:, 0]
|
36 |
valid_entries['PC2'] = pca_result[:, 1]
|
37 |
|