Spaces:
Sleeping
Sleeping
Delete vector.py
Browse files
vector.py
DELETED
|
@@ -1,11 +0,0 @@
|
|
| 1 |
-
import numpy as np
|
| 2 |
-
import re
|
| 3 |
-
|
| 4 |
-
DIM = 512
|
| 5 |
-
|
| 6 |
-
def embed(text: str) -> np.ndarray:
|
| 7 |
-
v = np.zeros(DIM, dtype=np.float32)
|
| 8 |
-
for w in re.findall(r"[a-zA-Z]{2,}", text.lower()):
|
| 9 |
-
v[hash(w) % DIM] += 1.0
|
| 10 |
-
n = np.linalg.norm(v)
|
| 11 |
-
return v / n if n > 0 else v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|