Skip to main content
ExLibris
  • Subscribe by RSS
  • Ex Libris Knowledge Center

    Configuring Normalization Rules for Display and Local Fields

    Return to menu

    Normalization rules provide the building blocks for making enhancements to MARC 21 records. Primo VE allows you to create additional normalization rules to alter the presentation of out-of-the-box display fields and local display fields. The normalization rules are applied immediately to the records for discovery. For information on how to create display and local fields, see Configuring Local Display and Search Fields for Primo VE.

    This section describes the syntax used to create the normalization rules, which are defined with Drools tools.

    Drools Terms

    The following terms are used in the syntax of the normalization rules:

    • num – numeric value

    • sort – sorting

    • sub – subfield

    • $ – A valid regular expression symbol that indicates the end.

    Normalization Rule Syntax

    Rule files contain one or more rules, which contain a condition and one or more actions to be applied to records. Actions are applied to a record if the record meets the condition. Each action within a rule can be performed on a single field within a record. Actions are performed in the order in which they appear within the rule.

    When defining a rule that contains multiple rules, you must use the priority (or salience) factor. Actions stipulated in the rule with the higher priority are performed first. For example, the action in a rule with priority 2 is performed before the action in a rule with priority 1.

    Priority (or salience) is only necessary when the fields in the rules are the same. Otherwise, when the rules in a file deal with different fields, multiple rules are performed from top to bottom.

    When

    (<conditions on MARC record>) then

    Action1

    Action2

    Action3

    ...

    End

    <conditions on MARC record> contains one or more Boolean clauses that apply to the record. If <conditions on MARC record> returns TRUE, the rule is applied to the record; otherwise, the rule is not applied and the record is not processed.
    • “When” must be the only word in the first line. The condition must be placed on a separate line.

    • While it is permissible to include multiple Boolean Operators in the rules, when a large number of Boolean operators are selected, slower performance is likely to result. Thus each rule should include no more than 200 Boolean operators.

    Conditions

    Conditions are defined at the entire rule level (WHEN) for Primo VE display and local field. The WHEN clause is a condition that must be met by the entire record in order to determine whether the rule is applied to the record. The following Boolean operators are used between conditions to specify multiple conditions:

    • AND – The next condition must be true.

    • OR – The next condition may or may not be true.

    • AND NOT – The next condition must not be true.

    The following table describes the syntax for the possible MARC21 conditions:

    MARC21 Conditions
    Condition Example

    is – Applies the actions when a specific field/subfield exists. Valid formats:

    • MARC is "<field>"
    • MARC is "<field>"."<subfield>"
    • MARC.control is "<control number>"

    # The MARC 880 field exists.

    MARC is "880"

    # The MARC 260 field has subfield c.

    MARC is "260"."c"

    # The MARC.control field is 001.

    MARC.control is "001"

    match – Applies the actions when the contents of the specified subfield matches a specified regular expression. Format:

    MARC."<field>"."<subfield>" match "<regular expression>"

    # The 880 field with subfield ‘6’ matches the expression ‘505-.*’

    MARC."880"."6" match "505-.*"

    The .* portion of the expression means that it accepts anything after the string.

    has any – Applies the actions when a specific field exists and has any of the specified subfields. Format:

    MARC."<field>" has any "<subfield list>"

    # The 700 field has one or more of the following subfields: a, b, c, d, e, j, q, and u.

    MARC."700" has any "a,b,c,d,e,j,q,u"

    equals – Applies the actions when the entire contents of the specified subfield matches. Format:

    MARC."<field>".ind"<indicator>" equals "<value>"

    # The MARC 260 field's first indicator is 3.

    MARC."260".ind"1"  equals "3"

     

    Actions

    You can apply actions to single fields in a record based on conditions specified in the rule. If all of the conditions are met, the actions are applied to the record in the order in which they are listed.

    If you need to use a MARC field in the Actions section, you must also check for its existence in the Conditions section. For example:

    rule "Primo VE - Language 041 a"

          when

             MARC is "041"."a"

          then

             set TEMP"2" to MARC."041"."a"

    The following table describes the syntax for the possible MARC21 actions.

    MARC21 Actions
    Action Examples

    set – This action changes the contents of an existing field. If a field does not exist, the field is created. Format:

    set <field> to <field>

    set pnx."display"."contents" to TEMP"1"

    set TEMP"1" to pnx."display"."contents"

    create – This action creates a PNX display field and sets its contents to the value of a specified field. If a display field already exists, an additional field is added. Format:

    create <PNX field> with <field>

    create pnx."display"."contents" with MARC "505"

    excluding num subfields without sort – This action uses only the non-numeric subfields and puts them in the order they appear in the MARC record. Format:

    excluding num subfields without sort

    create pnx."display"."contents" with MARC "505" excluding num subfields without sort

    sub without sort – This action uses either all subfields or only the specified subfields and puts them in the order they appear in the MARC record. Format:

    sub without sort ["<subfield list>"]

    set TEMP"1" to MARC."710" sub without sort "a,b,c,d,e"

    set TEMP"1" to MARC."710" sub without sort

    remove substring using regex – This action removes a substring from the contents of a temporary field using a specified regular expression. Format:

    remove substring using regexp (TEMP"<index>",<regular expression>)

    remove substring using regex (TEMP"1","(/|:|;|=|,)+$")

    concatenate with delimiter – This action concatenates the contents of two temporary fields and separates them with a delimiter. The result is placed in the first temporary field. Format:

    concatenate with delimiter (TEMP"<index>",TEMP"<index>","<delimiter>")

    concatenate with delimiter (TEMP"1",TEMP"2","")

    add prefix – This action adds the specified value to the beginning of the temporary field. Format:

    add prefix (TEMP"<index>","<value>")

    add prefix (TEMP"2","$$Q")

    replace string by string – This action replaces all occurrences of a regular expression with a specified value. Format:

    replace string by string (TEMP"<index>","<regular expression>","<value>")

    replace string by string (TEMP"1","[^0-9]","\\?")

    return list using regex – This action searches for all occurrences of a regular expression in the second temporary field and copies them as a list to the first temporary field. Format:

    return list using regex (TEMP"<index>",TEMP"<index>","<regular expression>")

    return list using regex (TEMP"1",TEMP"2","[a-z]{3}")

    remove string – This action removes a specified string from a temporary field. Format:

    remove string (TEMP"<index>","<value>")

    remove string (TEMP"1","<<")

    remove leading and trailing spaces – This action removes beginning and trailing spaces in a temporary field. Format:

    remove leading and trailing spaces (TEMP"<index>")

    remove leading and trailing spaces (TEMP"1")

    replace spaces – This action replaces all spaces in a temporary field with a specified character or string. Format

    replace spaces (TEMP"<index>","<value>")

    replace spaces (TEMP"1"," ")

    lower case – This action changes all letters in a temporary field to lowercase. Format:

    lower case (TEMP"<index>")

    lower case (TEMP"1")

    delimited by – This action places a delimiter between the specified subfields. Format:

    delimited by "<string>"

    set TEMP"2" to MARC."600" subfields "x-z" delimited by " -- "

     

    Java Routines

    The following table lists additional Java routines that are typically added as actions to perform a series of actions with a single command.

    Java Routines
    Routine Description

    normalize discovery lang

    Check to see that the language is valid. If it is less than three letters or not defined in language list, it will be set to ‘und’ - undefined.

    kormarc remove nonfiling brackets MARC."{tag}" sourcetag "{fieldTag}" from TEMP"{i}"

    Relevant only for KORMARC formats.

    Check the "{fieldTag}",  if it equals to 630|740 and the MARC."{tag}" has first indicator 1,

    OR

    the "{fieldTag}" is equals to 130|222|240|242|243|245|440|490|730|830 and MARC."{tag}" has second indicator 1

    Then

    remove from TEMP"{i}" the surrounding round brackets if exist.

    Date1

    Position 7-11 in the MARC 008 field.

    Date2

    Position 11-15 in the MARC 008 field.

    Language

    Position 35-37 in the MARC 008 field.

    prima display title

    This action retrieves the title from the MARC record:

    1) Check to see if the LDR field exists in the MARC.

    2) if yes, check to see if there is an ‘a’ in position 6 and an e|i|s in position 7.

    3) if those are true, then the records is a journal and the title is taken from field 130 subfields a,d,f,k,l,m,n,o,p,r,s.

    4) If there is no LDR field, check the title in field 245 subfields a,b,f,g,k,n,p,s.

    MARCRECORD

    This condition is used in conjunction with the prima display title routine to check for the existence of necessary MARC title fields.

    Normalization Rule Example

    Example 1:

    The following rule creates a hypertext link from the URL stored in the MARC 505 field and displays it in the Contents display field:

    rule "Primo VE - Contents 505"

          when

             MARC."505" has any "u,y"

          then

             set TEMP"1" to MARC."505" subfields "u"

             set TEMP"2" to MARC."505" subfields "y"

             add suffix  (TEMP"2","</a>")

             add prefix (TEMP"1","<a target=\"_blank\" href=\"")

             add suffix  (TEMP"1","\">")

             concatenate with delimiter (TEMP"1",TEMP"2","")

             set pnx."display"."contents" to TEMP"1"

    end

     
    MARC 505 Rule - Create Link for Content Display Field

    MARC Source:

    505    $$u http://www.google.com $$y Google

    Primo VE Output:

    GoogleLink.png


    Example 2:

    When a MARC 880 $$6 subfield contains the string 520-<any_value>, the following rule will display the contents of all non-numeric subfields in the Description display field without sorting them:

    rule "Primo VE - Description 880"

          when

             MARC is "880" AND

             MARC."880"."6" match "520-.*"

          then

             create pnx."display"."description" with MARC."880" excluding num subfields without sort

    end

     
    MARC 880 Rule - Create Description Display Field

    Example 3:

    When a MARC 600 field contains any of the subfields a-u, w-z and its second indicator is not 2, the rule below will display the concatenation of the following strings separated by " -- " in the Subject display field:

    • A string that has no period at the end and contains the values from subfields a-u, and w (which are separated by a space).

    • A string that has no period at the end and contains the values from subfields x-z (which are separated by " -- ").

    rule "Primo VE - Subject 600"

          when

             MARC."600" has any "a-u,w-z" AND NOT

             MARC."600".ind"2"  equals "2"

          then

             set TEMP"1" to MARC."600" subfields "a-u,w" delimited by " " remove substring using regex "\\.+$"

             set TEMP"2" to MARC."600" subfields "x-z" delimited by " -- " remove substring using regex "\\.+$"

             concatenate with delimiter (TEMP"1",TEMP"2"," -- ")

             create pnx."display"."subject" with TEMP"1"

    end

     
    MARC 600 Rule - Create Subject Display Field

    Example 4:

    When a MARC 041 $$a exists, the following actions from the rule below are applied to the field to create the Language display field:

    1. The contents of MARC 041 $a is copied to Temp2, and all letters are converted to lowercase.

    2. All three-letter language codes in Temp2 are stored as a list in Temp1.

    3. If the language codes stored in Temp1 are valid, the Language display field is created.

    rule "Primo VE - Language 041 a"

          when

             MARC is "041"."a"

          then

             set TEMP"2" to MARC."041"."a"

             lower case (TEMP"2")

             return list using regex (TEMP"1",TEMP"2","[a-z]{3}")

             normalize discovery lang (TEMP"1")

             create pnx."display"."language" with list TEMP"1"

    end

     
    MARC 041 a Rule - Create Language Display Field

    Example 5:

    The following example shows how to check the LDR field in normalization rules.

    rule "Primo VE - LDR check"

          when

             MARC is "130" AND

             MARC is "245" AND

             MARC."130"."a" match "English.*" AND

             MARC.control."LDR"(6-8) match "ab|ai|as "

     

          then

             ...

             ...

    end

     
    Use LDR in Normalization Rules

    Example 6:

    When a MARC 583 $$a subfield contains any value, the following rule will store the contents of the subfield in the lds02 local display field:

    rule "Primo VE - Lds02"

          when

             MARC is "583"."a"

          then

             create pnx."display"."lds02" with MARC."583"."a"

    end

     
    MARC 583 Rule - Create Lds02 Display Field

    Example 7:

    The following rule creates local field Lsr01 with values from MARC 300 a,b subfields (Physical Description; $a-Extent, $b – Other physical details):

     

    rule "Primo VE Marc - Lsr01"

     

          when

     

             MARC.”300” has any "a,b"

     

          then

     

             create pnx."search"."lsr01" with MARC "300" subfields "a,b"

     

    end

     

     
    MARC 300 Rule - Create Local Search and Facet Field

    Example 8:

    The following rule creates local field Lsr14 with the values from MARC 700 a subfield (Added Entry-Personal Name; $a- Personal name):

    rule "Primo VE Marc - Lsr14"

     

          when

     

             MARC is "700"."a"

     

          then

     

             create pnx."search"."lsr14" with MARC "700"."a"

     

    end
     
    MARC 700 Rule - Create Local Search and Facet Field

    MARC Source:

    700    1#$aMelville, Gert, $eeditor.

    700    1#$aRuta, Carlos, $eeditor.

    700    1#$aCarugati, Laura S, $eeditor.

    Primo VE Output:

    PVE_LocalSearchFieldExampleOutput.png

     

    • Was this article helpful?