Skip to content

BIC

Canonicalizes one BIC mention per call — an 8- or 11-character Business Identifier Code in compact or SWIFT grouped display (with an optional BIC/SWIFT label) — to compact uppercase form.

In plain language: give it deutdeff, BIC: DEUTDEFF500, DEUT DE FF, or BNPA FR PP XXX and it hands back DEUTDEFF, DEUTDEFF500, or BNPAFRPPXXX when the shape is a real BIC structure per ISO 9362:2022 §5 with a known country code. The spec defines no checksum, so validation is structural (length 8 or 11, per-position charset, ISO 3166-1 country lookup plus XK); the location-code second character and the XXX head-office branch are informative and never rejected.


What it recognizes — and what it does not

Section titled “What it recognizes — and what it does not”
RecognizesDoes not recognize
Compact BIC-8 (DEUTDEFF, lowercase folds up) and BIC-11 (DEUTDEFF500, BNPAFRPPXXX)Wrong lengths (DEUTDEF 7, DEUTDEFF5 9, DEUTDEFF50 10, DEUTDEFF5000 12) → MISSING
SWIFT grouped display, single spaces only (DEUT DE FF, DEUT DE FF 500, BNPA FR PP XXX)Double-spaced display (DEUT DE FF) → MISSING
Fused BIC/SWIFT label with separator (BIC: DEUTDEFF, SWIFT: BNPAFRPPXXX, bic - NEDSZAJJ)Glued label (BICDEUTDEFF, SWIFTDEUTDEFF500, no separator) → MISSING
Kosovo XK user-assigned code (BANKXK22, CBKIXKPRXXX)Unknown country (DEUTXXFF, BNPAQQPP) → recognized, then INVALID
Bank codes with digits (DE1TDEFF, 4!c since 2014)Digit in the country position (DEUT1EFF, 2!a must be A–Z) → MISSING
Glued surroundings (XDEUTDEFF, DEUTDEFFY) → MISSING
Lowercase English trigrams at end of text (call me at, call me at., call me at noon) → MISSING

Default output_format is "bic" (identity — normalize() returns compact uppercase).

output_formatRendersExample
(default) bic / None / "default"Compact uppercase, branch as matchedDEUTDEFF, DEUTDEFF500
groupedSWIFT paper form, single spaces between the 4-2-2-3 groups (encoding)DEUT DE FF from DEUTDEFF, DEUT DE FF 500 from DEUTDEFF500
bic11Always 11 chars: BIC-8 gains XXX head office (lossy expansion); BIC-11 is identityDEUTDEFFXXX from DEUTDEFF

Any other value raises ContractError — including compact, paper, and hyphenated, which belong to other capabilities’ vocabularies, not BIC’s.

from paxman.capabilities import BIC
import paxman
paxman.register_all_shipped()
print(paxman.canonicalize("deutdeff", BIC.create_contract()).canonicalized_value)
print(paxman.canonicalize("BIC: DEUTDEFF500", BIC.create_contract()).canonicalized_value)
print(paxman.canonicalize("DEUT DE FF", BIC.create_contract()).canonicalized_value)
print(paxman.canonicalize("DEUTDEFF", BIC.create_contract(output_format="grouped")).canonicalized_value)
print(paxman.canonicalize("DEUTDEFF", BIC.create_contract(output_format="bic11")).canonicalized_value)

contract = BIC.create_contract(
output_format=None, # "bic" (default), "grouped", "bic11"
# plus every common field: suppress_common_words / excluded_rules / pinned_rules / year / extra_grammars
)
  • No grammar toggles: one grammar (bic_recognition), one rule (Section 5-bic-structure-country).
  • year filters by publication_year; e.g., year=2021 drops the ISO 9362:2022 rule → DEUTDEFF becomes INVALID.

InputContractStatusValue / why
DEUTDEFFdefaultsSUCCESS"DEUTDEFF"
deutdeffdefaultsSUCCESS"DEUTDEFF" (case folds up)
BIC: DEUTDEFFdefaultsSUCCESS"DEUTDEFF" (label recognized, span covers BIC DEUTDEFF)
DEUT DE FFdefaultsSUCCESS"DEUTDEFF" (grouped recognized)
BNPA FR PP XXXdefaultsSUCCESS"BNPAFRPPXXX" (grouped 11 recognized)
DEUTDEFFoutput_format="grouped"SUCCESS"DEUT DE FF"
DEUTDEFFoutput_format="bic11"SUCCESS"DEUTDEFFXXX" (lossy XXX expansion)
DEUTXXFFanyINVALIDrecognized shape, unknown country code
DEUTDEFFyear=2021INVALIDrule is 2022, dropped
DEUTDEFF5anyMISSING9 chars, no shape matches
DEUT1EFFanyMISSINGdigit in country position, grammar charset blocks
BICDEUTDEFFanyMISSINGglued label needs a separator
XDEUTDEFFanyMISSINGword guard blocks left glue
DEUT DE FFanyMISSINGdouble spaces not allowed in grouped display
call me at noonanyMISSINGEnglish-phrase filter, not a BIC
DEUTDEFF / BNPAFRPPanyraises MultipleMentionsErrortwo distinct BICs
DEUTDEFFoutput_format="compact"raises ContractErrorformat not offered

A single grammar plus a single deterministic rule yields at most one value, so AMBIGUOUS is unreachable for this capability. Two distinct BICs raise MultipleMentionsError; two identical mentions coalesce to one SUCCESS.


Notebook snippet — normalize a mixed column

Section titled “Notebook snippet — normalize a mixed column”
import paxman
from paxman.capabilities import BIC
from paxman.core.domain import Resolution
from paxman.core.errors import ContractError
paxman.register_all_shipped()
contract = BIC.create_contract()
rows = [
"DEUTDEFF",
"deutdeff",
"DEUTDEFF500",
"BIC: DEUTDEFF",
"SWIFT: BNPAFRPPXXX",
"DEUT DE FF",
"DEUT DE FF 500",
"BNPA FR PP XXX",
"BANKXK22",
"DEUTXXFF",
"DEUT1EFF",
"DEUTDEFF5",
"BICDEUTDEFF",
"call me at noon",
]
for text in rows:
r = paxman.canonicalize(text, contract)
val = r.canonicalized_value if r.status == Resolution.SUCCESS else "—"
rule = r.candidates[0].validation_rule if r.candidates else "—"
print(f"{text!r:24} → {r.status.value:10} {val!r:16} ({rule})")
try:
BIC.create_contract(output_format="compact")
except ContractError as e:
print(f"compact → ContractError: {e}")

  • ISO 9362:2022 §5 BIC structure plus country lookup (length 8 or 11, per-position charset, ISO 3166-1 country plus XK; no checksum) — Section 5-bic-structure-country

Each candidate’s validation_rule carries the section, and candidate.provenance[0].publication_year the year.

See also: Execution Result, Provenance, Segmentation.