Spaces:
Sleeping
Sleeping
Alexander Sanchez commited on
Commit ·
aad1d52
1
Parent(s): f1d274f
caligraphy metadata added
Browse files- corpus_loader.py +1 -0
- rag_corrector.py +1 -0
- vector_store.py +2 -0
corpus_loader.py
CHANGED
|
@@ -98,6 +98,7 @@ class CorpusLoader:
|
|
| 98 |
"type": str(row.get("type", "desconocido")),
|
| 99 |
"region": str(row.get("region", "desconocida")),
|
| 100 |
"date": str(row.get("date", "")),
|
|
|
|
| 101 |
"source": source,
|
| 102 |
"corrections": row.get("corrections", []),
|
| 103 |
}
|
|
|
|
| 98 |
"type": str(row.get("type", "desconocido")),
|
| 99 |
"region": str(row.get("region", "desconocida")),
|
| 100 |
"date": str(row.get("date", "")),
|
| 101 |
+
"caligrafia": str(row.get("caligrafia", "desconocida")),
|
| 102 |
"source": source,
|
| 103 |
"corrections": row.get("corrections", []),
|
| 104 |
}
|
rag_corrector.py
CHANGED
|
@@ -119,6 +119,7 @@ class RAGCorrector:
|
|
| 119 |
corr = "; ".join(doc["corrections"]) if doc["corrections"] else "—"
|
| 120 |
examples.append(
|
| 121 |
f"Ejemplo {i} [{doc['type']}, {doc['region']}, {doc['date']}]"
|
|
|
|
| 122 |
f" (similitud={doc['score']}):\n"
|
| 123 |
f" HTR: \"{doc['htr']}\"\n"
|
| 124 |
f" GT: \"{doc['gt']}\"\n"
|
|
|
|
| 119 |
corr = "; ".join(doc["corrections"]) if doc["corrections"] else "—"
|
| 120 |
examples.append(
|
| 121 |
f"Ejemplo {i} [{doc['type']}, {doc['region']}, {doc['date']}]"
|
| 122 |
+
f"caligrafia: {doc['caligrafia']}"
|
| 123 |
f" (similitud={doc['score']}):\n"
|
| 124 |
f" HTR: \"{doc['htr']}\"\n"
|
| 125 |
f" GT: \"{doc['gt']}\"\n"
|
vector_store.py
CHANGED
|
@@ -88,6 +88,7 @@ class VectorStore:
|
|
| 88 |
"type": p.get("type", ""),
|
| 89 |
"region": p.get("region", ""),
|
| 90 |
"date": p.get("date", ""),
|
|
|
|
| 91 |
"corrections": json.dumps(
|
| 92 |
p.get("corrections", []), ensure_ascii=False
|
| 93 |
),
|
|
@@ -131,6 +132,7 @@ class VectorStore:
|
|
| 131 |
"type": meta.get("type", ""),
|
| 132 |
"region": meta.get("region", ""),
|
| 133 |
"date": meta.get("date", ""),
|
|
|
|
| 134 |
"corrections": json.loads(meta.get("corrections", "[]")),
|
| 135 |
"score": round(1 - dist, 4), # cosine similarity
|
| 136 |
})
|
|
|
|
| 88 |
"type": p.get("type", ""),
|
| 89 |
"region": p.get("region", ""),
|
| 90 |
"date": p.get("date", ""),
|
| 91 |
+
"caligrafia": p.get("caligrafia", "desconocida"),
|
| 92 |
"corrections": json.dumps(
|
| 93 |
p.get("corrections", []), ensure_ascii=False
|
| 94 |
),
|
|
|
|
| 132 |
"type": meta.get("type", ""),
|
| 133 |
"region": meta.get("region", ""),
|
| 134 |
"date": meta.get("date", ""),
|
| 135 |
+
"caligrafia": meta.get("caligrafia", ""),
|
| 136 |
"corrections": json.loads(meta.get("corrections", "[]")),
|
| 137 |
"score": round(1 - dist, 4), # cosine similarity
|
| 138 |
})
|