The framing_result column in the independent StagingBench dataset contains short diagnostic strings. Some include a zoom value, a rotation value, or a percentage describing how much of the original frame is visible. This is a useful case for a small parser that answers a narrow question: how many strings explicitly contain each measurement?
StagingBench is a small test of 10 real room photos, with one run per tool and room cell. Counting text fields does not enlarge that sample or establish repeatability. The code below reads scores.csv from the current directory and counts matching strings, without interpreting the photos.
A compact extractor
Use csv to read the records and re to recognize the clauses. Each regular expression contains a capture group for the number, although this example only needs to know whether a match exists.
import csv import re number = r'([+-]?(?:\d+(?:\.\d+)?|\.\d+))' patterns = { 'zoom': re.compile(r'\bzoom\s+' + number + r'(?=;|$)'), 'rotation': re.compile(r'\brotated\s+' + number + r'\s+deg\b'), 'visibility': re.compile(r'\bonly\s+' + number + r'% of the original frame visible\b'), } counts = dict.fromkeys(patterns, 0) with open('scores.csv', newline='', encoding='utf-8') as source: for row in csv.DictReader(source): for name, pattern in patterns.items(): counts[name] += bool(pattern.search(row['framing_result'])) for name, count in counts.items(): print(f'{name}: {count}') Running this snippet against the supplied CSV returns:
zoom: 15 rotation: 5 visibility: 19 They count strings containing the respective clauses, rather than every number printed in the diagnostic field.
Treat the clauses as optional
Do not build a single expression that requires zoom, rotation and visibility to appear together. The clauses are optional: a string can contain a zoom value without a rotation value, for example.
Independent searches preserve that distinction. Each pattern contributes a Boolean value for the current string. A matching clause increments its counter; a missing clause leaves that counter unchanged.
Missing text is not a numerical zero. It also does not justify filling in a default zoom factor or assuming that rotation was absent from the underlying comparison. This parser reports textual presence only.
Respect semicolons and decimals
Semicolons separate clauses inside a CSV field. They are not the CSV delimiter here. Let DictReader handle the file structure before applying any regular expression to framing_result.
The zoom expression uses a lookahead for a semicolon or the end of the string. That allows the value to occur before another clause or at the end. The lookahead checks the boundary without consuming it.
The decimal point is escaped because an unescaped dot in a regular expression means any character. The optional sign matters for rotation: dropping a minus sign would alter the captured value. Raw Python strings keep the backslashes readable.
This numeric pattern accepts ordinary decimal notation, including a fractional value without a leading digit. It does not accept scientific notation or decimal commas. Those limitations are acceptable for the supplied strings, but should be revisited if the producer changes the format.
Match meaning as well as digits
A percentage alone is too broad a target for visibility. These diagnostics can also mention the percentage of output outside the original frame. The visibility pattern therefore requires the wording "of the original frame visible." That phrase distinguishes the requested measurement.
The expressions are deliberately tied to the observed wording. A future change from "rotated" to another label could make a value disappear from this count even though the underlying measurement still exists. Reviewing unmatched text is sensible when adopting a new export.
For interpretation, consult the StagingBench methodology. The script extracts diagnostic fields; the counts do not measure visual quality or identify a preferred tool. Keeping that boundary explicit makes the snippet easier to reuse accurately.
