Midnightar commited on
Commit
2878711
·
verified ·
1 Parent(s): 448497c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -226,15 +226,30 @@ def detect_document(text):
226
  # VEHICLE PLATE NUMBER
227
  # =========================
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  plate_match = re.search(
230
- r"[A-Z]{3}-?\d{3}[A-Z]{2}",
231
  text.upper()
232
  )
233
 
234
  if plate_match:
 
235
  return {
236
  "document_type": "vehicle_plate",
237
- "confidence": 93,
238
  "matched_keywords": [plate_match.group()]
239
  }
240
 
 
226
  # VEHICLE PLATE NUMBER
227
  # =========================
228
 
229
+ plate_patterns = [
230
+
231
+ # Standard Nigerian plates
232
+ r"[A-Z]{2,3}\s?\d{2,3}[A-Z]{1,2}",
233
+
234
+ # OCR damaged versions
235
+ r"[A-Z]{1,3}\d{2,3}[A-Z]{1,3}",
236
+
237
+ # Hyphen formats
238
+ r"[A-Z]{2,3}-?\d{2,3}-?[A-Z]{1,2}"
239
+ ]
240
+
241
+ for pattern in plate_patterns:
242
+
243
  plate_match = re.search(
244
+ pattern,
245
  text.upper()
246
  )
247
 
248
  if plate_match:
249
+
250
  return {
251
  "document_type": "vehicle_plate",
252
+ "confidence": 85,
253
  "matched_keywords": [plate_match.group()]
254
  }
255