User:Inductiveload/BnF ARK format

The Bibliothèque Nationale de France (BnF) uses the Archival Resource Key scheme for its authority control data. The URL looks like this: http://catalogue.bnf.fr/ark:/12148/cb119016075

It is made up of several parts:
 * http://catalogue.bnf.fr/ the Name Mapping Authority Host (NMAH)
 * ark:/ - this is an ARK record
 * 12148/ - Name Assigning Authority Number (NAAN) for the BnF. All BnF records will have this number.
 * cb119016075 - Name of the record. These always start with "cb", followed by 8 digits and then an alphanumeric check character.

VIAF presents only part of the name through the API: the unique part of the identifier. In the above example, this is 11901607. The rest of the ARK can be inferred from this, by prepending "http://catalogue.bnf.fr/ark:/12148/cb" and appending the check character.

You must derive the check character before you can construct a link directly to BnF, though you link to VIAF with just the 8 digits: http://viaf.org/processed/BNF|11901607

Deriving the check character
The check character is generated using the Nice Opaque Identifier (NOID) tool. It uses the set of xdigits "0123456789bcdfghjkmnpqrstvwxz" (in that order), which gives a radix of 29. This is the same as the example in the link. The "value" of a character is the index in this set ("0" is 0, "9" is 9, "b" is 10, "z" is 29). Any character not in the set has a value of 0.

The string fed into the algorithm is "cb" + "8-digit number", giving 10 characters.

Then, for every character, a position value is calculated: it is the multiplicative product of the position of the character in the string (starting from 1, so 'c' is 1, 'b' is 2...) and the value of the character's xdigit.

The sum of all the position values, modulo the radix (29) gives the check character's xdigit value.

Example
Take the number 11901607. The string to feed to the algorithm is "cb11901607".

Char: c  Pos:   1  -->  11 x  1  =  11 Char: b  Pos:   2  -->  10 x  2  =  20 Char: 1  Pos:   3  -->   1 x  3  =   3 Char: 1  Pos:   4  -->   1 x  4  =   4 Char: 9  Pos:   5  -->   9 x  5  =  45 Char: 0  Pos:   6  -->   0 x  6  =   0 Char: 1  Pos:   7  -->   1 x  7  =   7 Char: 6  Pos:   8  -->   6 x  8  =  48 Char: 0  Pos:   9  -->   0 x  9  =   0 Char: 7  Pos:  10  -->   7 x 10  =  70 +                          TOTAL = 208

208 mod 29 is 5, so the check digit is also "5". The full ARK is then http://catalogue.bnf.fr/ark:/12148/cb119016075

Example 2
Using "11900002"

Char: c  Pos:   1  -->  11  x   1  =  11 Char: b  Pos:   2  -->  10  x   2  =  20 Char: 1  Pos:   3  -->   1  x   3  =   3 Char: 1  Pos:   4  -->   1  x   4  =   4 Char: 9  Pos:   5  -->   9  x   5  =  45 Char: 0  Pos:   6  -->   0  x   6  =   0 Char: 0  Pos:   7  -->   0  x   7  =   0 Char: 0  Pos:   8  -->   0  x   8  =   0 Char: 0  Pos:   9  -->   0  x   9  =   0 Char: 2  Pos:  10  -->   2  x  10  =  20 +                                     103

103 mod 29 is 16, so the check character is "j". The full ARK is then http://catalogue.bnf.fr/ark:/12148/cb11900002j