Skip to main content

Order guide parser

ai_mercedes.order_guides reads the mborderguides.com guide pages that raw/order_guides collects, and derives model, feature and rule records from them.

from ai_mercedes.order_guides.derive import GuideContext, derive
from ai_mercedes.order_guides.parser import parse_document

document = parse_document(html)
derived = derive(document, GuideContext(guide_id="2027/glc/suv1", model_year=2027, is_amg=False))

parse_document returns what the page prints. derive turns that document into records by the rules below.

What the page holds​

Each section heading (Paint, Wheels, Upholstery, Trims, Packages, Options) is followed by swatches grouped under subtitles, then one table with every row of the section. A row's group is the subtitle of its swatch. The group separates headliners from upholstery, and soft tops from paint. In Options, each table has its own subtitle:

  • Factory Options
  • VPC Installed Options
  • Mercedes-Benz Store

Notes are printed in the table cell under the name, and under the swatch. Wheel swatches repeat the row's cells as text, so swatch text that matches a cell is not a note.

Package contents are <li> items, written CODE - Name, Name (CODE), 877+U25 - Name. An item can name a second code: (incl. 32U Sound Personalization).

An item can hold a nested list. Under an item ending Choice of:, the nested list holds the choices. Under any other item, the nested list holds more of the package's contents.

Standard equipment is listed per model, with codes written first (382 5G Communication Module) or last in parentheses (Larger Fuel Tank (916)). Many items have no code.

The wheel table's Mobility column lists the tires a wheel can be ordered with, R01 summer and R02 all-season. It also lists the wheel-bound codes, which come with the wheel: R66, B51 TIREFIT and 690 minispare.

Option codes​

The guide prints bare codes. The type prefix comes from the section:

RowPrefix
Paint2:
Paint named Two-Tone, soft-top color0:
Upholstery4:
Headliner0:
Package9:, or 0: when the code starts with P
VPC installed option6:
Mercedes-Benz Store item0:
A code the guide has no row for, in a package code's format (DG0, DA0)9:
Any other row, package content, tire0:

The 2025 and 2026 GLE guides print a letter after a three-character code, as in 922U and 111A. They print PKG after a package code, as in DB4PKG. The parser drops the letter and the PKG.

Paint and upholstery reuse bare codes (934 is a paint and a leather on the G-Class), so a code in a note is matched to the row whose name or section the note mentions, as in N/a w/ paint 993. When the note mentions neither, as w/ 825 only on a seat belt does, the code is matched to the upholstery. Options reuse bare codes too: 201 is both Black Leather and 4.5-degree rear-axle steering. A package or standard-equipment item whose name shares no word with the paint or upholstery row of its code is an option.

Features​

  • A row with its own price, or a standard-equipment item, is a standalone feature with no parent_package_code. A row with a blank price has a null price.
  • A standard-equipment item with several codes, as in Digital Extra: MBUX Smartphone Integration (14U) incl. CarPlay (16U) and Android Auto (17U), gets one feature per code, named by the words before that code.
  • A package item the guide does not list as a row is a wheel when its name describes a wheel, as in 20-inch AMG multi-spoke light-alloy wheels, and an option otherwise.
  • A package's items are child features under the package, not standard. A package whose note says it includes another package's content also gets that package's items, and the two packages are only_one_of.
  • A package's contents lists its items that name no code, sorted by name. The page can list them in a different order from one fetch to the next.
  • is_standard means standard on the model. is_configurable means a buyer can choose to get it. A standard wheel, tire, paint, top, upholstery, headliner, trim or center console is also configurable when the model offers more than one of its kind.
  • A row such as H08+775 orders two codes together. Each part is its own feature and requires the other. A part the guide lists as its own row takes that row's prefix, so DD1 in 4:DD1+975 is 9:DD1. A rule that names the combined row names its first part.
  • A row is offered on the models its Availability column lists.
  • When a row offered on a model requires one of a set of rows, and the guide lists none of that set for the model, every row in the set is offered on that model.

Rules​

A note is split into clauses, and each clause is classified by its wording. A note splits:

  • at the end of a sentence, but not at a period after Exec., Pkg. or Incl., or before a lowercase and, or, on or for, as in Std. on SL63 and the stray period in Only available on GLE350W4. and GLE500e;
  • at -, | and [;
  • before must have, must select or must choose;
  • before a parenthesis that begins with not or n/a;
  • after a comma, before not, n/a, requires, available, only, must or also;
  • after a closing parenthesis, before available.

An exclusion splits before only w/, so not w/ 808 only w/ DB2, DB3, DD5, DD4 excludes 808 and requires one of the four packages.

A model before a comma, as in On SL55, stays with the clause after the comma. So does a condition, as in If DG3 selected. On SL55, only available w/ Performance Trim Line applies to the SL55 only. If DG3 selected, must have DB1 produces no rule.

WordingRule
Requires, Required, Only with, Only possible w/, Only in combination w/, Compatible with Upholsteries:, Must select, Must choose between, Choice of, w/ 825 onlyrequires_one_of on the row
Available with, Available only withone requires_one_of on the row, with every code the clause lists
Not available with, Not available in conjunction with, Not w/, NA with, Not compatible with, Can't be had withexcludes on the row
Required by Xrequires_one_of the row, on X
Required for all upholsteriesrequires_one_of the row, on every upholstery
Included with X, Included w/ X, Single Option or included w/ Xthe row is also a child of X, when the guide lists X
contents of DD0 are included in DD6 and DD7DD6 and DD7 include DD0's contents, and each is only_one_of with DD0
Not available for <model>, N/A on <model>, <model> N/A, <model> only, Only <model>, Only available for <model>limits the models
<features> only, as in 19" wheels onlyrequires_one_of those features
MB-Tex not with Pinnacle Trim (DX2), AMG Line upholstery … only available with headliner black (51U)excludes / requires_one_of on the row; the words before not with or only available with are ignored
Includes Heated Steering Wheel (443) & Heated Washer System (875)the row is a package, and the codes are its children
A name ending for Vehicles w/ DB4requires_one_of [9:DB4]
Must have DX2 & DA2, Must have one of: 551, 561, 851, One of (584,577,575,573)requires_one_of
(replaces Y05)excludes [0:Y05]
On a paint, wheel, tire, top, upholstery, headliner, trim or center console: Includes U38 Nappa Leather Dashboardrequires_one_of [0:U38]
Standard, Standard on <model>, Std on <model>, <model> Standard Wheelstandard on those models
For GLC350E4, TIREFIT (B51) replaces spare wheel (690)swaps the wheel-bound code on that model

Available with Metal Weave (H64), … (H04), and Fineline Anthracite Wood (H08) lists alternatives, so the row requires one of the three. Available with produces no rule when every code it lists is an option, an accessory or a package other than a trim line, as in Available w/ Two-Tone Dashboard (ZI3). A tire does not count as an option here. A clause that says only, as in available with DG1 only, produces the rule even when every code it lists is an option, an accessory or a package.

A comma-separated list whose last item follows & or and, as in Requires A (DB0), B (U09), & C (293), requires every item. Each item gets its own requires_one_of rule.

Each upholstery requires one of the headliners that its row's Headliner column names. A Headliner cell that names only colors, as in Black or Grey, names the headliner rows whose names contain those colors. When a color matches no headliner row, the upholstery gets no headliner rule.

A model before only w/ or Requires limits the clause to that model, so SL43 only w/ DY2 applies to the SL43R only, and GLE450W4 Requires AIRMATIC Pkg (DC8) to the GLE450W4. Such a model has letters before its number, so a code such as DG1 is not read as one. A model after a code that is not in parentheses also limits the clause, so Requires DE6 AMG DYNAMIC PLUS Pckg on GT55 applies to the GT55 only.

Models before a colon limit the clause to those models, as in GLS450W4: Required AMG Line (DG1) and GLE350W4 & GLE500e: Requires AMG Line (DG1). A bare number before the colon, as in 63: Requires DE8, limits the clause to every model whose name contains that number. A clause limited to models the guide does not list produces no rule.

A row whose notes limit it to some models, as Only available on GLE350W4 and GLE500e4 does, restricts nothing on the other models, where it may be standard.

A leading Plausi: or Plausi update: label is dropped.

The parser reads i.c.w. and icw as in combination with, and drops Click to Enlarge/ at the start of a note. A clause about a price, as in Leather price included in DD7 Package, produces no rule.

A package requires one of the choices in each of its Choice of: or Must choose lists. The choices are not children of the package.

A package item whose code is a pattern, as in 8xx - Nappa Leather Upholstery (801 or 885), is not a child. The package requires one of the codes in the item's parentheses.

The extra charge printed after a package item, as in (+$1,100), is the child's price.

A clause that names features without codes is resolved by name, then by category (Leather Upholstery, 19" or 20" wheels, 7xx level upholstery). Those rules are marked inferred. for standard line 300/300 4M limits a clause to the GLC300W and GLC300W4. Only available with Premium Trim (DX0) produces no rule. DX0 means that neither DX1 nor DX2 is ordered, and the contents of DX1 and DX2 include the row.

Two kinds of packages are only_one_of, and those rules are marked inferred:

  • the trim-line packages whose codes share a prefix, such as DX1 Exclusive and DX2 Pinnacle, or DY1 and DY2;
  • a package and its Plus version, such as AMG Line and AMG Line Plus w/ Night Package.

Neither rule applies when one of the packages requires another, as the GT guide's DF1 requires DC1. The rule does not apply on a model where one of the packages is standard or not offered.

A model's paints are also only_one_of, and so are its upholsteries. Each of these rules lists the paint or upholstery rows that the guide offers on the model, so two models of one guide can have different rules. Headliners and soft-top colors are in neither rule. The rules are marked inferred, and their source is paints or upholsteries. They do not require a paint or an upholstery.

When the guide offers a two-tone paint on a model, the model has no paint rule. A two-tone car has the two-tone code and its paints. For example, a Maybach S-Class with Moonlight White / Obsidian Black Two-Tone (0:C37) also has Obsidian Black Metallic (2:197) and MANUFAKTUR Moonlight White Metallic (2:885).

Parts of a target separated by ; are each required, as in Only with 85R wheel; 521, 524, or 529 upholsteries. In a list such as L6J Steering Wheel, DB5 package, and 982, 984, or 987 upholstery, the alternatives joined by or are one group. An upholstery code printed with a trailing letter, as 141A is, names upholstery 141. A row name is matched with w/ read as with.

Required w/ DA2 makes DA2 require the row, and Required with 7xx level upholstery makes each 7xx upholstery require it. When the clause names a trim line, as in Required w/ DX2, the row requires the trim line instead.

These clauses produce no rule:

  • a requirement that can be deselected, as in Requires RP5 but can be deselected, if replaced with alternative wheel;
  • a restriction explained by since … std, as in Only w/ 651 or 251 upholsteries, since other upholsteries come with black already std;
  • a clause that applies if or when a feature is selected, ordered or equipped;
  • a clause that begins with No price or No charge, as in No price option on S 580 only;
  • a requirement with an alternative that has no code and names no row, as in Available with Luxury Line or AMG Line (DG3).

When an alternative has no code but names a row, the rule includes that row. Requires Exclusive Interior Package or Exclusive Interior Package Plus (DB3) requires one of DB3 and DB2.

A rule never names its own row. Not with DC1/DF1/DC2 on DF1 excludes DC1 and DC2.

A clause that begins with Adds or Available and ends in a price, such as Available w/ P55 Night Package ($200) or Adds 360° Camera only w/ DX1 ($600), states the row's price alongside another feature and produces no rule. So does Available with or without AMG Line (DG3).

Only compatible with and required with 2xx interiors makes the row require one of the 2xx upholsteries. It also makes each of those upholsteries require the row. A printed code the guide does not list, followed by the name of a row, resolves to that row: Requires 459 Adjustable Damping Suspension resolves to 457.

When a package requires another package, and each requires one of a set of the same kind of feature, the package's code is added to the required package's set. DG2 requires DG3, so DG2 is added to DG3's set of upholsteries.

A wheel requires one of the tires its Mobility column lists. A tire or wheel-bound code does not require one of the wheels whose Mobility column lists it. Standard wheels and the wheels of a package have no Mobility column, so the wheels whose Mobility column lists a tire or wheel-bound code are not all the wheels that vehicles with that code have. On a wheel whose Mobility column lists tires, the wheel's own rule already limits the vehicle to one of those tires. No rule limits a wheel-bound code such as Extended Mobility Tires (R66) to the wheels whose Mobility column lists it.

A package that contains a required code meets the requirement, and the rule lists the package too. Exclusive Trim (DX1) and Pinnacle Trim (DX2) contain MBUX Navigation Premium (PBG), so Requires MB Navigation (PBG) on DA2 requires one of PBG, DX1 and DX2.

A package contains:

  • its children;
  • the contents of every package whose contents it includes;
  • for a Plus version, the package it extends.

A package item that offers a choice, as in Black (61U) or Macchiato Beige (65U) Microfiber Headliner (… must select one of), is not part of the package's contents.

A requirement for a trim line is met only by that trim line. Only available with DY1 requires DY1, although DY2 includes DY1's contents.

A Plus version is matched by name. The match ignores parenthesized text and accepts a misspelled word, so MANUFAKTUR Interior Package Plus is the Plus version of MANUFAKUR Interior Package.

only w/ DC4, DC1 and DF1 requires one of the codes. Requires one of: Black Microfiber Headliner (61U) or … Headliner (DD1+71U) requires one of 61U and DD1. An alternative that lists several codes ordered together, as DD1+71U does, is represented by its first code. Requires Pinnacle (DY2) and one of 974, 976, 977 or 979 Upholsteries requires DY2 and one of the four upholsteries.

A number in the hundreds before upholsteries or interiors, as in Not with 200 or 800 Upholsteries, names the 2xx and 8xx upholsteries. The parser does not read the number as a code. Nappa Leather (800,500,900 or A00) names the 8xx, 5xx, 9xx and Axx upholsteries. 2XX/8XX upholstery names the 2xx and 8xx upholsteries. A code family in a conjunction is resolved too, so Only with DD6 & 9XX Upholstery requires DD6 and one of the 9xx upholsteries. A code the guide lists is a code even when it looks like a family, as wheel RXX does.

A rule can name a code that no feature has, such as a headliner the guide names only in the upholstery table. The rule is still written, so it applies to the feature when another source, such as NetSTAR, supplies it. The parser does not create a feature for a code the guide only mentions. A row included with a package the guide does not list is not a child of that package.

A requirement is not written on a model where one of its codes is standard. DG1 is standard on the GLS580W4, so Only with AMG Line (DG1) is not written on that model.

A package's requirement for one of its own contents is not written. In the GLS SUV guide, DG1 contains Illuminated Central Star (24U), so DG1's Requires Illuminated Central Star (24U) is not written.

derived.notes records what every clause became. A clause marked unresolved produced no rule.

PDF guides​

Some model years have no guide page. The model-year list of their class omits them, and the class page (/en_us/vehicle-class/<class>) links a PDF on Contentful (assets.eu.ctfassets.net or downloads.eu.ctfassets.net) from a button at its top, such as MY27_GLS_SUV_DOG_11.10.pdf. The AMG PDFs are linked from the AMG class page (/en_us/vehicle-class/<class>-amg), which the class page links. The date in the file name is the revision. A new revision has a new URL, and a class page can link more than one revision of a guide at once: the GT class page links MY27_GT_4-Door_DOG_Final_11-3-2026.pdf and MY27_GT_4-Door_DOG_Final_11-5-2026.pdf.

raw/order_guide_pdfs_latest downloads every linked PDF, and raw/order_guide_pdfs snapshots it daily. The class pages need the same session as the guide pages; the PDFs need none.

ai_mercedes.order_guides.parser.parse_pdf reads a PDF into the OrderGuideDocument that parse_document reads from a page, so derive turns both into records by the same rules:

from ai_mercedes.order_guides.derive import GuideContext, derive
from ai_mercedes.order_guides.parser import parse_pdf

guide = parse_pdf(content)
derived = derive(guide.document, GuideContext(guide_id="pdf/MY27_GLS_SUV_DOG_11.10", model_year=guide.model_year, is_amg=False))

A PDF prints the sections of a guide page, each under the title of a PDF page:

PagesRead as
Model Rangeone ModelCard per column, named by its MODEL CODE
Standard Equipmentthe items marked • under each model
Paints, Wheels, Headliners, Trims, Steering Wheelsswatches, each headed by its code
MB-Tex, Leather, Nappa Leather and the other upholstery pagesone upholstery per code, with its notes and prices
Upholstery Detailsthe upholsteries' details, such as Headliner
Packages, Factory Options, VPC Installed Optionsone row per code, with a price, Std. or - under each model

Headliners are upholstery rows grouped as Headliners, and steering wheels are options, as on a guide page. A table cell is read like a guide page's availability and price. A row offered on some models lists them, and a model whose cell prints Std. is named in a Standard on <models> note. A table header names a model by its code, its name or the start of either, as the GT guide's GT 53 names GT53C4.

The notes under a swatch or an upholstery are printed on wrapped lines. A line continues the note above it when the line starts lowercase or with ( or &, or when the line above ends mid-phrase. A line also continues the note above it when the line above ends in a space, unless that note ends in a period or only, or the line opens a clause, as GLE450W4 Requires AIRMATIC Pkg (DC8) does. All Models restricts nothing and is dropped.

The model year and the publication date are read from the page footers, because a revision table can end before the PDF's publication date.

MercedesOrderGuidesComponent drops a PDF guide whose baumusters a guide page of the same model year prints, and a PDF guide whose baumusters a later PDF prints. A PDF guide's guide_id is pdf/ and its file name without the extension.

The parser does not read:

  • the colored markers for limited capacity and a delayed option, as the page parser drops (Delayed);
  • the Upholstery Availability matrix, which repeats per upholstery family what each upholstery's notes say;
  • the Options in Detail and Vehicle Specifications pages.

Transformed tables​

MercedesOrderGuidesComponent reads each daily partition of mercedes/mbusa/raw/order_guides and of mercedes/mbusa/raw/order_guide_pdfs. It derives every guide and writes three partitioned tables:

TableRecordKey
mercedes/mbusa/transformed/order_guides_modelsOrderGuideModelRecordmodel_year, baumuster_code
mercedes/mbusa/transformed/order_guides_featuresOrderGuideFeatureRecordmodel_year, baumuster_code, option_code, parent_package_code
mercedes/mbusa/transformed/order_guides_rulesOrderGuideRuleRecordmodel_year, baumuster_code, subject_code, rule_type, codes

The guides of one partition are deduplicated together. A model is keyed by its baumuster code, because guides that print model names have no model_code. The guide_id column names the guide each record came from.

Some non-AMG guides, such as 2026/gt/cpe, print the same baumusters as their AMG guide (2026/gt/cpe/amg). The component drops such a non-AMG guide after deriving it, so these baumusters' records come from the AMG guide.

The component reads only guides of min_model_year and later, which is 2025: the parser is verified against those guides. The run fails on:

  • a partition that holds no such guide;
  • a guide that fails to parse;
  • a guide that derives no models or no features.

A partial table would otherwise remove guides from the downstream tables while the materialization succeeds.

derived.notes is not written to the warehouse.

Enriched and consolidated tables​

MercedesOrderGuidesEnrichmentComponent writes three tables under mercedes/mbusa/enriched/:

  • order_guides_models
  • order_guides_features
  • order_guides_rules

For each partition, the component joins the guide records on model_year and the six-character baumuster_code to the same partition of two sources:

  • transformed/netstar_models, which lists the models of the model years NetSTAR takes orders for.
  • transformed/nafta_inventory, which also lists the models of earlier model years still on dealer lots.

A record takes NetSTAR's model_code and vehicle_class_code. Where NetSTAR does not list the model, the record takes NAFTA's model_code, and its vehicle_class_code takes NAFTA's model_class. The component renames NAFTA's AMGGT class to NetSTAR's GT.

The two sources can give one baumuster different model codes. For example, NetSTAR's CLA250+E is NAFTA's CLA250E.

A guide model that neither source lists is dropped, together with its features and rules. The model_codes_matched check on enriched/order_guides_models lists each dropped model.

The enriched models and features have the columns of netstar_models and netstar_features:

  • option_id is the guide's option code.
  • is_default_selection is the guide's is_standard.
  • group and category are the NetSTAR values for the guide's feature_type. The consolidated feature_type expression reads them.
  • rules is empty. The guide's rules are rows of enriched/order_guides_rules.

Each row of enriched/order_guides_rules has the fields of ai_core.entities.RuleEntity. Each guide rule type becomes a RuleType:

  • A requires_one_of rule becomes an inclusion rule. Its one IF part is the subject.
  • An excludes rule becomes an exclusion rule. Its one IF part is the subject.
  • An only_one_of rule stays only_one_of and has no IF part.

A rule is keyed by its model, subject, rule_type and rule_key, which joins its codes with commas.

In the consolidated tier, the guides are the order_guides source group of models and features, with priority 3. NetSTAR has priority 1 and NAFTA has priority 2. On every field that NetSTAR or NAFTA also has, their value takes precedence over the guide's. A feature that only the guide lists becomes its own row of consolidated/features.

is_configurable is the exception. Wherever a guide listed the feature for the model within the source group's history window, the consolidated is_configurable is the latest order_guides_is_configurable in that window. The guide source groups keep the default window of 365 days, as the Audi and Stellantis guide source groups do. A model, feature or rule that a guide no longer lists stays in the consolidated tables until its last guide row leaves the window.

The guides are the only source of consolidated/rules.

Tires on NAFTA inventory​

A NAFTA vehicle lists its wheel and usually no tire. A NetSTAR vehicle lists both. When a guide's Mobility column names one tire for a wheel, NetSTAR vehicles with that wheel have that tire.

MercedesNaftaInventoryComponent writes enriched/nafta_inventory, which is the consolidated tier's NAFTA inventory source. It is transformed/nafta_inventory with the base codes dropped and a tire added to some vehicles' feature_refs. For each vehicle, it collects the tires that the vehicle's wheels require. It reads them from the inclusion rules that a wheel's Mobility column produces, in enriched/order_guides_rules. A vehicle gets a tire when:

  • exactly one of 0:R01 and 0:R02 is among the collected tires, and
  • the vehicle lists neither.

A vehicle whose wheels allow both tires, or whose model has no guide, keeps its feature_refs unchanged. Other tire codes in a Mobility column, such as R06, are ignored.

The first partition of enriched/order_guides_rules is 2026-10-21. mborderguides.com publishes no earlier guides. A partition of enriched/nafta_inventory before 2026-10-21 reads the 2026-10-21 partition of enriched/order_guides_rules. A later partition reads the partition of the same date. The guides cover MY2026 and MY2027 only, so a MY2025 vehicle gets no tire.

Limits​

  • The guides' availability lists can be narrower than the NetSTAR configurator. On the 2027 GLC, PAV is listed for the GLC300W only and is offered on every GLC model. NetSTAR is the primary source for which models offer a feature.
  • The guides' prices are unreliable. The 2027 GLB guide prints $0 for options that NetSTAR prices. NetSTAR is the primary source for MSRP.
  • A note that pairs codes with models, Only with 641 (GLC43) and 611 (GLC63), is read as one rule for both models.
  • A clause with a condition, such as Required w/ Nappa Interior if DG3 also selected, produces no rule.

Fixtures​

projects/ai_mercedes/tests/data/order_guides/fixtures/ holds the captured guide pages the tests read.