Spaces:
Running
Running
prince1604 commited on
Commit ·
14aaae8
1
Parent(s): d7353b3
Merged short alt detection back into main 'poor quality' report and removed separate 'short_alt' counts as requested
Browse files- src/analyzer.py +5 -35
src/analyzer.py
CHANGED
|
@@ -89,44 +89,15 @@ class ImageAnalyzer:
|
|
| 89 |
poor_quality_images.append({'src': img['src'], 'alt': alt_text, 'reason': reason})
|
| 90 |
total_poor_quality += 1
|
| 91 |
|
| 92 |
-
#
|
| 93 |
-
#
|
| 94 |
-
# We interpret this as requiring two distinct, non-overlapping sets.
|
| 95 |
|
| 96 |
-
non_overlapping_poor = []
|
| 97 |
-
non_overlapping_short = []
|
| 98 |
-
|
| 99 |
-
for img in poor_quality_images:
|
| 100 |
-
if img['reason'].startswith("Too short") or img['reason'].startswith("Too few words"):
|
| 101 |
-
non_overlapping_short.append(img)
|
| 102 |
-
else:
|
| 103 |
-
non_overlapping_poor.append(img)
|
| 104 |
-
|
| 105 |
-
# Update legacy counters (only adding strictly short ones to the legacy global count)
|
| 106 |
-
# But wait, should true "poor" ones be tracked globally too?
|
| 107 |
-
# The summary returned `total_poor_quality` which was everything.
|
| 108 |
-
# If we separate them, we should probably track them separately in summary too if possible,
|
| 109 |
-
# but for now we update the page level reporting as requested.
|
| 110 |
-
|
| 111 |
-
# Update global counters strictly based on the split
|
| 112 |
-
total_short_alt_legacy += len(non_overlapping_short)
|
| 113 |
-
|
| 114 |
-
# The 'total_poor_quality' global in summary currently counts EVERYTHING.
|
| 115 |
-
# If we want to maintain that consistency, we keep it as processed in loop.
|
| 116 |
-
# BUT user said "remove and add in poor perfectly" -> implies separation.
|
| 117 |
-
# Let's subtract the short ones from the global poor quality count for the SUMMARY as well?
|
| 118 |
-
# actually, `total_poor_quality` was just `+=1` in the loop for every hit.
|
| 119 |
-
# Let's adjust it to only count the non-overlapping poor ones.
|
| 120 |
-
total_poor_quality -= len(non_overlapping_short)
|
| 121 |
-
|
| 122 |
pages_report.append({
|
| 123 |
"page_url": page_url,
|
| 124 |
"missing_alt_count": len(missing_images),
|
| 125 |
-
"poor_quality_count": len(
|
| 126 |
-
"short_alt_count": len(non_overlapping_short), # Mutually exclusive count
|
| 127 |
"images_without_alt": list(set(missing_images)),
|
| 128 |
-
"images_with_poor_alt":
|
| 129 |
-
"images_with_short_alt": non_overlapping_short
|
| 130 |
})
|
| 131 |
|
| 132 |
return {
|
|
@@ -134,8 +105,7 @@ class ImageAnalyzer:
|
|
| 134 |
"total_pages_scanned": len(site_data),
|
| 135 |
"total_images_found": total_images,
|
| 136 |
"total_images_missing_alt": total_missing_alt,
|
| 137 |
-
"total_images_poor_quality": total_poor_quality
|
| 138 |
-
"total_images_short_alt": total_short_alt_legacy # Reverted to strictly short counts
|
| 139 |
},
|
| 140 |
"details": pages_report
|
| 141 |
}
|
|
|
|
| 89 |
poor_quality_images.append({'src': img['src'], 'alt': alt_text, 'reason': reason})
|
| 90 |
total_poor_quality += 1
|
| 91 |
|
| 92 |
+
# User Intent: "short alt list and that count are add in poor not it show separately"
|
| 93 |
+
# Action: Consolidate everything into 'poor_quality' and remove specific 'short_alt' reporting.
|
|
|
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
pages_report.append({
|
| 96 |
"page_url": page_url,
|
| 97 |
"missing_alt_count": len(missing_images),
|
| 98 |
+
"poor_quality_count": len(poor_quality_images), # Contains ALL poor images (Generic, Filename, Short)
|
|
|
|
| 99 |
"images_without_alt": list(set(missing_images)),
|
| 100 |
+
"images_with_poor_alt": poor_quality_images
|
|
|
|
| 101 |
})
|
| 102 |
|
| 103 |
return {
|
|
|
|
| 105 |
"total_pages_scanned": len(site_data),
|
| 106 |
"total_images_found": total_images,
|
| 107 |
"total_images_missing_alt": total_missing_alt,
|
| 108 |
+
"total_images_poor_quality": total_poor_quality
|
|
|
|
| 109 |
},
|
| 110 |
"details": pages_report
|
| 111 |
}
|