Spaces:
Running
Running
prince1604 commited on
Commit ·
b3f7149
1
Parent(s): a88e274
Refined generic text detection: added partial matches for short phrases (e.g. 'company logo') while allowing branded logos
Browse files- src/analyzer.py +19 -4
src/analyzer.py
CHANGED
|
@@ -52,11 +52,26 @@ class ImageAnalyzer:
|
|
| 52 |
is_poor = True
|
| 53 |
reason = "Filename pattern detected (slug)"
|
| 54 |
|
| 55 |
-
# B) Generic / Filler Text (
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
generic_terms = {'image', 'photo', 'picture', 'logo', 'banner', 'icon', 'thumbnail', 'placeholder', 'img', 'spacer'}
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
# C) Too Short / Sparse (Lowest Priority)
|
| 62 |
if not is_poor:
|
|
|
|
| 52 |
is_poor = True
|
| 53 |
reason = "Filename pattern detected (slug)"
|
| 54 |
|
| 55 |
+
# B) Generic / Filler Text (Smart check)
|
| 56 |
+
# Flag if alt equals or contains generic terms.
|
| 57 |
+
# Exception: "Brand Name Logo" (usually > 2 words or specific)
|
| 58 |
+
# If word count is low (< 3) AND contains a generic term, it's likely poor.
|
| 59 |
+
# If it is EXACTLY a generic term, it is definitely poor.
|
| 60 |
generic_terms = {'image', 'photo', 'picture', 'logo', 'banner', 'icon', 'thumbnail', 'placeholder', 'img', 'spacer'}
|
| 61 |
+
|
| 62 |
+
if not is_poor:
|
| 63 |
+
if lower_alt in generic_terms:
|
| 64 |
+
# Exact match found (e.g., "logo", "image") -> Bad
|
| 65 |
+
is_poor = True
|
| 66 |
+
reason = "Generic filler text"
|
| 67 |
+
else:
|
| 68 |
+
# Check partial match for short phrases (likely "My Logo", "Chart Image")
|
| 69 |
+
# If phrase is long (>= 3 words), it might be descriptive enough (e.g., "Eminent Tactiles Logo")
|
| 70 |
+
# So we only flag partial generic matches if word count is small (< 3)
|
| 71 |
+
has_generic = any(term in lower_alt.split() for term in generic_terms)
|
| 72 |
+
if has_generic and word_count < 3:
|
| 73 |
+
is_poor = True
|
| 74 |
+
reason = "Generic filler text (partial match)"
|
| 75 |
|
| 76 |
# C) Too Short / Sparse (Lowest Priority)
|
| 77 |
if not is_poor:
|