vojmahdal commited on
Commit
4e45bbf
·
verified ·
1 Parent(s): 278fa8a

Update date in DB

Browse files
Files changed (1) hide show
  1. db.py +11 -2
db.py CHANGED
@@ -225,20 +225,29 @@ def redact_entities(entities: list[dict[str, Any]] | None) -> list[dict[str, Any
225
  by a ``[TYPE]`` placeholder and character offsets (which point into the
226
  original text) are dropped. Type, score and, for dates/times, the
227
  normalized value are kept.
 
 
 
 
 
 
 
 
228
  """
229
  redacted: list[dict[str, Any]] = []
230
  for ent in entities or []:
231
  if not isinstance(ent, dict):
232
  continue
233
  etype = str(ent.get("type", "") or "")
 
234
  item: dict[str, Any] = {
235
- "text": f"[{etype or 'ENTITY'}]",
236
  "type": etype,
237
  "score": ent.get("score"),
238
  }
239
  if etype in _VALUE_KEEPING_TYPES:
240
  item["kind"] = ent.get("kind")
241
- item["normalized"] = ent.get("normalized")
242
  redacted.append(item)
243
  return redacted
244
 
 
225
  by a ``[TYPE]`` placeholder and character offsets (which point into the
226
  original text) are dropped. Type, score and, for dates/times, the
227
  normalized value are kept.
228
+
229
+ Dates/times are not identifiers, so for them ``text`` is the normalized
230
+ value itself (e.g. ``"2026-10-05"``), not a ``[DATE]`` placeholder - that
231
+ normalized value *is* the structured output the assignment asks for, and
232
+ showing only "[DATE]" in the history/export defeats the point of having
233
+ extracted it. When normalization was not possible (ambiguous or relative
234
+ expressions without a reference date, e.g. "next week"), there is no safe
235
+ value to show, so the placeholder is kept.
236
  """
237
  redacted: list[dict[str, Any]] = []
238
  for ent in entities or []:
239
  if not isinstance(ent, dict):
240
  continue
241
  etype = str(ent.get("type", "") or "")
242
+ normalized = ent.get("normalized") if etype in _VALUE_KEEPING_TYPES else None
243
  item: dict[str, Any] = {
244
+ "text": normalized if normalized else f"[{etype or 'ENTITY'}]",
245
  "type": etype,
246
  "score": ent.get("score"),
247
  }
248
  if etype in _VALUE_KEEPING_TYPES:
249
  item["kind"] = ent.get("kind")
250
+ item["normalized"] = normalized
251
  redacted.append(item)
252
  return redacted
253