DVPPython Studio
Module 2: Make editorial decisions / Build 2 of 4

Normalize model names

Use a controlled lookup without deleting original evidence or guessing unknown providers.

Runs on your computer · 35–55 minutes · no paid services

Download practice filesFiles, commands & notes

Without JavaScript, use the step links and keep your files on your computer.

One useful idea

Normalization produces a new lookup key; it should not rewrite evidence. strip removes outer whitespace and casefold prepares case-insensitive text. Internal whitespace is unchanged: the exact classroom alias must exist in ALIASES.

The fixed dictionary recognizes runway/runwayml, kling/kling ai, veo/google veo and grok/xai grok. It is a teaching vocabulary, not a current vendor registry. Unknown valid text returns canonical None and known False; empty, overlong or nontext inputs remain errors.

Return the original raw text beside the canonical value. That lets a caller see what was supplied and decide whether to expand the vocabulary. A fallback to the cleaned key would blur recognized aliases and unknown guesses.

Refresh first: Validation versus a completed decision, String transformations, Dictionary lookups.

Trace a finished example

from qc_tools import normalize_model

print(normalize_model(" Google VEO "))
print(normalize_model("veo preview"))

The first retains " Google VEO " as original, maps canonical to veo and sets known True. The second retains veo preview, canonical None and known False. Neither call contacts a provider.

The finished implementation is in qc_tools.py. Reading it is guided practice, not independent evidence.

Predict a known alias

What changes for " RUNWAYML "?

Compare your answer · self-reviewed

Only the lookup key changes. Original stays exact; canonical is runway and known is True.

Find the guessing bug

Why is get(key, key) misleading for this contract?

Compare your answer · self-reviewed

It makes an unknown cleaned label look like a canonical known value. Keep None and known False instead.

Preserve evidence

Should an empty string be unknown?

Compare your answer · self-reviewed

No. Empty text is a refused value; it raises ValueError. Unknown means a valid label was not found in the fixed vocabulary.

Try the idea in this browser

Runs in this browser · optional preparation · local project checks remain separate

Try a small function before opening your local files. Python downloads when you choose Run; if it cannot load, your code stays here and the local kit still works. The worker executes on your device, not on a DVP server. Only run code you trust: this is not a hostile-code security sandbox.

JavaScript loads the practice controls. Python starts only after Run.

Read the browser task briefs without running Python

Trace the declared policy

Read the complete function, predict a changed case, then Run. Write normalize_model(raw) using the supplied fixed ALIASES. Require text; strip/casefold a lookup key of 1–80 characters. Return {original: exact raw text, canonical: alias value or None, known: actual boolean}. Unknown text must remain unknown, not become a provider. Keep original whitespace/case as evidence; malformed input is not unknown. Return the specified data for new inputs; wrong types raise TypeError and refused values raise ValueError. These classroom rules do not analyze media or establish objective quality.

Implement the policy independently

Write normalize_model(raw) using the supplied fixed ALIASES. Require text; strip/casefold a lookup key of 1–80 characters. Return {original: exact raw text, canonical: alias value or None, known: actual boolean}. Unknown text must remain unknown, not become a provider. Keep original whitespace/case as evidence; malformed input is not unknown. Return the specified data for new inputs; wrong types raise TypeError and refused values raise ValueError. These classroom rules do not analyze media or establish objective quality.

Change it, then build your own

One controlled change

Compare Google VEO, google veo and veo preview. Write the original/canonical/known triple for each before running the reference.

Your independent task

Write normalize_model(raw) using the supplied fixed ALIASES. Require text; strip/casefold a lookup key of 1–80 characters. Return {original: exact raw text, canonical: alias value or None, known: actual boolean}. Unknown text must remain unknown, not become a provider. Keep original whitespace/case as evidence; malformed input is not unknown. Implement it in practice.py. Import the supplied ALIASES only; do not import the finished normalizer.

What success looks like

Three model-name test methods pass, including Unicode unknown text, exact original whitespace/case, the 80-character limit and caller errors.

Hint 1 · a question

Which value is evidence and which is only a lookup key?

Hint 2 · a concept cue

Use strip/casefold on a new key. None from the alias lookup means unknown; do not change raw.

Hint 3 · a localized example

ALIASES.get(key) gives the mapped value or None. known is canonical is not None; check type and length first.

Need the complete worked solution?

Open qc_tools.py from the kit. Trace it, close it, then try fresh inputs in your own files. Treat the attempt as guided; seeing the solution does not award a practical pass.

Course help is guidance, not independent evidence. With JavaScript, opening help records guidance locally; otherwise note it in your README. Reset does not erase that history.

Repair a failed check

If provenance tests fail, stop assigning the stripped key back to raw. If every label is known, inspect your lookup fallback. Do not map a new provider/version by guessing.

NotImplementedError means a practice stub is still unfinished. Read the failing test name and the last error line. Change one behavior, rerun that build, then rerun all implemented builds.

Show it works on new inputs

Create a before/after JSON sample with two known aliases and two unknown labels. Explain the lookup decision without changing the fixed policy just to satisfy your examples.

Self-review: name the input, result, refused case and reason. Your local test output and explanation are separate from a quiz score; this page does not certify a pass.

Keep the idea

A recognized vocabulary entry is not the same as any normalized string. Preserve the original and make uncertainty explicit.