Documentation

MarcGrok
in package

Class MarcGrok.

Wraps a MARC Record and provide methods to extract and interpret the data.

Tags
see
http://marcspec.github.io/MARCspec/marc-spec.html

Table of Contents

$record  : Record
The MARC record being wrapped.
$container  : array<string|int, mixed>
The container (parent record) info.
$meetings  : array<string|int, mixed>
All meetings.
$names  : array<string|int, mixed>
All names, excluding meetings, series names.
$publication  : array<string|int, mixed>
The publication info (publisher, date, etc.)
$seriesNames  : array<string|int, mixed>
All series names.
__construct()  : mixed
MarcGrok constructor.
getAllMeetings()  : array<string|int, mixed>
Get all meetings.
getAllNames()  : array<string|int, mixed>
Get all personal, corporate and uncontrolled names.
getAllPublicationInfo()  : array<string|int, mixed>
Get all info about publishers, etc.
getAllSeriesNames()  : array<string|int, mixed>
Get all series names.
getContainerInfo()  : array<string|int, mixed>
Get all container (parent record) info.
getRecord()  : Record
Get the wrapped MARC record.
extractNames()  : array<string|int, mixed>
Extract names from an X00 or X10 field.
getAllMeetingsNotMemoized()  : array<string|int, mixed>
Get all meetings.
getAllNamesNotMemoized()  : array<string|int, mixed>
Get all personal, corporate and uncontrolled names.
getAllPublicationInfoNotMemoized()  : array<string|int, mixed>
Get all info about publishers, etc.
getAllSeriesNamesNotMemoized()  : array<string|int, mixed>
Get all series names.
getContainerInfoNotMemoized()  : array<string|int, mixed>
Get all container (parent record) info.

Properties

$record

The MARC record being wrapped.

protected Record $record

$container

The container (parent record) info.

private array<string|int, mixed> $container = NULL

$meetings

All meetings.

private array<string|int, mixed> $meetings = NULL

$names

All names, excluding meetings, series names.

private array<string|int, mixed> $names = NULL

$publication

The publication info (publisher, date, etc.)

private array<string|int, mixed> $publication = NULL

$seriesNames

All series names.

private array<string|int, mixed> $seriesNames = NULL

Methods

__construct()

MarcGrok constructor.

public __construct(Record $record) : mixed
Parameters
$record : Record

The MARC record to wrap.

Return values
mixed

getAllMeetings()

Get all meetings.

public getAllMeetings() : array<string|int, mixed>

Memoized. See getAllMeetingsNotMemoized for details.

Tags
see
MarcGrok::getAllMeetingsNotMemoized()
Return values
array<string|int, mixed>

An array of arrays containing CSL name variables, keyed by relator code.

getAllNames()

Get all personal, corporate and uncontrolled names.

public getAllNames() : array<string|int, mixed>

Memoized. See getAllNamesNotMemoized for details.

Tags
see
MarcGrok::getAllNamesNotMemoized()
Return values
array<string|int, mixed>

An array of arrays containing CSL name variables, keyed by relator code.

getAllPublicationInfo()

Get all info about publishers, etc.

public getAllPublicationInfo() : array<string|int, mixed>

Memoized. See getAllPublicationInfoNotMemoized for details.

Tags
see
MarcGrok::getAllPublicationInfoNotMemoized
Return values
array<string|int, mixed>

Associative array of publication info.

getAllSeriesNames()

Get all series names.

public getAllSeriesNames() : array<string|int, mixed>

Memoized. See getAllSeriesNamesNotMemoized for details.

Tags
see
MarcGrok::getAllSeriesNamesNotMemoized()
Return values
array<string|int, mixed>

An array of arrays containing CSL name variables, keyed by relator code.

getContainerInfo()

Get all container (parent record) info.

public getContainerInfo() : array<string|int, mixed>

Memoized. See getContainerInfoNotMemoized for more info.

Tags
see
MarcGrok::getContainerInfoNotMemoized()
Return values
array<string|int, mixed>

Associative array of container info.

getRecord()

Get the wrapped MARC record.

public getRecord() : Record
Return values
Record

The MARC record.

extractNames()

Extract names from an X00 or X10 field.

protected extractNames(string $tag) : array<string|int, mixed>

MARC: Any tag containing personal names (X00) or corporate names (X10).

  • X00 - Personal Names-General Information
    • $a - Personal name (NR)
    • $c - Titles and words associated with a name (R)
    • $e - Relator term (R)
  • X10 - Corporate Names-General Information
    • $a - Corporate name or jurisdiction name as entry element (NR)
    • $c - Location of meeting (R)
    • $e - Relator term (R)
Parameters
$tag : string

The tag of the field from which to extract the names.

Tags
see
https://www.loc.gov/marc/bibliographic/bdx00.html
see
https://www.loc.gov/marc/bibliographic/bdx10.html
see
https://www.loc.gov/marc/relators/relaterm.html
see
https://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html#name-fields
Return values
array<string|int, mixed>

An array of arrays, each serializable to CSL-JSON name variables.

getAllMeetingsNotMemoized()

Get all meetings.

private getAllMeetingsNotMemoized() : array<string|int, mixed>

Excludes:

  • meetings in 611, because they are the subjects of the work, rather than contributors.

Not memoized.

Tags
see
https://www.loc.gov/marc/bibliographic/bdx11.html
Return values
array<string|int, mixed>

An array of meetings. Each meeting can have the following keys:

  • name: string
  • locations: array of strings
  • dates: array of strings

getAllNamesNotMemoized()

Get all personal, corporate and uncontrolled names.

private getAllNamesNotMemoized() : array<string|int, mixed>

Excludes:

  • meeting names
  • series names
  • names in 600 and 610, because they are the subjects of the work, rather than contributors.

Not memoized.

Tags
see
https://www.loc.gov/marc/bibliographic/bdx00.html
see
https://www.loc.gov/marc/bibliographic/bdx10.html
see
https://www.loc.gov/marc/bibliographic/bd720.html
see
https://www.loc.gov/marc/relators/relaterm.html
Return values
array<string|int, mixed>

An array of arrays containing CSL name variables, keyed by relator code.

getAllPublicationInfoNotMemoized()

Get all info about publishers, etc.

private getAllPublicationInfoNotMemoized() : array<string|int, mixed>

Not memoized.

MARC:

  • 260 - Publication, Distribution, etc. (Imprint) (R)
    • $a - Place of publication, distribution, etc. (R)
    • $b - Name of publisher, distributor, etc. (R)
    • $c - Date of publication, distribution, etc. (R)
    • $e - Place of manufacture (R)
    • $f - Manufacturer (R)
    • $g - Date of manufacture (R)
  • 264 - Production, Publication, Distribution, Manufacture, and Copyright Notice (R)
    • $a - Place of production, publication, distribution, manufacture
    • $b - Name of producer, publisher, distributor, manufacturer (R)
    • $c - Date of production, publication, distribution, manufacture, or copyright notice (R)

Results are grouped by the named entity's function (e.g. publisher, producer, etc.). Each group is sorted, first by the first indicator, then by date, so that the current/latest entity is listed first,

To keep things simple, we support the repeated fields, but not repeated subfields here. We simply use the first subfield if available.

Tags
see
https://www.loc.gov/marc/bibliographic/bd260.html
see
https://www.loc.gov/marc/bibliographic/bd264.html
Return values
array<string|int, mixed>

Associative array of publication info.

getContainerInfoNotMemoized()

Get all container (parent record) info.

private getContainerInfoNotMemoized() : array<string|int, mixed>

Not memoized.

MARC: 773 - Host Item Entry (R)

  • $t - Title (NR) -> title
  • $p - Abbreviated title (NR) -> title_short
  • $g - Related parts (R) -> pages, number, volume, part, date
  • $q - Enumeration and first page (NR) -> first page, number, volume, part
  • $b - Edition (NR) -> edition
  • $a - Main entry heading (NR) -> authors

Subfield $q is considered before subfield $g for number, volume and part, because it uses a fixed format which can be reliably parsed. However, if a range of pages needs to be specified, we have to get it is from $g, since $q only contains the first page in the range.

Tags
see
https://www.loc.gov/marc/bibliographic/bd773.html
Return values
array<string|int, mixed>

Associative array of container info.

Search results