@natlibfi/melinda-record-matching 4.4.0-alpha.1 → 5.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/melinda-node-tests.yml +13 -9
- package/LICENSE.txt +21 -165
- package/README.md +2 -2
- package/dist/candidate-search/candidate-search-utils.js +6 -43
- package/dist/candidate-search/candidate-search-utils.js.map +7 -1
- package/dist/candidate-search/choose-queries.js +75 -0
- package/dist/candidate-search/choose-queries.js.map +7 -0
- package/dist/candidate-search/index.js +89 -225
- package/dist/candidate-search/index.js.map +7 -1
- package/dist/candidate-search/index.test.js +92 -0
- package/dist/candidate-search/index.test.js.map +7 -0
- package/dist/candidate-search/query-list/bib.js +141 -320
- package/dist/candidate-search/query-list/bib.js.map +7 -1
- package/dist/candidate-search/query-list/bib.test.js +34 -0
- package/dist/candidate-search/query-list/bib.test.js.map +7 -0
- package/dist/candidate-search/query-list/component.js +87 -0
- package/dist/candidate-search/query-list/component.js.map +7 -0
- package/dist/candidate-search/query-list/index.js +39 -52
- package/dist/candidate-search/query-list/index.js.map +7 -1
- package/dist/cli.js +138 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.js +87 -462
- package/dist/index.js.map +7 -1
- package/dist/index.test.js +69 -0
- package/dist/index.test.js.map +7 -0
- package/dist/match-detection/features/bib/all-source-ids.js +20 -91
- package/dist/match-detection/features/bib/all-source-ids.js.map +7 -1
- package/dist/match-detection/features/bib/authors.js +20 -76
- package/dist/match-detection/features/bib/authors.js.map +7 -1
- package/dist/match-detection/features/bib/bibliographic-level.js +4 -40
- package/dist/match-detection/features/bib/bibliographic-level.js.map +7 -1
- package/dist/match-detection/features/bib/host-component.js +5 -41
- package/dist/match-detection/features/bib/host-component.js.map +7 -1
- package/dist/match-detection/features/bib/index.js +17 -119
- package/dist/match-detection/features/bib/index.js.map +7 -1
- package/dist/match-detection/features/bib/index.test.js +40 -0
- package/dist/match-detection/features/bib/index.test.js.map +7 -0
- package/dist/match-detection/features/bib/isbn.js +13 -69
- package/dist/match-detection/features/bib/isbn.js.map +7 -1
- package/dist/match-detection/features/bib/issn.js +5 -50
- package/dist/match-detection/features/bib/issn.js.map +7 -1
- package/dist/match-detection/features/bib/language.js +25 -86
- package/dist/match-detection/features/bib/language.js.map +7 -1
- package/dist/match-detection/features/bib/media-type.js +12 -64
- package/dist/match-detection/features/bib/media-type.js.map +7 -1
- package/dist/match-detection/features/bib/melinda-id.js +5 -47
- package/dist/match-detection/features/bib/melinda-id.js.map +7 -1
- package/dist/match-detection/features/bib/melinda-identifier-factory.js +16 -67
- package/dist/match-detection/features/bib/melinda-identifier-factory.js.map +7 -1
- package/dist/match-detection/features/bib/other-standard-identifier.js +5 -51
- package/dist/match-detection/features/bib/other-standard-identifier.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js +49 -189
- package/dist/match-detection/features/bib/publication-time-allow-cons-years-multi.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js +10 -53
- package/dist/match-detection/features/bib/publication-time-allow-cons-years.js.map +7 -1
- package/dist/match-detection/features/bib/publication-time.js +8 -46
- package/dist/match-detection/features/bib/publication-time.js.map +7 -1
- package/dist/match-detection/features/bib/record-type.js +4 -43
- package/dist/match-detection/features/bib/record-type.js.map +7 -1
- package/dist/match-detection/features/bib/standard-identifier-factory.js +47 -163
- package/dist/match-detection/features/bib/standard-identifier-factory.js.map +7 -1
- package/dist/match-detection/features/bib/title-version-original.js +11 -53
- package/dist/match-detection/features/bib/title-version-original.js.map +7 -1
- package/dist/match-detection/features/bib/title.js +20 -72
- package/dist/match-detection/features/bib/title.js.map +7 -1
- package/dist/match-detection/features/index.js +3 -11
- package/dist/match-detection/features/index.js.map +7 -1
- package/dist/match-detection/index.js +35 -150
- package/dist/match-detection/index.js.map +7 -1
- package/dist/match-detection/index.test.js +44 -0
- package/dist/match-detection/index.test.js.map +7 -0
- package/dist/matching-utils.js +38 -102
- package/dist/matching-utils.js.map +7 -1
- package/eslint.config.js +52 -0
- package/example.env +4 -0
- package/package.json +29 -78
- package/src/candidate-search/candidate-search-utils.js +1 -28
- package/src/candidate-search/choose-queries.js +93 -0
- package/src/candidate-search/index.js +85 -119
- package/src/candidate-search/{index.spec.js → index.test.js} +30 -43
- package/src/candidate-search/query-list/bib.js +54 -55
- package/src/candidate-search/query-list/bib.test.js +38 -0
- package/src/candidate-search/query-list/component.js +127 -0
- package/src/candidate-search/query-list/index.js +31 -35
- package/src/cli.js +177 -0
- package/src/index.js +27 -68
- package/src/{index.spec.js → index.test.js} +11 -42
- package/src/match-detection/features/bib/all-source-ids.js +2 -29
- package/src/match-detection/features/bib/authors.js +5 -30
- package/src/match-detection/features/bib/bibliographic-level.js +0 -27
- package/src/match-detection/features/bib/host-component.js +0 -27
- package/src/match-detection/features/bib/index.js +16 -43
- package/src/match-detection/features/bib/index.test.js +52 -0
- package/src/match-detection/features/bib/isbn.js +2 -29
- package/src/match-detection/features/bib/issn.js +1 -28
- package/src/match-detection/features/bib/language.js +5 -32
- package/src/match-detection/features/bib/media-type.js +2 -28
- package/src/match-detection/features/bib/melinda-id.js +1 -28
- package/src/match-detection/features/bib/melinda-identifier-factory.js +5 -32
- package/src/match-detection/features/bib/other-standard-identifier.js +1 -28
- package/src/match-detection/features/bib/publication-time-allow-cons-years-multi.js +7 -34
- package/src/match-detection/features/bib/publication-time-allow-cons-years.js +1 -28
- package/src/match-detection/features/bib/publication-time.js +2 -28
- package/src/match-detection/features/bib/record-type.js +0 -27
- package/src/match-detection/features/bib/standard-identifier-factory.js +1 -28
- package/src/match-detection/features/bib/title-version-original.js +2 -28
- package/src/match-detection/features/bib/title.js +6 -34
- package/src/match-detection/features/index.js +1 -28
- package/src/match-detection/index.js +1 -28
- package/src/match-detection/{index.spec.js → index.test.js} +9 -35
- package/src/matching-utils.js +8 -37
- package/dist/candidate-search/index.spec.js +0 -144
- package/dist/candidate-search/index.spec.js.map +0 -1
- package/dist/candidate-search/query-list/bib.spec.js +0 -64
- package/dist/candidate-search/query-list/bib.spec.js.map +0 -1
- package/dist/index.spec.js +0 -127
- package/dist/index.spec.js.map +0 -1
- package/dist/match-detection/features/bib/index.spec.js +0 -93
- package/dist/match-detection/features/bib/index.spec.js.map +0 -1
- package/dist/match-detection/index.spec.js +0 -91
- package/dist/match-detection/index.spec.js.map +0 -1
- package/src/candidate-search/query-list/bib.spec.js +0 -54
- package/src/match-detection/features/bib/index.spec.js +0 -78
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"bib.js","names":["_debug","_interopRequireDefault","require","_candidateSearchUtils","_matchingUtils","obj","__esModule","default","debug","createDebugLogger","bibSourceIds","record","debugData","extend","fSids","get","length","JSON","stringify","toSidQueries","sidStrings","getSidStrings","sidQueries","toQueries","map","toSidString","filter","nonEmptySid","field","validateSidFieldSubfieldCounts","createSidString","sfC","getSubfieldValues","sfB","cleanedSfC","removeSourcePrefix","normalizeSidSubfieldValue","cleanedSfB","concat","subfieldValue","sourcePrefixRegex","normalizedValue","testStringOrNumber","String","replace","normalizeAwayRegex","bibMelindaIds","melindaIds","getMelindaIdsF035","bibHostComponents","id","getHostId","value","subfields","find","code","test","bibTitle","bibTitleAuthorPublisher","onlyTitleLength","bibTitleAuthor","bibTitleAuthorYear","addYear","title","getTitle","booleanStartWords","formatted","trim","slice","useWordSearch","some","word","toLowerCase","startsWith","queryIsOkAlone","query","addAuthorsToSearch","authorQuery","bibAuthors","undefined","addYearToSearch","addPublisherToSearch","publisherQuery","bibPublishers","yearQuery","bibYear","titleString","includes","join","author","getAuthor","authorString","publisher","getPublisher","publisherString","year","getYear","bibStandardIdentifiers","fields","identifiers","toIdentifiers","uniqueIdentifiers","Set","tag","issnIsbnReqExp","otherIdReqExp","sub"],"sources":["../../../src/candidate-search/query-list/bib.js"],"sourcesContent":["\n/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* Melinda record matching modules for Javascript\n*\n* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of melinda-record-matching-js\n*\n* melinda-record-matching-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Lesser General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* melinda-record-matching-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Lesser General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\nimport createDebugLogger from 'debug';\nimport {toQueries} from '../candidate-search-utils';\nimport {getMelindaIdsF035, validateSidFieldSubfieldCounts, getSubfieldValues, testStringOrNumber} from '../../matching-utils';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query');\n\nexport function bibSourceIds(record) {\n\n /* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records\n SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:\n\n SID__ $c 123457 $b helka\n SID__ $c (ANDL100020)1077305 $b sata\n SID__ $c VER999999 $ FI-KV\n SID__ $c /10024/508126 $ REPO_THESEUS\n\n In melinda.sourceid -index case is kept, sourceprefixes in brackets and hyphens are normalized away:\n Note: slashes are not normalized away, but a SRU-search-string including slashes needs to be quoted\n\n 1234567helka\n 1077305sata\n VER999999FIKV\n /10024/508126REPO_THESEUS\n\n Note: All Melinda records that have a matching records in a local db do NOT have SID for that local records,\n existence of a SID field depends on how the record has been added to Melinda and how it has been handled\n afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db\n after the matching record is removed from the local db.\n\n */\n\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');\n const debugData = debug.extend('data');\n //const debugInfo = debug.extend('info');\n\n debug(`Creating queries for sourceid's`);\n\n const fSids = record.get('SID');\n debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);\n\n return fSids.length > 0 ? toSidQueries(fSids) : [];\n\n function toSidQueries(fSids) {\n debug(`Creating actual queries for sourceid's`);\n\n const sidStrings = getSidStrings(fSids);\n\n if (sidStrings.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n const sidQueries = toQueries(sidStrings, 'melinda.sourceid');\n\n return sidQueries;\n\n function getSidStrings(fSids) {\n debug(`Getting Sid strings from SID fields`);\n\n // Map SID fields to valid sidStrings, filter out empty strings\n const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);\n return sidStrings;\n\n function toSidString(field) {\n debug(`Getting string from a field`);\n\n return validateSidFieldSubfieldCounts(field) ? createSidString(field) : '';\n\n function createSidString(field) {\n debug(`Creating string from a field`);\n const [sfC] = getSubfieldValues(field, 'c');\n const [sfB] = getSubfieldValues(field, 'b');\n\n const cleanedSfC = removeSourcePrefix(normalizeSidSubfieldValue(sfC));\n const cleanedSfB = normalizeSidSubfieldValue(sfB);\n\n debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);\n return cleanedSfC.concat(cleanedSfB);\n }\n\n function removeSourcePrefix(subfieldValue) {\n const sourcePrefixRegex = (/^(?<sourcePrefix>\\([A-Za-z0-9-]+\\))(?<id>.+)$/u);\n const normalizedValue = testStringOrNumber(subfieldValue) ? String(subfieldValue).replace(sourcePrefixRegex, '$<id>') : '';\n debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);\n return normalizedValue;\n }\n\n function normalizeSidSubfieldValue(subfieldValue) {\n debugData(`Normalizing ${subfieldValue}`);\n const normalizeAwayRegex = (/[- ]/u);\n return testStringOrNumber(subfieldValue) ? String(subfieldValue).replace(normalizeAwayRegex, '') : '';\n }\n\n }\n }\n }\n}\n\nexport function bibMelindaIds(record) {\n // Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');\n const debugData = debug.extend('data');\n debug(`Creating queries for MelindaIds`);\n\n // Note: Melinda-ID's for search queries are created just from records f035a's and f035z's\n // Both (FI-MELINDA)- and FCC-prefixed forms are found\n // f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA\n const melindaIds = getMelindaIdsF035(record);\n\n debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);\n\n if (melindaIds.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(melindaIds, 'melinda.melindaid');\n}\n\n\n// bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05\n// bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?\nexport function bibHostComponents(record) {\n const id = getHostId();\n return testStringOrNumber(id) ? [`melinda.partsofhost=${id}`] : [];\n\n function getHostId() {\n const [field] = record.get(/^773$/u);\n\n if (field) {\n const {value} = field.subfields.find(({code}) => code === 'w') || {};\n\n if (testStringOrNumber(value) && (/^\\(FI-MELINDA\\)/u).test(String(value))) {\n return String(value).replace(/^\\(FI-MELINDA\\)/u, '');\n }\n\n if (testStringOrNumber(value) && (/^\\(FIN01\\)/u).test(String(value))) {\n return String(value).replace(/^\\(FIN01\\)/u, '');\n }\n\n return false;\n }\n return false;\n }\n}\n\n// SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to\n// (probably) to *headings* index TIT\n// - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search\n\n// Headings index TIT drops articles etc. from the start of the title according to the filing indicator\n// Currently filing indicator is not implemented - if the title starts with an article and the Melinda\n// record is correctly catalogued using a filing indicator -> dc.title search won't match\n\nexport function bibTitle(record) {\n // We get author/publisher only when formatted title is shorter than 5 chars\n return bibTitleAuthorPublisher({record, onlyTitleLength: 5});\n}\n\nexport function bibTitleAuthor(record) {\n debug('bibTitleAuthor');\n // We use onlyTitleLength that is longer than our formatted length to\n // get an author or an publisher always\n return bibTitleAuthorPublisher({record, onlyTitleLength: 100});\n}\n\nexport function bibTitleAuthorYear(record) {\n debug('bibTitleAuthorYear');\n // We use onlyTitleLength that is longer than our formatted length to\n // get an author or an publisher always\n\n return bibTitleAuthorPublisher({record, onlyTitleLength: 100, addYear: true});\n}\n\nexport function bibTitleAuthorPublisher({record, onlyTitleLength, addYear = false}) {\n debug('bibTitleAuthorPublisher');\n const title = getTitle();\n const booleanStartWords = ['and', 'or', 'nor', 'not'];\n\n if (testStringOrNumber(title)) {\n const formatted = String(title)\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n // use word search for titles starting with a boolean\n const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));\n // Prevent too many matches / SRU crashing by having a minimum length\n // Note that currently this fails matching if there are no matches from previous matchers\n if (formatted.length >= onlyTitleLength) {\n return [`dc.title=\"${useWordSearch ? '' : '^'}${formatted}*\"`];\n }\n const queryIsOkAlone = formatted.length >= 5;\n\n // use word search without ending * also in combination searches to avoid SRU-server crashes [MRA-189]\n const query = `dc.title=\"${useWordSearch || !queryIsOkAlone ? '' : '^'}${formatted}${queryIsOkAlone ? '*' : ''}\"`;\n debug(`query: ${query}`);\n return addAuthorsToSearch({query, queryIsOkAlone, addYear});\n }\n\n return [];\n\n function addAuthorsToSearch({query, queryIsOkAlone = false, addYear = false}) {\n debug('addAuthorsToSearch');\n const [authorQuery] = bibAuthors(record);\n if (authorQuery !== undefined) {\n if (addYear) {\n return addYearToSearch({query: `${authorQuery} AND ${query}`, queryIsOkAlone: true});\n }\n return [`${authorQuery} AND ${query}`];\n }\n return addPublisherToSearch({query, queryIsOkAlone, addYear});\n //return [];\n }\n\n function addPublisherToSearch({query, queryIsOkAlone = false, addYear = false}) {\n const [publisherQuery] = bibPublishers(record);\n if (publisherQuery !== undefined) {\n if (addYear) {\n return addYearToSearch({query: `${publisherQuery} AND ${query}`, queryIsOkAlone: true});\n }\n return [`${publisherQuery} AND ${query}`];\n }\n if (queryIsOkAlone && !addYear) {\n return [`${query}`];\n }\n return addYearToSearch({query, queryIsOkAlone});\n }\n\n function addYearToSearch({query, queryIsOkAlone = false}) {\n const [yearQuery] = bibYear(record);\n if (yearQuery !== undefined) {\n return [`${yearQuery} AND ${query}`];\n }\n if (queryIsOkAlone) {\n return [`${query}`];\n }\n return [];\n }\n\n function getTitle() {\n const [field] = record.get(/^245$/u);\n\n if (field) {\n const titleString = field.subfields\n //.filter(({code}) => ['a', 'b', 'n', 'p'].includes(code))\n .filter(({code}) => ['a', 'b'].includes(code))\n //.filter(({code}) => ['a'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n return titleString;\n }\n return false;\n }\n}\n\nexport function bibAuthors(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibAuthors');\n const debugData = debug.extend('data');\n debug(`Creating query for the first author`);\n //debugData(record);\n\n const author = getAuthor(record);\n const booleanStartWords = ['and', 'or', 'nor', 'not'];\n\n\n if (testStringOrNumber(author)) {\n const formatted = String(author)\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n // use word search for authors starting with a boolean\n const useWordSearch = booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));\n // Prevent too many matches by having a minimum length\n debugData(`Author string: ${formatted}`);\n if (formatted.length >= 5) {\n return [`dc.author=\"${useWordSearch ? '' : '^'}${formatted}*\"`];\n }\n return [];\n }\n\n return [];\n\n function getAuthor(record) {\n //debugData(record);\n // eslint-disable-next-line prefer-named-capture-group\n const [field] = record.get(/^(100)|(110)|(111)|(700)|(710)|(711)$/u);\n //debugData(field);\n\n if (field) {\n const authorString = field.subfields\n .filter(({code}) => ['a'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n return authorString;\n }\n return false;\n }\n}\n\nexport function bibPublishers(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibPublishers');\n const debugData = debug.extend('data');\n debug(`Creating query for the first publisher`);\n //debugData(record);\n\n const publisher = getPublisher(record);\n if (testStringOrNumber(publisher)) {\n const formatted = String(publisher)\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n debugData(`Publisher string: ${formatted}`);\n // use non-wildcard word search from dc.publisher\n return [`dc.publisher=\"${formatted}\"`];\n }\n\n return [];\n\n function getPublisher(record) {\n //debugData(record);\n const [field] = record.get(/^(?:260)|(?:264)$/u);\n //debugData(field);\n\n if (field) {\n const publisherString = field.subfields\n .filter(({code}) => ['b'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n return publisherString;\n }\n return false;\n }\n}\n\nexport function bibYear(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibYear');\n const debugData = debug.extend('data');\n debug(`Creating query for the publishing year`);\n debugData(record);\n\n const year = getYear(record);\n if (year) {\n return [`dc.date=\"${year}\"`];\n }\n return [];\n\n function getYear(record) {\n const value = record.get(/^008$/u)?.[0]?.value || undefined;\n return testStringOrNumber(value) ? String(value).slice(7, 11) : undefined;\n }\n}\n\n\nexport function bibStandardIdentifiers(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');\n const debugData = debug.extend('data');\n debug(`Creating queries for standard identifiers`);\n\n // DEVELOP: should we query also f015 and f028?\n\n const fields = record.get(/^(?<def>020|022|024)$/u);\n const identifiers = [].concat(...fields.map(toIdentifiers));\n const uniqueIdentifiers = [...new Set(identifiers)];\n\n debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);\n debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);\n debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);\n\n if (uniqueIdentifiers.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(uniqueIdentifiers, 'dc.identifier');\n\n function toIdentifiers({tag, subfields}) {\n const issnIsbnReqExp = (/^[A-Za-z0-9-]+$/u);\n const otherIdReqExp = (/^[A-Za-z0-9-:]+$/u);\n\n if (tag === '022') {\n return subfields\n .filter(sub => ['a', 'z', 'y'].includes(sub.code) && testStringOrNumber(sub.value) && issnIsbnReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n\n if (tag === '020') {\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && testStringOrNumber(sub.value) && issnIsbnReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && testStringOrNumber(sub.value) && otherIdReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAA8H,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA7B9H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,MAAMG,KAAK,GAAG,IAAAC,cAAiB,EAAC,0DAA0D,CAAC;AAEpF,SAASC,YAAYA,C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,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAACnB,QAAQ,CAACmB,GAAG,CAACnD,IAAI,CAAC,IAAI,IAAAb,iCAAkB,EAACgE,GAAG,CAACtD,KAAK,CAAC,IAAIoD,cAAc,CAAChD,IAAI,CAACb,MAAM,CAAC+D,GAAG,CAACtD,KAAK,CAAC,CAAC,CAAC,CAC5H5B,GAAG,CAAC,CAAC;QAAC4B;MAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;IACpC;IAEA,IAAImD,GAAG,KAAK,KAAK,EAAE;MACjB,OAAOlD,SAAS,CACb3B,MAAM,CAACgF,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACnB,QAAQ,CAACmB,GAAG,CAACnD,IAAI,CAAC,IAAI,IAAAb,iCAAkB,EAACgE,GAAG,CAACtD,KAAK,CAAC,IAAIoD,cAAc,CAAChD,IAAI,CAACb,MAAM,CAAC+D,GAAG,CAACtD,KAAK,CAAC,CAAC,CAAC,CACvH5B,GAAG,CAAC,CAAC;QAAC4B;MAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;IACpC;IAEA,OAAOC,SAAS,CACb3B,MAAM,CAACgF,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAACnB,QAAQ,CAACmB,GAAG,CAACnD,IAAI,CAAC,IAAI,IAAAb,iCAAkB,EAACgE,GAAG,CAACtD,KAAK,CAAC,IAAIqD,aAAa,CAACjD,IAAI,CAACb,MAAM,CAAC+D,GAAG,CAACtD,KAAK,CAAC,CAAC,CAAC,CACtH5B,GAAG,CAAC,CAAC;MAAC4B;IAAK,CAAC,KAAKT,MAAM,CAACS,KAAK,CAAC,CAAC;EACpC;AACF"}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/candidate-search/query-list/bib.js"],
|
|
4
|
+
"sourcesContent": ["import createDebugLogger from 'debug';\nimport {toQueries} from '../candidate-search-utils.js';\nimport {getMelindaIdsF035, validateSidFieldSubfieldCounts, getSubfieldValues, testStringOrNumber} from '../../matching-utils.js';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query');\n\nexport function bibSourceIds(record) {\n\n /* Melinda's SRU-index melinda.sourceid includes source IDs from SID fields in Melinda records\n SID-fields in Melinda have sf $c with local id and sf $b with a code for the local db:\n\n SID__ $c 123457 $b helka\n SID__ $c (ANDL100020)1077305 $b sata\n SID__ $c VER999999 $ FI-KV\n SID__ $c /10024/508126 $ REPO_THESEUS\n\n In melinda.sourceid -index case is kept, sourceprefixes in brackets and hyphens are normalized away:\n Note: slashes are not normalized away, but a SRU-search-string including slashes needs to be quoted\n\n 1234567helka\n 1077305sata\n VER999999FIKV\n /10024/508126REPO_THESEUS\n\n Note: All Melinda records that have a matching records in a local db do NOT have SID for that local records,\n existence of a SID field depends on how the record has been added to Melinda and how it has been handled\n afterwards. SIDs are also not reliably maintained. A record might or might not have a SID for a local db\n after the matching record is removed from the local db.\n\n */\n\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:source-ids');\n const debugData = debug.extend('data');\n //const debugInfo = debug.extend('info');\n\n debug(`Creating queries for sourceid's`);\n\n const fSids = record.get('SID');\n debugData(`SID-fields (${fSids.length}): ${JSON.stringify(fSids)}`);\n\n return fSids.length > 0 ? toSidQueries(fSids) : [];\n\n function toSidQueries(fSids) {\n debug(`Creating actual queries for sourceid's`);\n\n const sidStrings = getSidStrings(fSids);\n\n if (sidStrings.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n const sidQueries = toQueries(sidStrings, 'melinda.sourceid');\n\n return sidQueries;\n\n function getSidStrings(fSids) {\n debug(`Getting Sid strings from SID fields`);\n\n // Map SID fields to valid sidStrings, filter out empty strings\n const sidStrings = fSids.map(toSidString).filter(nonEmptySid => nonEmptySid);\n return sidStrings;\n\n function toSidString(field) {\n debug(`Getting string from a field`);\n\n return validateSidFieldSubfieldCounts(field) ? createSidString(field) : '';\n\n function createSidString(field) {\n debug(`Creating string from a field`);\n const [sfC] = getSubfieldValues(field, 'c');\n const [sfB] = getSubfieldValues(field, 'b');\n\n const cleanedSfC = removeSourcePrefix(normalizeSidSubfieldValue(sfC));\n const cleanedSfB = normalizeSidSubfieldValue(sfB);\n\n debugData(`${JSON.stringify(sfC)} + ${JSON.stringify(sfB)}`);\n return cleanedSfC.concat(cleanedSfB);\n }\n\n function removeSourcePrefix(subfieldValue) {\n const sourcePrefixRegex = (/^(?<sourcePrefix>\\([A-Za-z0-9-]+\\))(?<id>.+)$/u);\n const normalizedValue = testStringOrNumber(subfieldValue) ? String(subfieldValue).replace(sourcePrefixRegex, '$<id>') : '';\n debugData(`Normalized ${subfieldValue} to ${normalizedValue}`);\n return normalizedValue;\n }\n\n function normalizeSidSubfieldValue(subfieldValue) {\n debugData(`Normalizing ${subfieldValue}`);\n const normalizeAwayRegex = (/[- ]/u);\n return testStringOrNumber(subfieldValue) ? String(subfieldValue).replace(normalizeAwayRegex, '') : '';\n }\n\n }\n }\n }\n}\n\nexport function bibMelindaIds(record) {\n // Melinda's SRU-index melinda.melindaid includes f001 controlnumbers and old Melinda-IDs from f035z's for all non-deleted Melinda-records\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibMelindaIds');\n const debugData = debug.extend('data');\n debug(`Creating queries for MelindaIds`);\n\n // Note: Melinda-ID's for search queries are created just from records f035a's and f035z's\n // Both (FI-MELINDA)- and FCC-prefixed forms are found\n // f001 controlnumber is not currently included, even if record's f003 is FI-MELINDA\n const melindaIds = getMelindaIdsF035(record);\n\n debugData(`Unique identifiers (${melindaIds.length}): ${JSON.stringify(melindaIds)}`);\n\n if (melindaIds.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(melindaIds, 'melinda.melindaid');\n}\n\n\n// bibHostComponents returns host id from the first subfield $w of first field f773, see test-fixtures 04 and 05\n// bibHostComponents should search all 773 $ws for possible host id, but what should it do in case of multiple host ids?\nexport function bibHostComponents(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents');\n const debugData = debug.extend('data');\n debug(`Creating queries for hostIds`);\n\n const id = getHostId();\n debugData(`Found id: ${JSON.stringify(id)}`);\n\n return testStringOrNumber(id) ? [`melinda.partsofhost=${id}`] : [];\n\n function getHostId() {\n const [field] = record.get(/^773$/u);\n\n if (field) {\n const {value} = field.subfields.find(({code}) => code === 'w') || {};\n\n if (testStringOrNumber(value) && (/^\\(FI-MELINDA\\)/u).test(String(value))) {\n return String(value).replace(/^\\(FI-MELINDA\\)/u, '');\n }\n\n if (testStringOrNumber(value) && (/^\\(FIN01\\)/u).test(String(value))) {\n return String(value).replace(/^\\(FIN01\\)/u, '');\n }\n\n return false;\n }\n return false;\n }\n}\n\n// SRU search dc.title with a search phrase starting with ^ maps currently in Melinda to\n// (probably) to *headings* index TIT\n// - Aleph cannot currently handle headings searches starting with a boolean - in these cases use word search\n\n// Headings index TIT drops articles etc. from the start of the title according to the filing indicator\n// Currently filing indicator is not implemented - if the title starts with an article and the Melinda\n// record is correctly catalogued using a filing indicator -> dc.title search won't match\n\nexport function bibTitle(record) {\n // We get author/publisher only when formatted title is shorter than 5 chars\n return bibTitleAuthorPublisher({record, onlyTitleLength: 5});\n}\n\nexport function bibTitleAuthor(record) {\n debug('bibTitleAuthor');\n // We use onlyTitleLength that is longer than our formatted length to\n // get an author or an publisher always\n return bibTitleAuthorPublisher({record, onlyTitleLength: 100});\n}\n\nexport function bibTitleAuthorYear(record) {\n debug('bibTitleAuthorYearAlternates');\n // We use onlyTitleLength that is longer than our formatted length to\n // get an author or an publisher always\n\n return bibTitleAuthorPublisher({record, onlyTitleLength: 100, addYear: true});\n}\n\nexport function bibTitleAuthorYearAlternates(record) {\n debug('bibTitleAuthorYearAlternates');\n // We use onlyTitleLength that is longer than our formatted length to\n // get an author or an publisher always\n const origQueryList = bibTitleAuthorPublisher({record, onlyTitleLength: 100, addYear: true, alternates: true, alternateQueries: []});\n debug(`${JSON.stringify(origQueryList)}`);\n return {queryList: Array.from(origQueryList).reverse(), queryListType: 'alternates'};\n}\n\nexport function bibTitleAuthorPublisher({record, onlyTitleLength, addYear = false, alternates = false, alternateQueries = []}) {\n debug(`bibTitleAuthorPublisher, onlyTitleLength: ${onlyTitleLength}, addYear: ${addYear}, alternates: ${alternates}`);\n const title = getTitle();\n if (testStringOrNumber(title)) {\n const formatted = String(title)\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n // use word search for titles starting with a boolean\n const useWordSearch = checkUseWordSearch(formatted);\n // Prevent too many matches / SRU crashing by having a minimum length\n // Note that currently this fails matching if there are no matches from previous matchers\n if (formatted.length >= onlyTitleLength && !alternates) {\n return [`dc.title=\"${useWordSearch ? '' : '^'}${formatted}*\"`];\n }\n const queryIsOkAlone = formatted.length >= 5;\n\n // use word search without ending * also in combination searches to avoid SRU-server crashes [MRA-189]\n const query = `dc.title=\"${useWordSearch || !queryIsOkAlone ? '' : '^'}${formatted}${queryIsOkAlone ? '*' : ''}\"`;\n debug(`query: ${query}`);\n const newAlternateQueries = alternates ? [...alternateQueries, query] : alternateQueries;\n\n return addAuthorsToSearch({query, queryIsOkAlone, addYear, alternates, alternateQueries: newAlternateQueries});\n }\n\n return [];\n\n function addAuthorsToSearch({query, queryIsOkAlone = false, addYear = false, alternates = false, alternateQueries = []}) {\n debug('addAuthorsToSearch');\n const [authorQuery] = bibAuthors(record);\n if (authorQuery !== undefined) {\n if (addYear) {\n const newAlternateQueries = alternates ? [...alternateQueries, `${authorQuery} AND ${query}`] : alternateQueries;\n return addYearToSearch({query: `${authorQuery} AND ${query}`, queryIsOkAlone: true, alternates, alternateQueries: newAlternateQueries});\n }\n return alternates ? alternateQueries : [`${authorQuery} AND ${query}`];\n }\n return addPublisherToSearch({query, queryIsOkAlone, addYear, alternates, alternateQueries});\n //return [];\n }\n\n function addPublisherToSearch({query, queryIsOkAlone = false, addYear = false, alternates = false, alternateQueries = []}) {\n const [publisherQuery] = bibPublishers(record);\n if (publisherQuery !== undefined) {\n if (addYear) {\n const newAlternateQueries = alternates ? [...alternateQueries, `${publisherQuery} AND ${query}`] : alternateQueries;\n return addYearToSearch({query: `${publisherQuery} AND ${query}`, queryIsOkAlone: true, alternates, alternateQueries: newAlternateQueries});\n }\n return alternates ? alternateQueries : [`${publisherQuery} AND ${query}`];\n }\n if (queryIsOkAlone && !addYear) {\n return alternates ? alternateQueries : [`${query}`];\n }\n return addYearToSearch({query, queryIsOkAlone, alternates, alternateQueries});\n }\n\n function addYearToSearch({query, queryIsOkAlone = false, alternates = false, alternateQueries = []}) {\n const [yearQuery] = bibYear(record);\n if (yearQuery !== undefined) {\n const newAlternateQueries = alternates ? [...alternateQueries, `${yearQuery} AND ${query}`] : alternateQueries;\n return alternates ? newAlternateQueries : [`${yearQuery} AND ${query}`];\n }\n if (queryIsOkAlone) {\n return alternates ? alternateQueries : [`${query}`];\n }\n return [];\n }\n\n function getTitle() {\n const [field] = record.get(/^245$/u);\n\n if (field) {\n const titleString = field.subfields\n //.filter(({code}) => ['a', 'b', 'n', 'p'].includes(code))\n .filter(({code}) => ['a', 'b'].includes(code))\n //.filter(({code}) => ['a'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n return titleString;\n }\n return false;\n }\n}\n\nexport function bibAuthors(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibAuthors');\n const debugData = debug.extend('data');\n debug(`Creating query for the first author`);\n //debugData(record);\n\n const author = getAuthor(record);\n\n if (testStringOrNumber(author)) {\n const formatted = String(author)\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n // use word search for authors starting with a boolean\n const useWordSearch = checkUseWordSearch(formatted);\n // Prevent too many matches by having a minimum length\n debugData(`Author string: ${formatted}`);\n if (formatted.length >= 5) {\n return [`dc.author=\"${useWordSearch ? '' : '^'}${formatted}*\"`];\n }\n return [];\n }\n\n return [];\n\n function getAuthor(record) {\n //debugData(record);\n // eslint-disable-next-line prefer-named-capture-group\n const [field] = record.get(/^(100)|(110)|(111)|(700)|(710)|(711)$/u);\n //debugData(field);\n\n if (field) {\n const authorString = field.subfields\n .filter(({code}) => ['a'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n return authorString;\n }\n return false;\n }\n}\n\nexport function bibPublishers(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibPublishers');\n const debugData = debug.extend('data');\n debug(`Creating query for the first publisher`);\n //debugData(record);\n\n const publisher = getPublisher(record);\n if (testStringOrNumber(publisher)) {\n const formatted = String(publisher)\n .replace(/[^\\w\\s\\p{Alphabetic}]/gu, '')\n // Clean up concurrent spaces from fe. subfield changes\n .replace(/ +/gu, ' ')\n .trim()\n .slice(0, 30)\n .trim();\n\n debugData(`Publisher string: ${formatted}`);\n // use non-wildcard word search from dc.publisher\n return [`dc.publisher=\"${formatted}\"`];\n }\n\n return [];\n\n function getPublisher(record) {\n //debugData(record);\n const [field] = record.get(/^(?:260)|(?:264)$/u);\n //debugData(field);\n\n if (field) {\n const publisherString = field.subfields\n .filter(({code}) => ['b'].includes(code))\n .map(({value}) => testStringOrNumber(value) ? String(value) : '')\n .filter(value => value)\n // In Melinda's index subfield separators are indexed as ' '\n .join(' ');\n return publisherString;\n }\n return false;\n }\n}\n\nexport function bibYear(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibYear');\n const debugData = debug.extend('data');\n debug(`Creating query for the publishing year`);\n\n const year = getYear(record);\n if (year) {\n return [`dc.date=\"${year}\"`];\n }\n return [];\n\n function getYear(record) {\n const [f008] = record.get(/^008$/u);\n if (f008 === undefined) {\n debug('f008 missing');\n return false;\n }\n\n debugData(`f008: ${JSON.stringify(f008)}`);\n const {value} = f008;\n return testStringOrNumber(value) ? String(value).slice(7, 11) : undefined;\n }\n}\n\nexport function checkUseWordSearch(formatted) {\n // Note: add a space to startWords to catch just actual boolean words\n const booleanStartWords = ['and ', 'or ', 'nor ', 'not '];\n return booleanStartWords.some(word => formatted.toLowerCase().startsWith(word));\n}\n\nexport function bibStandardIdentifiers(record) {\n\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibStandardIdentifiers');\n const debugData = debug.extend('data');\n debug(`Creating queries for standard identifiers`);\n\n // DEVELOP: should we query also f015 and f028?\n\n const fields = record.get(/^(?<def>020|022|024)$/u);\n const identifiers = [].concat(...fields.map(toIdentifiers));\n const uniqueIdentifiers = [...new Set(identifiers)];\n\n debugData(`Standard identifier fields: ${JSON.stringify(fields)}`);\n debugData(`Identifiers (${identifiers.length}): ${JSON.stringify(identifiers)}`);\n debugData(`Unique identifiers (${uniqueIdentifiers.length}): ${JSON.stringify(uniqueIdentifiers)}`);\n\n if (uniqueIdentifiers.length < 1) {\n debug(`No identifiers found, no queries created.`);\n return [];\n }\n\n return toQueries(uniqueIdentifiers, 'dc.identifier');\n\n function toIdentifiers({tag, subfields}) {\n const issnIsbnReqExp = (/^[A-Za-z0-9-]+$/u);\n const otherIdReqExp = (/^[A-Za-z0-9-:]+$/u);\n\n if (tag === '022') {\n return subfields\n .filter(sub => ['a', 'z', 'y'].includes(sub.code) && testStringOrNumber(sub.value) && issnIsbnReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n\n if (tag === '020') {\n return subfields\n .filter(sub => ['a', 'z'].includes(sub.code) && testStringOrNumber(sub.value) && issnIsbnReqExp.test(String(sub.value)))\n .map(({value}) => String(value));\n }\n\n return subfields\n .filter(sub => ['a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I,QAAQ,OAAO;AACjB,aAAO,UACJ,OAAO,SAAO,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,IAAI,KAAK,mBAAmB,IAAI,KAAK,KAAK,eAAe,KAAK,OAAO,IAAI,KAAK,CAAC,CAAC,EACtH,IAAI,CAAC,EAAC,MAAK,MAAM,OAAO,KAAK,CAAC;AAAA,IACnC;AAEA,WAAO,UACJ,OAAO,SAAO,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI,IAAI,KAAK,mBAAmB,IAAI,KAAK,KAAK,cAAc,KAAK,OAAO,IAAI,KAAK,CAAC,CAAC,EACrH,IAAI,CAAC,EAAC,MAAK,MAAM,OAAO,KAAK,CAAC;AAAA,EACnC;AACF;",
|
|
6
|
+
"names": ["debug", "fSids", "sidStrings", "field", "addYear", "alternates", "alternateQueries", "record"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
2
|
+
import { describe } from "node:test";
|
|
3
|
+
import createDebugLogger from "debug";
|
|
4
|
+
import generateTests from "@natlibfi/fixugen";
|
|
5
|
+
import { READERS } from "@natlibfi/fixura";
|
|
6
|
+
import { MarcRecord } from "@natlibfi/marc-record";
|
|
7
|
+
import * as generators from "./bib.js";
|
|
8
|
+
const debug = createDebugLogger("@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents:test");
|
|
9
|
+
const debugData = debug.extend("data");
|
|
10
|
+
describe("candidate-search/query-list/bib/", () => {
|
|
11
|
+
generateTests({
|
|
12
|
+
path: [import.meta.dirname, "..", "..", "..", "test-fixtures", "candidate-search", "query-list", "bib"],
|
|
13
|
+
useMetadataFile: true,
|
|
14
|
+
fixura: {
|
|
15
|
+
reader: READERS.JSON
|
|
16
|
+
},
|
|
17
|
+
callback: ({ type, inputRecord, expectedQuery, expectedQueryListType, enabled = true }) => {
|
|
18
|
+
const generate = generators[type];
|
|
19
|
+
const record = new MarcRecord(inputRecord, { subfieldValues: false });
|
|
20
|
+
if (!enabled) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const result = generate(record);
|
|
24
|
+
debugData(`Result: ${JSON.stringify(result)}`);
|
|
25
|
+
if (result.queryListType) {
|
|
26
|
+
assert.deepStrictEqual(result.queryList, expectedQuery);
|
|
27
|
+
assert.equal(result.queryListType, expectedQueryListType);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
assert.deepStrictEqual(result, expectedQuery);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=bib.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/candidate-search/query-list/bib.test.js"],
|
|
4
|
+
"sourcesContent": ["import assert from 'node:assert';\nimport {describe} from 'node:test';\nimport createDebugLogger from 'debug';\nimport generateTests from '@natlibfi/fixugen';\nimport {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport * as generators from './bib.js';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:bibHostComponents:test');\nconst debugData = debug.extend('data');\n\ndescribe('candidate-search/query-list/bib/', () => {\n generateTests({\n path: [import.meta.dirname, '..', '..', '..', 'test-fixtures', 'candidate-search', 'query-list', 'bib'],\n useMetadataFile: true,\n fixura: {\n reader: READERS.JSON\n },\n callback: ({type, inputRecord, expectedQuery, expectedQueryListType, enabled = true}) => {\n const generate = generators[type];\n const record = new MarcRecord(inputRecord, {subfieldValues: false});\n\n if (!enabled) {\n return;\n }\n\n const result = generate(record);\n debugData(`Result: ${JSON.stringify(result)}`);\n\n if (result.queryListType) {\n assert.deepStrictEqual(result.queryList, expectedQuery);\n assert.equal(result.queryListType, expectedQueryListType);\n return;\n }\n assert.deepStrictEqual(result, expectedQuery);\n }\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,YAAY;AACnB,SAAQ,gBAAe;AACvB,OAAO,uBAAuB;AAC9B,OAAO,mBAAmB;AAC1B,SAAQ,eAAc;AACtB,SAAQ,kBAAiB;AACzB,YAAY,gBAAgB;AAE5B,MAAM,QAAQ,kBAAkB,iFAAiF;AACjH,MAAM,YAAY,MAAM,OAAO,MAAM;AAErC,SAAS,oCAAoC,MAAM;AACjD,gBAAc;AAAA,IACZ,MAAM,CAAC,YAAY,SAAS,MAAM,MAAM,MAAM,iBAAiB,oBAAoB,cAAc,KAAK;AAAA,IACtG,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,QAAQ,QAAQ;AAAA,IAClB;AAAA,IACA,UAAU,CAAC,EAAC,MAAM,aAAa,eAAe,uBAAuB,UAAU,KAAI,MAAM;AACvF,YAAM,WAAW,WAAW,IAAI;AAChC,YAAM,SAAS,IAAI,WAAW,aAAa,EAAC,gBAAgB,MAAK,CAAC;AAElE,UAAI,CAAC,SAAS;AACZ;AAAA,MACF;AAEA,YAAM,SAAS,SAAS,MAAM;AAC9B,gBAAU,WAAW,KAAK,UAAU,MAAM,CAAC,EAAE;AAE7C,UAAI,OAAO,eAAe;AACxB,eAAO,gBAAgB,OAAO,WAAW,aAAa;AACtD,eAAO,MAAM,OAAO,eAAe,qBAAqB;AACxD;AAAA,MACF;AACA,aAAO,gBAAgB,QAAQ,aAAa;AAAA,IAC9C;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import createDebugLogger from "debug";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { toQueries } from "../candidate-search-utils.js";
|
|
4
|
+
import { getSubfieldValues, testStringOrNumber, toMelindaIds } from "../../matching-utils.js";
|
|
5
|
+
const setTimeoutPromise = promisify(setTimeout);
|
|
6
|
+
export function hostIdMelinda(record) {
|
|
7
|
+
const debug = createDebugLogger("@natlibfi/melinda-record-matching:candidate-search:query:hostIdMelinda");
|
|
8
|
+
const debugData = debug.extend("data");
|
|
9
|
+
debug(`Creating query for the Melinda Id host`);
|
|
10
|
+
const ids = hostId(record);
|
|
11
|
+
if (ids.length > 0) {
|
|
12
|
+
return toQueries(ids, "melinda.partsofhost");
|
|
13
|
+
}
|
|
14
|
+
debug(`No valid Melinda Id host found`);
|
|
15
|
+
return [];
|
|
16
|
+
function hostId(record2) {
|
|
17
|
+
const f773s = record2.get(/^773$/u).filter((f773) => f773.subfields.some((sub) => sub.code === "w" && /\(FI-MELINDA\).*/ui.test(sub.value)));
|
|
18
|
+
if (f773s.length === 0) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const melindaIds = f773s.map((f773) => toMelindaIds(f773, ["w"])).flat().filter((value) => testStringOrNumber(value)).filter((value, index, array) => array.indexOf(value) === index);
|
|
22
|
+
return melindaIds;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function hostIdOtherSource(record, client) {
|
|
26
|
+
const debug = createDebugLogger("@natlibfi/melinda-record-matching:candidate-search:query:hostIdOtherSource");
|
|
27
|
+
const debugData = debug.extend("data");
|
|
28
|
+
debug(`Creating query for the Other source Id host`);
|
|
29
|
+
const ids = getHostIds(record);
|
|
30
|
+
const otherSources = getOtherSources(record);
|
|
31
|
+
if (ids.length > 0 && otherSources.length > 0) {
|
|
32
|
+
const otherSourceIds = ids.map((id) => otherSources.map((source) => `${id}${source}`)).flat();
|
|
33
|
+
const melindaHostQueries = await handleSruCalls(otherSourceIds);
|
|
34
|
+
debug(JSON.stringify(melindaHostQueries));
|
|
35
|
+
return melindaHostQueries;
|
|
36
|
+
}
|
|
37
|
+
debug(`No valid other source hosts found`);
|
|
38
|
+
return [];
|
|
39
|
+
function getHostIds(record2) {
|
|
40
|
+
const f773s = record2.get(/^773$/u).filter((f773) => f773.subfields.some((sub) => sub.code === "w" && !/\(FI-MELINDA\).*/ui.test(sub.value)));
|
|
41
|
+
if (f773s.length === 0) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const subfieldWs = f773s.map((f773) => {
|
|
45
|
+
debugData(`f773: ${JSON.stringify(f773)}`);
|
|
46
|
+
return getSubfieldValues(f773, "w").flat();
|
|
47
|
+
}).flat();
|
|
48
|
+
const ids2 = subfieldWs.map((value) => `${value}`.replace(/\(FI-.*\)/ui, "")).filter((value) => testStringOrNumber(value)).filter((value, index, array) => array.indexOf(value) === index);
|
|
49
|
+
return ids2;
|
|
50
|
+
}
|
|
51
|
+
function getOtherSources(record2) {
|
|
52
|
+
const fSids = record2.get("SID");
|
|
53
|
+
return fSids.map((field) => getSubfieldValues(field, "b"));
|
|
54
|
+
}
|
|
55
|
+
async function handleSruCalls(otherSourceIds, ids2 = []) {
|
|
56
|
+
const [otherSourceId, ...rest] = otherSourceIds;
|
|
57
|
+
if (otherSourceId === void 0) {
|
|
58
|
+
debug(`host ids: ${ids2}`);
|
|
59
|
+
const validIds = ids2.filter((id2) => id2);
|
|
60
|
+
return toQueries(validIds, "melinda.partsofhost");
|
|
61
|
+
}
|
|
62
|
+
const otherSourceHostQuery = await toQueries([otherSourceId], "melinda.sourceid");
|
|
63
|
+
const id = await new Promise((resolve, reject) => {
|
|
64
|
+
debug(`Searching for hosts with query: ${otherSourceHostQuery}`);
|
|
65
|
+
let recordId;
|
|
66
|
+
client.searchRetrieve(otherSourceHostQuery).on("error", (err) => {
|
|
67
|
+
debug(`SRU error for query: ${otherSourceHostQuery}: ${err}`);
|
|
68
|
+
reject(err);
|
|
69
|
+
}).on("end", async () => {
|
|
70
|
+
try {
|
|
71
|
+
debug(`Searching for hosts: done`);
|
|
72
|
+
await setTimeoutPromise(10);
|
|
73
|
+
resolve(recordId);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
debug(`Error caught on END`);
|
|
76
|
+
reject(err);
|
|
77
|
+
}
|
|
78
|
+
}).on("record", (record2) => {
|
|
79
|
+
const [field] = record2.get(/^001$/u);
|
|
80
|
+
debug(field);
|
|
81
|
+
recordId = field.value ? field.value : "";
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
return handleSruCalls(rest, [...ids2, id]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/candidate-search/query-list/component.js"],
|
|
4
|
+
"sourcesContent": ["import createDebugLogger from 'debug';\nimport {promisify} from 'util';\nimport {toQueries} from '../candidate-search-utils.js';\nimport {getSubfieldValues, testStringOrNumber, toMelindaIds} from '../../matching-utils.js';\n\nconst setTimeoutPromise = promisify(setTimeout); // eslint-disable-line\n\nexport function hostIdMelinda(record) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:hostIdMelinda');\n const debugData = debug.extend('data'); // eslint-disable-line\n debug(`Creating query for the Melinda Id host`);\n\n const ids = hostId(record);\n if (ids.length > 0) {\n return toQueries(ids, 'melinda.partsofhost');\n }\n\n debug(`No valid Melinda Id host found`);\n return [];\n\n function hostId(record) {\n // Multi 773 handling\n const f773s = record.get(/^773$/u)\n .filter(f773 => f773.subfields.some(sub => sub.code === 'w' && (/\\(FI-MELINDA\\).*/ui).test(sub.value)));\n\n if (f773s.length === 0) {\n return false;\n }\n\n // Multi $w handling\n // $w (prefix)<id> handling\n // $w <id> & $w (prefix)<id> Match\n const melindaIds = f773s.map(f773 => toMelindaIds(f773, ['w'])).flat()\n .filter(value => testStringOrNumber(value)) // drop invalid values\n .filter((value, index, array) => array.indexOf(value) === index); // unique values;\n return melindaIds;\n }\n}\n\nexport async function hostIdOtherSource(record, client) {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:query:hostIdOtherSource');\n const debugData = debug.extend('data'); // eslint-disable-line\n debug(`Creating query for the Other source Id host`);\n\n const ids = getHostIds(record);\n const otherSources = getOtherSources(record);\n if (ids.length > 0 && otherSources.length > 0) {\n const otherSourceIds = ids.map(id => otherSources.map(source => `${id}${source}`)).flat();\n const melindaHostQueries = await handleSruCalls(otherSourceIds);\n debug(JSON.stringify(melindaHostQueries));\n\n return melindaHostQueries;\n }\n\n debug(`No valid other source hosts found`);\n return [];\n\n\n function getHostIds(record) {\n const f773s = record.get(/^773$/u)\n .filter(f773 => f773.subfields.some(sub => sub.code === 'w' && !(/\\(FI-MELINDA\\).*/ui).test(sub.value)));\n if (f773s.length === 0) {\n return false;\n }\n\n // Multi 773 handling\n const subfieldWs = f773s\n .map(f773 => {\n debugData(`f773: ${JSON.stringify(f773)}`);\n return getSubfieldValues(f773, 'w').flat();\n }).flat();\n\n // Multi $w handling\n // $w (prefix)<id> handling\n // $w <id> & $w (prefix)<id> Match\n const ids = subfieldWs.map(value => `${value}`.replace(/\\(FI-.*\\)/ui, '')) // remove prefixes\n .filter(value => testStringOrNumber(value)) // drop invalid values\n .filter((value, index, array) => array.indexOf(value) === index); // unique values\n\n return ids;\n }\n\n function getOtherSources(record) {\n const fSids = record.get('SID');\n return fSids.map(field => getSubfieldValues(field, 'b'));\n }\n\n async function handleSruCalls(otherSourceIds, ids = []) {\n const [otherSourceId, ...rest] = otherSourceIds;\n\n if (otherSourceId === undefined) {\n debug(`host ids: ${ids}`);\n const validIds = ids.filter(id => id);\n return toQueries(validIds, 'melinda.partsofhost');\n }\n\n const otherSourceHostQuery = await toQueries([otherSourceId], 'melinda.sourceid');\n const id = await new Promise((resolve, reject) => {\n debug(`Searching for hosts with query: ${otherSourceHostQuery}`);\n let recordId;\n\n client.searchRetrieve(otherSourceHostQuery)\n .on('error', err => {\n debug(`SRU error for query: ${otherSourceHostQuery}: ${err}`);\n reject(err);\n })\n .on('end', async () => {\n try {\n debug(`Searching for hosts: done`);\n await setTimeoutPromise(10);\n resolve(recordId);\n } catch (err) {\n debug(`Error caught on END`);\n reject(err);\n }\n })\n .on('record', record => {\n const [field] = record.get(/^001$/u);\n debug(field);\n recordId = field.value ? field.value : '';\n });\n });\n\n return handleSruCalls(rest, [...ids, id]);\n }\n}\n\n"],
|
|
5
|
+
"mapp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E;AAC/D,UAAI;AAEJ,aAAO,eAAe,oBAAoB,EACvC,GAAG,SAAS,SAAO;AAClB,cAAM,wBAAwB,oBAAoB,KAAK,GAAG,EAAE;AAC5D,eAAO,GAAG;AAAA,MACZ,CAAC,EACA,GAAG,OAAO,YAAY;AACrB,YAAI;AACF,gBAAM,2BAA2B;AACjC,gBAAM,kBAAkB,EAAE;AAC1B,kBAAQ,QAAQ;AAAA,QAClB,SAAS,KAAK;AACZ,gBAAM,qBAAqB;AAC3B,iBAAO,GAAG;AAAA,QACZ;AAAA,MACF,CAAC,EACA,GAAG,UAAU,CAAAF,YAAU;AACtB,cAAM,CAAC,KAAK,IAAIA,QAAO,IAAI,QAAQ;AACnC,cAAM,KAAK;AACX,mBAAW,MAAM,QAAQ,MAAM,QAAQ;AAAA,MACzC,CAAC;AAAA,IACL,CAAC;AAED,WAAO,eAAe,MAAM,CAAC,GAAGC,MAAK,EAAE,CAAC;AAAA,EAC1C;AACF;",
|
|
6
|
+
"names": ["record", "ids", "id"]
|
|
7
|
+
}
|
|
@@ -1,60 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var bib = _interopRequireWildcard(require("./bib"));
|
|
8
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
13
|
-
*
|
|
14
|
-
* Melinda record matching modules for Javascript
|
|
15
|
-
*
|
|
16
|
-
* Copyright (C) 2020-2022 University Of Helsinki (The National Library Of Finland)
|
|
17
|
-
*
|
|
18
|
-
* This file is part of melinda-record-matching-js
|
|
19
|
-
*
|
|
20
|
-
* melinda-record-matching-js program is free software: you can redistribute it and/or modify
|
|
21
|
-
* it under the terms of the GNU Lesser General Public License as
|
|
22
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
23
|
-
* License, or (at your option) any later version.
|
|
24
|
-
*
|
|
25
|
-
* melinda-record-matching-js is distributed in the hope that it will be useful,
|
|
26
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
-
* GNU Lesser General Public License for more details.
|
|
29
|
-
*
|
|
30
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
31
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
-
*
|
|
33
|
-
* @licend The above is the entire license notice
|
|
34
|
-
* for the JavaScript code in this file.
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
const searchTypes = exports.searchTypes = {
|
|
1
|
+
import * as bib from "./bib.js";
|
|
2
|
+
import * as component from "./component.js";
|
|
3
|
+
import createDebugLogger from "debug";
|
|
4
|
+
const debug = createDebugLogger("@natlibfi/melinda-record-matching:candidate-search:index");
|
|
5
|
+
const debugData = debug.extend("data");
|
|
6
|
+
export const searchTypes = {
|
|
39
7
|
bib: {
|
|
40
|
-
standardIdentifiers:
|
|
41
|
-
hostComponents:
|
|
42
|
-
title:
|
|
8
|
+
standardIdentifiers: "bibStandardIdentifiers",
|
|
9
|
+
hostComponents: "bibHostComponents",
|
|
10
|
+
title: "bibTitle",
|
|
43
11
|
// title ( + first author + first publisher if needed)
|
|
44
|
-
titleAuthor:
|
|
12
|
+
titleAuthor: "bibTitleAuthor",
|
|
45
13
|
// title + first author (or first publisher if no author)
|
|
46
|
-
titleAuthorYear:
|
|
14
|
+
titleAuthorYear: "bibTitleAuthorYear",
|
|
47
15
|
// title + first author (or first publisher if no author), publishing year
|
|
48
|
-
|
|
49
|
-
|
|
16
|
+
titleAuthorYearAlternates: "bibTitleAuthorYearAlternates",
|
|
17
|
+
// title + first author (or first publisher if no author), publishing year
|
|
18
|
+
melindaId: "bibMelindaIds",
|
|
19
|
+
sourceIds: "bibSourceIds"
|
|
50
20
|
//DEVELOP: bibContent: 'bibContent'
|
|
21
|
+
},
|
|
22
|
+
component: {
|
|
23
|
+
hostIdMelinda: "hostIdMelinda",
|
|
24
|
+
// 773 $w (FI-MELINDA)
|
|
25
|
+
hostIdOtherSource: "hostIdOtherSource",
|
|
26
|
+
// 773 $w !(FI-MELINDA)
|
|
27
|
+
hostIsbn: "hostIsbn"
|
|
28
|
+
// 773 $z
|
|
51
29
|
}
|
|
52
30
|
};
|
|
53
|
-
|
|
54
|
-
const extractors = {
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
|
|
31
|
+
export default async (record, searchSpec, client) => {
|
|
32
|
+
const extractors = { ...bib, ...component };
|
|
33
|
+
debugData(`extractors: ${JSON.stringify(extractors)}`);
|
|
34
|
+
debugData(`searchSpec: ${JSON.stringify(searchSpec)}`);
|
|
35
|
+
const qExtractors = searchSpec.map(generateQueryExtractor);
|
|
36
|
+
const results = await handleQextractors(qExtractors);
|
|
37
|
+
return results;
|
|
38
|
+
async function handleQextractors(qExtractors2, results2 = []) {
|
|
39
|
+
const [qExtractor, ...rest] = qExtractors2;
|
|
40
|
+
if (qExtractor === void 0) {
|
|
41
|
+
return results2.flat();
|
|
42
|
+
}
|
|
43
|
+
const result = await qExtractor(record, client);
|
|
44
|
+
return handleQextractors(rest, [...results2, result]);
|
|
45
|
+
}
|
|
58
46
|
function generateQueryExtractor(type) {
|
|
59
47
|
if (extractors[type]) {
|
|
60
48
|
return extractors[type];
|
|
@@ -62,5 +50,4 @@ var _default = (record, searchSpec) => {
|
|
|
62
50
|
throw new Error(`Unknown search type: ${type}`);
|
|
63
51
|
}
|
|
64
52
|
};
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=index.js.map
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/candidate-search/query-list/index.js"],
|
|
4
|
+
"sourcesContent": ["import * as bib from './bib.js';\nimport * as component from './component.js';\nimport createDebugLogger from 'debug';\n\nconst debug = createDebugLogger('@natlibfi/melinda-record-matching:candidate-search:index');\nconst debugData = debug.extend('data');\n\nexport const searchTypes = {\n bib: {\n standardIdentifiers: 'bibStandardIdentifiers',\n hostComponents: 'bibHostComponents',\n title: 'bibTitle', // title ( + first author + first publisher if needed)\n titleAuthor: 'bibTitleAuthor', // title + first author (or first publisher if no author)\n titleAuthorYear: 'bibTitleAuthorYear', // title + first author (or first publisher if no author), publishing year\n titleAuthorYearAlternates: 'bibTitleAuthorYearAlternates', // title + first author (or first publisher if no author), publishing year\n melindaId: 'bibMelindaIds',\n sourceIds: 'bibSourceIds'\n //DEVELOP: bibContent: 'bibContent'\n },\n component: {\n hostIdMelinda: 'hostIdMelinda', // 773 $w (FI-MELINDA)\n hostIdOtherSource: 'hostIdOtherSource', // 773 $w !(FI-MELINDA)\n hostIsbn: 'hostIsbn' // 773 $z\n }\n};\n\nexport default async (record, searchSpec, client) => {\n const extractors = {...bib, ...component};\n debugData(`extractors: ${JSON.stringify(extractors)}`);\n debugData(`searchSpec: ${JSON.stringify(searchSpec)}`);\n\n const qExtractors = searchSpec.map(generateQueryExtractor);\n const results = await handleQextractors(qExtractors);\n return results;\n\n async function handleQextractors(qExtractors, results = []) {\n const [qExtractor, ...rest] = qExtractors;\n\n if (qExtractor === undefined) {\n return results.flat();\n }\n\n const result = await qExtractor(record, client);\n return handleQextractors(rest, [...results, result]);\n }\n\n function generateQueryExtractor(type) {\n if (extractors[type]) {\n //debugData(`${JSON.stringify(extractors[type])}`);\n return extractors[type];\n }\n\n throw new Error(`Unknown search type: ${type}`);\n }\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,SAAS;AACrB,YAAY,eAAe;AAC3B,OAAO,uBAAuB;AAE9B,MAAM,QAAQ,kBAAkB,0DAA0D;AAC1F,MAAM,YAAY,MAAM,OAAO,MAAM;AAE9B,aAAM,cAAc;AAAA,EACzB,KAAK;AAAA,IACH,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,IAChB,OAAO;AAAA;AAAA,IACP,aAAa;AAAA;AAAA,IACb,iBAAiB;AAAA;AAAA,IACjB,2BAA2B;AAAA;AAAA,IAC3B,WAAW;AAAA,IACX,WAAW;AAAA;AAAA,EAEb;AAAA,EACA,WAAW;AAAA,IACT,eAAe;AAAA;AAAA,IACf,mBAAmB;AAAA;AAAA,IACnB,UAAU;AAAA;AAAA,EACZ;AACF;AAEA,eAAe,OAAO,QAAQ,YAAY,WAAW;AACnD,QAAM,aAAa,EAAC,GAAG,KAAK,GAAG,UAAS;AACxC,YAAU,eAAe,KAAK,UAAU,UAAU,CAAC,EAAE;AACrD,YAAU,eAAe,KAAK,UAAU,UAAU,CAAC,EAAE;AAErD,QAAM,cAAc,WAAW,IAAI,sBAAsB;AACzD,QAAM,UAAU,MAAM,kBAAkB,WAAW;AACnD,SAAO;AAEP,iBAAe,kBAAkBA,cAAaC,WAAU,CAAC,GAAG;AAC1D,UAAM,CAAC,YAAY,GAAG,IAAI,IAAID;AAE9B,QAAI,eAAe,QAAW;AAC5B,aAAOC,SAAQ,KAAK;AAAA,IACtB;AAEA,UAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;AAC9C,WAAO,kBAAkB,MAAM,CAAC,GAAGA,UAAS,MAAM,CAAC;AAAA,EACrD;AAEA,WAAS,uBAAuB,MAAM;AACpC,QAAI,WAAW,IAAI,GAAG;AAEpB,aAAO,WAAW,IAAI;AAAA,IACxB;AAEA,UAAM,IAAI,MAAM,wBAAwB,IAAI,EAAE;AAAA,EAChD;AACF;",
|
|
6
|
+
"names": ["qExtractors", "results"]
|
|
7
|
+
}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import yargs from "yargs";
|
|
3
|
+
import createMatchOperator, { candidateSearch, matchDetection } from "./index.js";
|
|
4
|
+
import createDebugLogger from "debug";
|
|
5
|
+
import { MarcRecord } from "@natlibfi/marc-record";
|
|
6
|
+
cli();
|
|
7
|
+
async function cli() {
|
|
8
|
+
const debug = createDebugLogger("@natlibfi/melinda-record-matching:cli");
|
|
9
|
+
const args = yargs(process.argv.slice(2)).scriptName("melinda-record-matching-js").epilog("Copyright (C) 2022-2023 University Of Helsinki (The National Library Of Finland)").usage("$0 <file> [options] and env variable info in README").usage("Installed globally: $0 <file> [options] and env variable info in README").usage("Not installed: npx $0 <file> [options] and env variable info in README").usage("Build from source: node dist/index.js <file> [options] and env variable info in README").showHelpOnFail(true).example([["$ node /dist/cli.js record.json"]]).env("MELINDA_RECORD_MATCH").version().positional("file", { type: "string", describe: "Json file of records to match" }).options({
|
|
10
|
+
t: { type: "string", default: "IDS", alias: "searchType", describe: "IDS, STANDARD_IDS, COMPONENT, CONTENT or CONTENTALT" },
|
|
11
|
+
m: { type: "number", default: 1, alias: "maxMatches", describe: "" },
|
|
12
|
+
c: { type: "number", default: 1e3, alias: "maxCandidates", describe: "" },
|
|
13
|
+
s: { type: "boolean", default: false, alias: "returnStrategy", describe: "" },
|
|
14
|
+
q: { type: "boolean", default: false, alias: "returnQuery", describe: "" },
|
|
15
|
+
n: { type: "boolean", default: false, alias: "returnNonMatches", describe: "" }
|
|
16
|
+
}).check((args2) => {
|
|
17
|
+
const [file2] = args2._;
|
|
18
|
+
if (file2 === void 0) {
|
|
19
|
+
throw new Error("No file argument given");
|
|
20
|
+
}
|
|
21
|
+
if (!fs.existsSync(file2)) {
|
|
22
|
+
throw new Error(`File ${file2} does not exist`);
|
|
23
|
+
}
|
|
24
|
+
if (args2.sruUrl === void 0) {
|
|
25
|
+
throw new Error("Setup sru url");
|
|
26
|
+
}
|
|
27
|
+
if (!["IDS", "STANDARD_IDS", "COMPONENT", "CONTENT", "CONTENTALT"].includes(args2.searchType)) {
|
|
28
|
+
throw new Error("Invalid search type");
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}).parseSync();
|
|
32
|
+
const [file] = args._;
|
|
33
|
+
const { searchType } = args;
|
|
34
|
+
debug(JSON.stringify(args));
|
|
35
|
+
const detection = {
|
|
36
|
+
treshold: 0.9,
|
|
37
|
+
strategy: generateStrategy(searchType)
|
|
38
|
+
};
|
|
39
|
+
const search = {
|
|
40
|
+
url: args.sruUrl,
|
|
41
|
+
searchSpec: generateSearchSpec(searchType)
|
|
42
|
+
};
|
|
43
|
+
const matchOperator = await createMatchOperator({ detection, search, ...args });
|
|
44
|
+
const fileRaw = fs.readFileSync(file, "utf8");
|
|
45
|
+
const record = new MarcRecord(JSON.parse(fileRaw), { subfieldValues: false });
|
|
46
|
+
const result = await matchOperator({ record });
|
|
47
|
+
debug(JSON.stringify(result));
|
|
48
|
+
function generateStrategy(searchType2) {
|
|
49
|
+
if (["IDS"].includes(searchType2)) {
|
|
50
|
+
return [
|
|
51
|
+
matchDetection.features.bib.melindaId(),
|
|
52
|
+
matchDetection.features.bib.allSourceIds()
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
if (["STANDARD_IDS"].includes(searchType2)) {
|
|
56
|
+
return [
|
|
57
|
+
matchDetection.features.bib.hostComponent(),
|
|
58
|
+
matchDetection.features.bib.isbn(),
|
|
59
|
+
matchDetection.features.bib.issn(),
|
|
60
|
+
matchDetection.features.bib.otherStandardIdentifier(),
|
|
61
|
+
// Let's not use the same title matchDetection here
|
|
62
|
+
//matchDetection.features.bib.title(),
|
|
63
|
+
matchDetection.features.bib.authors(),
|
|
64
|
+
// We probably should have some leeway here for notated music as BK etc.
|
|
65
|
+
matchDetection.features.bib.recordType(),
|
|
66
|
+
// Use publicationTimeAllowConsYearsMulti to
|
|
67
|
+
// - ignore one year differences in publicationTime
|
|
68
|
+
// - extract publicationTimes from f008, f26x and reprint notes in f500
|
|
69
|
+
// - do not substract points for mismatching (normal) publicationTime, if there's a match between
|
|
70
|
+
// normal publicationTime and a reprintPublication time
|
|
71
|
+
matchDetection.features.bib.publicationTimeAllowConsYearsMulti(),
|
|
72
|
+
matchDetection.features.bib.language(),
|
|
73
|
+
matchDetection.features.bib.bibliographicLevel()
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
if (["COMPONENT"].includes(searchType2)) {
|
|
77
|
+
return [
|
|
78
|
+
matchDetection.features.bib.hostComponent(),
|
|
79
|
+
matchDetection.features.bib.otherStandardIdentifier(),
|
|
80
|
+
matchDetection.features.bib.recordType(),
|
|
81
|
+
matchDetection.features.bib.title(),
|
|
82
|
+
matchDetection.features.bib.language(),
|
|
83
|
+
matchDetection.features.bib.authors(),
|
|
84
|
+
matchDetection.features.bib.bibliographicLevel()
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
if (["CONTENT", "CONTENTALT"].includes(searchType2)) {
|
|
88
|
+
return [
|
|
89
|
+
matchDetection.features.bib.hostComponent(),
|
|
90
|
+
matchDetection.features.bib.isbn(),
|
|
91
|
+
matchDetection.features.bib.issn(),
|
|
92
|
+
matchDetection.features.bib.otherStandardIdentifier(),
|
|
93
|
+
matchDetection.features.bib.title(),
|
|
94
|
+
matchDetection.features.bib.authors(),
|
|
95
|
+
matchDetection.features.bib.recordType(),
|
|
96
|
+
matchDetection.features.bib.publicationTime(),
|
|
97
|
+
matchDetection.features.bib.language(),
|
|
98
|
+
matchDetection.features.bib.bibliographicLevel()
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
throw new Error("Unsupported match validation package");
|
|
102
|
+
}
|
|
103
|
+
function generateSearchSpec(searchType2) {
|
|
104
|
+
if (["IDS"].includes(searchType2)) {
|
|
105
|
+
return [
|
|
106
|
+
candidateSearch.searchTypes.bib.melindaId,
|
|
107
|
+
candidateSearch.searchTypes.bib.sourceIds
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
if (["STANDARD_IDS"].includes(searchType2)) {
|
|
111
|
+
return [candidateSearch.searchTypes.bib.standardIdentifiers];
|
|
112
|
+
}
|
|
113
|
+
if (["COMPONENT"].includes(searchType2)) {
|
|
114
|
+
return [
|
|
115
|
+
//candidateSearch.searchTypes.bib.sourceIds,
|
|
116
|
+
candidateSearch.searchTypes.component.hostIdMelinda,
|
|
117
|
+
candidateSearch.searchTypes.component.hostIdOtherSource
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
if (["CONTENT"].includes(searchType2)) {
|
|
121
|
+
return [
|
|
122
|
+
candidateSearch.searchTypes.bib.hostComponents,
|
|
123
|
+
//candidateSearch.searchTypes.bib.titleAuthor,
|
|
124
|
+
candidateSearch.searchTypes.bib.title
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
if (["CONTENTALT"].includes(searchType2)) {
|
|
128
|
+
return [
|
|
129
|
+
candidateSearch.searchTypes.bib.hostComponents,
|
|
130
|
+
// titleAuthorYearAlternates searches for matchCandidates
|
|
131
|
+
// with alternate queries, starting from more tight searches
|
|
132
|
+
candidateSearch.searchTypes.bib.titleAuthorYearAlternates
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
throw new Error("Unsupported match validation package");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli.js"],
|
|
4
|
+
"sourcesContent": ["import fs from 'fs';\nimport yargs from 'yargs';\nimport createMatchOperator, {candidateSearch, matchDetection} from './index.js';\nimport createDebugLogger from 'debug';\nimport {MarcRecord} from '@natlibfi/marc-record';\n\ncli();\n\nasync function cli() {\n const debug = createDebugLogger('@natlibfi/melinda-record-matching:cli');\n const args = yargs(process.argv.slice(2))\n .scriptName('melinda-record-matching-js')\n .epilog('Copyright (C) 2022-2023 University Of Helsinki (The National Library Of Finland)')\n .usage('$0 <file> [options] and env variable info in README')\n .usage('Installed globally: $0 <file> [options] and env variable info in README')\n .usage('Not installed: npx $0 <file> [options] and env variable info in README')\n .usage('Build from source: node dist/index.js <file> [options] and env variable info in README')\n .showHelpOnFail(true)\n .example([['$ node /dist/cli.js record.json']])\n .env('MELINDA_RECORD_MATCH')\n .version()\n .positional('file', {type: 'string', describe: 'Json file of records to match'})\n .options({\n t: {type: 'string', default: 'IDS', alias: 'searchType', describe: 'IDS, STANDARD_IDS, COMPONENT, CONTENT or CONTENTALT'},\n m: {type: 'number', default: 1, alias: 'maxMatches', describe: ''},\n c: {type: 'number', default: 1000, alias: 'maxCandidates', describe: ''},\n s: {type: 'boolean', default: false, alias: 'returnStrategy', describe: ''},\n q: {type: 'boolean', default: false, alias: 'returnQuery', describe: ''},\n n: {type: 'boolean', default: false, alias: 'returnNonMatches', describe: ''}\n })\n .check((args) => {\n const [file] = args._;\n if (file === undefined) {\n throw new Error('No file argument given');\n }\n\n if (!fs.existsSync(file)) {\n throw new Error(`File ${file} does not exist`);\n }\n\n if (args.sruUrl === undefined) {\n throw new Error('Setup sru url');\n }\n\n if (!['IDS', 'STANDARD_IDS', 'COMPONENT', 'CONTENT', 'CONTENTALT'].includes(args.searchType)) {\n throw new Error('Invalid search type');\n }\n\n return true;\n })\n .parseSync();\n\n const [file] = args._;\n const {searchType} = args;\n debug(JSON.stringify(args));\n\n const detection = {\n treshold: 0.9,\n strategy: generateStrategy(searchType)\n };\n\n const search = {\n url: args.sruUrl, searchSpec: generateSearchSpec(searchType)\n };\n\n const matchOperator = await createMatchOperator({detection, search, ...args});\n\n const fileRaw = fs.readFileSync(file, 'utf8');\n const record = new MarcRecord(JSON.parse(fileRaw), {subfieldValues: false});\n\n const result = await matchOperator({record});\n debug(JSON.stringify(result));\n\n\n function generateStrategy(searchType) {\n if (['IDS'].includes(searchType)) {\n return [\n matchDetection.features.bib.melindaId(),\n matchDetection.features.bib.allSourceIds()\n ];\n }\n\n // We could have differing strategy for STANDARD_IDS\n // Let's not run title in strategy when we found the candidates through standard_ids search\n\n if (['STANDARD_IDS'].includes(searchType)) {\n return [\n matchDetection.features.bib.hostComponent(),\n matchDetection.features.bib.isbn(),\n matchDetection.features.bib.issn(),\n matchDetection.features.bib.otherStandardIdentifier(),\n // Let's not use the same title matchDetection here\n //matchDetection.features.bib.title(),\n matchDetection.features.bib.authors(),\n // We probably should have some leeway here for notated music as BK etc.\n matchDetection.features.bib.recordType(),\n // Use publicationTimeAllowConsYearsMulti to\n // - ignore one year differences in publicationTime\n // - extract publicationTimes from f008, f26x and reprint notes in f500\n // - do not substract points for mismatching (normal) publicationTime, if there's a match between\n // normal publicationTime and a reprintPublication time\n matchDetection.features.bib.publicationTimeAllowConsYearsMulti(),\n matchDetection.features.bib.language(),\n matchDetection.features.bib.bibliographicLevel()\n ];\n }\n\n if (['COMPONENT'].includes(searchType)) {\n return [\n matchDetection.features.bib.hostComponent(),\n matchDetection.features.bib.otherStandardIdentifier(),\n matchDetection.features.bib.recordType(),\n matchDetection.features.bib.title(),\n matchDetection.features.bib.language(),\n matchDetection.features.bib.authors(),\n matchDetection.features.bib.bibliographicLevel()\n ];\n }\n\n if (['CONTENT', 'CONTENTALT'].includes(searchType)) {\n return [\n matchDetection.features.bib.hostComponent(),\n matchDetection.features.bib.isbn(),\n matchDetection.features.bib.issn(),\n matchDetection.features.bib.otherStandardIdentifier(),\n matchDetection.features.bib.title(),\n matchDetection.features.bib.authors(),\n matchDetection.features.bib.recordType(),\n matchDetection.features.bib.publicationTime(),\n matchDetection.features.bib.language(),\n matchDetection.features.bib.bibliographicLevel()\n ];\n }\n\n throw new Error('Unsupported match validation package');\n }\n\n\n function generateSearchSpec(searchType) {\n if (['IDS'].includes(searchType)) {\n return [\n candidateSearch.searchTypes.bib.melindaId,\n candidateSearch.searchTypes.bib.sourceIds\n ];\n }\n\n if (['STANDARD_IDS'].includes(searchType)) {\n return [candidateSearch.searchTypes.bib.standardIdentifiers];\n }\n\n if (['COMPONENT'].includes(searchType)) {\n return [\n //candidateSearch.searchTypes.bib.sourceIds,\n candidateSearch.searchTypes.component.hostIdMelinda,\n candidateSearch.searchTypes.component.hostIdOtherSource\n ];\n }\n\n if (['CONTENT'].includes(searchType)) {\n return [\n candidateSearch.searchTypes.bib.hostComponents,\n //candidateSearch.searchTypes.bib.titleAuthor,\n candidateSearch.searchTypes.bib.title\n ];\n }\n if (['CONTENTALT'].includes(searchType)) {\n return [\n candidateSearch.searchTypes.bib.hostComponents,\n // titleAuthorYearAlternates searches for matchCandidates\n // with alternate queries, starting from more tight searches\n candidateSearch.searchTypes.bib.titleAuthorYearAlternates\n ];\n }\n\n throw new Error('Unsupported match validation package');\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,WAAW;AAClB,OAAO,uBAAsB,iBAAiB,sBAAqB;AACnE,OAAO,uBAAuB;AAC9B,SAAQ,kBAAiB;AAEzB,IAAI;AAEJ,eAAe,MAAM;AACnB,QAAM,QAAQ,kBAAkB,uCAAuC;AACvE,QAAM,OAAO,MAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,EACrC,WAAW,4BAA4B,EACvC,OAAO,kFAAkF,EACzF,MAAM,qDAAqD,EAC3D,MAAM,yEAAyE,EAC/E,MAAM,wEAAwE,EAC9E,MAAM,wFAAwF,EAC9F,eAAe,IAAI,EACnB,QAAQ,CAAC,CAAC,iCAAiC,CAAC,CAAC,EAC7C,IAAI,sBAAsB,EAC1B,QAAQ,EACR,WAAW,QAAQ,EAAC,MAAM,UAAU,UAAU,gCAA+B,CAAC,E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