User:Inductiveload/BnF ARK format

From Wikisource
Jump to navigation Jump to search

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%7C11901607

Deriving the check character

[edit]

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

[edit]

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

[edit]

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

Javascript snippet

[edit]
function generate_bnf_ark_from_8digits(orig_id){
    var bnf_xdigits = '0123456789bcdfghjkmnpqrstvwxz';
    var bnf_check_digit = 0;
    
    var id = 'cb' + orig_id;
    for (var i=0; i<id.length; i++){
        bnf_check_digit += bnf_xdigits.indexOf(id[i]) * (i+1);
    }
    return id + bnf_xdigits[bnf_check_digit % bnf_xdigits.length]; //29 is the radix
}