Update app.py
Browse files
app.py
CHANGED
@@ -6,21 +6,28 @@ import json
|
|
6 |
from sentence_transformers import SentenceTransformer
|
7 |
|
8 |
def load_data():
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
embeddings, patent_numbers, metadata = load_data()
|
26 |
|
|
|
6 |
from sentence_transformers import SentenceTransformer
|
7 |
|
8 |
def load_data():
|
9 |
+
try:
|
10 |
+
with h5py.File('patent_embeddings.h5', 'r') as f:
|
11 |
+
embeddings = f['embeddings'][:]
|
12 |
+
patent_numbers = f['patent_numbers'][:]
|
13 |
+
|
14 |
+
metadata = {}
|
15 |
+
with open('patent_metadata.jsonl', 'r') as f:
|
16 |
+
for line in f:
|
17 |
+
data = json.loads(line)
|
18 |
+
metadata[data['patent_number']] = data
|
19 |
+
|
20 |
+
print(f"Embedding shape: {embeddings.shape}")
|
21 |
+
print(f"Number of patent numbers: {len(patent_numbers)}")
|
22 |
+
print(f"Number of metadata entries: {len(metadata)}")
|
23 |
+
|
24 |
+
return embeddings, patent_numbers, metadata
|
25 |
+
except FileNotFoundError as e:
|
26 |
+
print(f"Error: Could not find file. {e}")
|
27 |
+
raise
|
28 |
+
except Exception as e:
|
29 |
+
print(f"An unexpected error occurred while loading data: {e}")
|
30 |
+
raise
|
31 |
|
32 |
embeddings, patent_numbers, metadata = load_data()
|
33 |
|