Primo: Fix tests, update regex, and lint (#2116)

Co-authored-by: Sebastian Karcher <karcher@u.northwestern.edu>
Co-authored-by: Abe Jellinek <jellinek@berkeley.edu>
这个提交包含在:
Ohad Kimhy 2021-06-14 20:00:11 +03:00 提交者 GitHub
父节点 f04d53c1c4
当前提交 3839229a71
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 3 个文件被更改,包括 141 次插入225 次删除

查看文件

@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2018-06-14 05:49:37"
"lastUpdated": "2020-10-18 08:33:02"
}
/*
@ -99,48 +99,93 @@ function scrape(doc, pnxurl) {
var testCases = [
{
"type": "web",
"url": "https://primo-qa.hosted.exlibrisgroup.com/primo-explore/search?query=any,contains,zotero&tab=everything&search_scope=TCCDALMA_EVERYTHING&vid=TCCDALMA&lang=en_US&offset=0",
"items": "multiple"
},
{
"type": "web",
"url": "https://primo-qa.hosted.exlibrisgroup.com/primo-explore/fulldisplay?vid=TCCDALMA&search_scope=TCCDALMA_EVERYTHING&tab=everything&docid=TCCD_ALMA2136169630001641&lang=en_US&context=L&adaptor=Local%20Search%20Engine&isFrbr=true&query=any,contains,adam%20smith&sortby=rank&offset=0",
"items": "multiple"
},
{
"type": "web",
"url": "https://primo-qa.hosted.exlibrisgroup.com/primo-explore/search?query=any,contains,mannheim&tab=everything&search_scope=TCCDALMA_EVERYTHING&vid=TCCDALMA&sortby=rank&lang=en_US",
"items": "multiple"
},
{
"type": "web",
"url": "http://primo-demo.exlibrisgroup.com:1701/primo-explore/fulldisplay?docid=TN_gvrl_refCX4183000563&context=PC&vid=NORTH&search_scope=PC&tab=articles&lang=en_US",
"url": "http://virtuose.uqam.ca/primo-explore/fulldisplay?vid=UQAM&docid=UQAM_BIB000969205&context=L",
"defer": true,
"items": [
{
"itemType": "encyclopediaArticle",
"title": "Water",
"creators": [],
"date": "2012",
"ISBN": "9781452218557",
"itemType": "book",
"title": "War",
"creators": [
{
"lastName": "Baynes",
"firstName": "Ken",
"creatorType": "author"
},
{
"firstName": "Ken",
"lastName": "Baynes",
"creatorType": "author"
},
{
"lastName": "Welsh Arts Council",
"creatorType": "contributor",
"fieldMode": 1
},
{
"lastName": "Glynn Vivian Art Gallery",
"creatorType": "contributor",
"fieldMode": 1
}
],
"date": "1970",
"callNumber": "NX650G8B38",
"language": "eng",
"libraryCatalog": "primo-demo.exlibrisgroup.com:1701",
"pages": "1775–1778",
"libraryCatalog": "virtuose.uqam.ca",
"place": "Boston",
"publisher": "Book and Art Chop",
"series": "Art and society 1",
"attachments": [],
"tags": [
{
"tag": "Drinking Water"
"tag": "ART; GUERRE; WAR"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://bcujas-catalogue.univ-paris1.fr/primo-explore/fulldisplay?vid=CUJAS_V1&docid=33CUJAS_ALEPH000070200&context=L&search_scope=LSCOP_ALL",
"defer": true,
"items": [
{
"itemType": "book",
"title": "Test pattern for living",
"creators": [
{
"firstName": "Nicholas",
"lastName": "Johnson",
"creatorType": "author"
}
],
"date": "1972",
"callNumber": "203.206",
"language": "eng",
"libraryCatalog": "bcujas-catalogue.univ-paris1.fr",
"numPages": "xx+154",
"place": "Toronto New York",
"publisher": "Bantam Books",
"attachments": [],
"tags": [
{
"tag": "Mass media"
},
{
"tag": "Fresh Water"
"tag": "Social aspects"
},
{
"tag": "Residential Water Supply"
"tag": "United States"
},
{
"tag": "Water Distribution"
"tag": "United States"
},
{
"tag": "Water Treatment"
"tag": "Social conditions"
},
{
"tag": "1960-"
}
],
"notes": [],

查看文件

@ -11,7 +11,7 @@
},
"inRepository": true,
"translatorType": 1,
"lastUpdated": "2020-11-11 21:49:51"
"lastUpdated": "2021-06-14 16:53:01"
}
/*
@ -50,13 +50,13 @@ function doImport() {
p: 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib',
sear: 'http://www.exlibrisgroup.com/xsd/jaguar/search'
};
var item = new Zotero.Item();
var itemType = ZU.xpathText(doc, '//p:display/p:type', ns) || ZU.xpathText(doc, '//p:facets/p:rsrctype', ns) || ZU.xpathText(doc, '//p:search/p:rsrctype', ns);
if (!itemType) {
throw new Error('Could not locate item type');
}
switch (itemType.toLowerCase()) {
case 'book':
case 'ebook':
@ -121,7 +121,7 @@ function doImport() {
}
}
}
item.title = ZU.xpathText(doc, '//p:display/p:title', ns);
if (item.title) {
item.title = ZU.unescapeHTML(item.title);
@ -134,7 +134,7 @@ function doImport() {
creators = contributors;
contributors = [];
}
// //addata/au is great because it lists authors in last, first format,
// but it can also have a bunch of junk. We'll use it to help split authors
var splitGuidance = {};
@ -192,15 +192,15 @@ function doImport() {
item.date = m[0];
}
}
// the three letter ISO codes that should be in the language field work well:
item.language = ZU.xpathText(doc, '(//p:display/p:language|//p:facets/p:language)[1]', ns);
var pages = ZU.xpathText(doc, '//p:display/p:format', ns);
if (item.itemType == 'book' && pages && pages.search(/\d/) != -1) {
item.numPages = extractNumPages(pages);
}
item.series = ZU.xpathText(doc, '(//p:addata/p:seriestitle)[1]', ns);
if (item.series) {
let m = item.series.match(/^(.*);\s*(\d+)/);
@ -215,11 +215,11 @@ function doImport() {
if (isbn) {
item.ISBN = ZU.cleanISBN(isbn);
}
if (issn) {
item.ISSN = ZU.cleanISSN(issn);
}
// Try this if we can't find an isbn/issn in addata
// The identifier field is supposed to have standardized format, but
// the super-tolerant idCheck should be better than a regex.
@ -231,7 +231,7 @@ function doImport() {
}
item.edition = ZU.xpathText(doc, '//p:display/p:edition', ns);
var subjects = ZU.xpath(doc, '//p:display/p:subject', ns);
if (!subjects.length) {
subjects = ZU.xpath(doc, '//p:search/p:subject', ns);
@ -240,15 +240,15 @@ function doImport() {
for (let i = 0, n = subjects.length; i < n; i++) {
let tagChain = ZU.trimInternal(subjects[i].textContent);
// Split chain of tags, e.g. "Deutschland / Gerichtsverhandlung / Schallaufzeichnung / Bildaufzeichnung"
for (let tag of tagChain.split(/ (?:\/|--) /)) {
for (let tag of tagChain.split(/ (?:\/|--|;) /)) {
item.tags.push(tag);
}
}
item.abstractNote = ZU.xpathText(doc, '//p:display/p:description', ns)
|| ZU.xpathText(doc, '//p:addata/p:abstract', ns);
if (item.abstractNote) item.abstractNote = ZU.unescapeHTML(item.abstractNote);
item.DOI = ZU.xpathText(doc, '//p:addata/p:doi', ns);
item.issue = ZU.xpathText(doc, '//p:addata/p:issue', ns);
item.volume = ZU.xpathText(doc, '//p:addata/p:volume', ns);
@ -276,7 +276,7 @@ function doImport() {
else if (endPage) {
item.pages = endPage;
}
// these are actual local full text links (e.g. to google-scanned books)
// e.g http://solo.bodleian.ox.ac.uk/OXVU1:LSCOP_OX:oxfaleph013370702
var URL = ZU.xpathText(doc, '//p:links/p:linktorsrc', ns);
@ -349,10 +349,10 @@ function stripAuthor(str) {
// e.g. Wheaton, Barbara Ketcham [former owner]$$QWheaton, Barbara Ketcham
str = str.replace(/^(.*)\$\$Q(.*)$/, "$2");
return str
// Remove year
.replace(/\s*,?\s*\(?\d{4}-?(\d{4})?\)?/g, '')
// Remove things like (illustrator). TODO: use this to assign creator type?
.replace(/\s*,?\s*[[(][^()]*[\])]$/, '')
// Remove year
.replace(/\s*,?\s*\(?\d{4}-?(\d{4}|\.{3})?\)?/g, '')
// Remove creator type like (illustrator)
.replace(/(\s*,?\s*[[(][^()]*[\])])+$/, '')
// The full "continuous" name uses no separators, which need be removed
// cf. "Luc, Jean André : de (1727-1817)"
.replace(/\s*:\s+/, " ");
@ -368,11 +368,12 @@ function fetchCreators(item, creators, type, splitGuidance) {
type,
true
);
if (!c.firstName) {
delete c.firstName;
c.fieldMode = 1;
}
item.creators.push(c);
}
}
@ -443,10 +444,10 @@ var testCases = [
"attachments": [],
"tags": [
{
"tag": "Chemistry"
"tag": "Water"
},
{
"tag": "Water"
"tag": "Chemistry"
}
],
"notes": [],
@ -548,47 +549,38 @@ var testCases = [
"seriesNumber": "138",
"attachments": [],
"tags": [
{
"tag": "Bildaufzeichnung"
},
{
"tag": "Conduct of court proceedings"
},
{
"tag": "Deutschland"
"tag": "Germany"
},
{
"tag": "Constitutional law"
},
{
"tag": "Freedom of information"
},
{
"tag": "Deutschland"
},
{
"tag": "Deutschland"
},
{
"tag": "Elektronische Medien"
},
{
"tag": "Gerichtsberichterstattung"
},
{
"tag": "Gerichtsverhandlung"
},
{
"tag": "Germany; Constitutional law"
},
{
"tag": "Germany; Freedom of information"
},
{
"tag": "Germany; Hochschulschrift"
},
{
"tag": "Informationsfreiheit"
"tag": "Hochschulschrift"
},
{
"tag": "Rechtsprechende Gewalt"
},
{
"tag": "Schallaufzeichnung"
"tag": "Öffentlichkeitsgrundsatz"
},
{
"tag": "Informationsfreiheit"
},
{
"tag": "Gerichtsberichterstattung"
},
{
"tag": "Elektronische Medien"
},
{
"tag": "Verbot"
@ -597,7 +589,13 @@ var testCases = [
"tag": "Verfassungsmäßigkeit"
},
{
"tag": "Öffentlichkeitsgrundsatz"
"tag": "Gerichtsverhandlung"
},
{
"tag": "Schallaufzeichnung"
},
{
"tag": "Bildaufzeichnung"
}
],
"notes": [],

165
Primo.js
查看文件

@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsbv",
"lastUpdated": "2019-03-26 01:29:32"
"lastUpdated": "2020-02-04 01:29:32"
}
/*
@ -207,7 +207,7 @@ function fetchPNX(itemData) {
gotPNX = true;
PNXUrlGenerator.confirmed = true;
}
importPNX(text, url);
},
function () {
@ -250,7 +250,7 @@ var testCases = [
"title": "China and foreign missionaries.",
"creators": [
{
"lastName": "Great Britain. Foreign Office",
"lastName": "Great Britain Foreign Office",
"creatorType": "author",
"fieldMode": 1
}
@ -260,111 +260,31 @@ var testCases = [
"language": "eng",
"libraryCatalog": "princeton-primo.com",
"place": "London",
"publisher": "London 1860-1912",
"publisher": "1860-1912",
"attachments": [],
"tags": [
"China Foreign relations Great Britain.",
"China Religion.",
"Great Britain Foreign relations China.",
"Missions China."
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://virtuose.uqam.ca/primo_library/libweb/action/dlDisplay.do?vid=UQAM&docId=UQAM_BIB000969205&fn=permalink",
"items": [
{
"itemType": "book",
"title": "War",
"creators": [
{
"firstName": "Ken",
"lastName": "Baynes",
"creatorType": "author"
"tag": "China"
},
{
"lastName": "Welsh Arts Council",
"creatorType": "contributor",
"fieldMode": 1
"tag": "China; China"
},
{
"lastName": "Glynn Vivian Art Gallery",
"creatorType": "contributor",
"fieldMode": 1
"tag": "Foreign relations"
},
{
"tag": "Foreign relations"
},
{
"tag": "Great Britain; Great Britain"
},
{
"tag": "Missions"
},
{
"tag": "Religion; China"
}
],
"date": "1970",
"callNumber": "NX650G8B38",
"language": "eng",
"libraryCatalog": "virtuose.uqam.ca",
"place": "Boston",
"publisher": "Boston Book and Art Chop",
"series": "Art and society 1",
"attachments": [],
"tags": [
"ART",
"GUERRE",
"WAR"
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://primo-prod.u-paris10.fr/primo_library/libweb/action/dlDisplay.do?vid=UPON&search_scope=default_scope&docId=SCD_ALEPH000546633&fn=permalink",
"items": [
{
"itemType": "thesis",
"title": "Les espaces publics au prisme de l'art à Johannesburg (Afrique du Sud) : quand la ville fait œuvre d'art et l'art œuvre de ville",
"creators": [
{
"firstName": "Pauline",
"lastName": "Guinard",
"creatorType": "author"
},
{
"firstName": "Philippe )",
"lastName": "Gervais-Lambony",
"creatorType": "contributor"
},
{
"lastName": "Université Paris Ouest Nanterre La Défense",
"creatorType": "contributor",
"fieldMode": 1
},
{
"firstName": "cultures et sociétés du passé et du présent Nanterre",
"lastName": "Ecole doctorale Milieux",
"creatorType": "contributor"
}
],
"date": "2012",
"abstractNote": "Thèse de doctorat, Cette thèse porte sur les espaces publics à Johannesburg, capitale économique de l’Afrique du Sud. Dans le contexte contemporain, l’utilisation de la notion occidentale d’espaces publics pose problème : d’une part, du fait des ségrégations passées qui ont eu tendance à faire de ces espaces des lieux de séparation et de mise à distance des différents publics ; et d’autre part, du fait des forts taux de violence et du fort sentiment d’insécurité, qui tendent à encourager la sécurisation et la privatisation de ces mêmes espaces. L’enjeu est alors de comprendre les éventuels processus de construction de la publicité (au sens de caractère public) de ces espaces, à la fois sur le plan juridique, social et politique. Pour ce faire, l’art qui se déploie dans les espaces juridiquement publics de la métropole depuis la fin de l’apartheid, est utilisé comme une clef de lecture privilégiée de ces phénomènes, en tant qu’il permettrait, ainsi que nous entendons le montrer, de créer des espaces de rencontre et de débats ou, à l’inverse, de mieux réguler et contrôler ces espaces. Selon une approche qualitative, notre étude se base à la fois sur des observations de terrain et sur des entretiens conduits auprès des producteurs mais aussi des récepteurs de cet art qui a lieu dans les espaces publics. A la croisée de la géographie urbaine et de la géographie culturelle, nous envisageons donc de réexaminer la notion d’espaces publics au prisme de l’art à Johannesburg en vue de saisir – entre tentative de normalisation et résistance à cette normalisation – quelle ville est aujourd’hui à l’œuvre non seulement à Johannesburg, mais aussi, à travers elle, dans d’autres villes du monde., This Ph.D. thesis deals with public spaces in Johannesburg, the economic capital of South Africa. In the current context, the issues raised by the use of the western notion of public spaces are explored. On one hand, the previous segregations tended to mark off spaces into different publics completely separated from each other. On the other hand, the high rates of violence and sense of insecurity enhance securitization and privatization of these same spaces. What is at stake is to understand how the publicness of these spaces can be legally, socially, and politically built. In that framework, art spread in legally public spaces of Johannesburg since the end of apartheid is used as a tool to understand and reveal these phenomena since it is presented, as we aim at demonstrating, as a mean to create spaces of encounter and debate or, conversely, to regulate and control better these spaces. In a qualitative approach, our study is based on field observations and interviews with both producers and receivers of this art which takes place in public spaces. At the crossroads of urban geography and cultural geography, we are therefore re-examining the concept of public spaces through the prism of art in Johannesburg to figure out – between normalization and resistance to this normalization – which city is today at work not only in Johannesburg, but also, through her, in other cities of the world.",
"language": "fre",
"libraryCatalog": "Primo",
"place": "Sl",
"shortTitle": "Les espaces publics au prisme de l'art à Johannesburg (Afrique du Sud)",
"university": "sn",
"attachments": [],
"tags": [
"Art",
"Art urbain -- Thèses et écrits académiques -- Afrique du Sud -- Johannesburg (Afrique du Sud)",
"Espaces publics -- Normalisation -- Thèses et écrits académiques",
"Espaces publics -- Thèses et écrits académiques -- Afrique du Sud -- Johannesburg (Afrique du Sud)",
"Géographie culturelle -- Thèses et écrits académiques",
"Géographie urbaine -- Thèses et écrits académiques",
"Johannesburg",
"Johannesburg (Afrique du Sud) -- Thèses et écrits académiques -- Afrique du Sud",
"Normalisation",
"Prisme",
"Publicisation"
],
"notes": [],
"seeAlso": []
}
@ -397,53 +317,6 @@ var testCases = [
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://bcujas-catalogue.univ-paris1.fr/CUJAS_V1:LSCOP_ALL:33CUJAS_ALEPH000070200",
"items": [
{
"itemType": "book",
"title": "Test pattern for living",
"creators": [
{
"firstName": "Nicholas",
"lastName": "Johnson",
"creatorType": "author"
}
],
"date": "1972",
"callNumber": "203.206",
"language": "eng",
"libraryCatalog": "bcujas-catalogue.univ-paris1.fr",
"numPages": "xx+154",
"place": "Toronto New York",
"publisher": "Bantam Books",
"attachments": [],
"tags": [
{
"tag": "301.16/1/0973"
},
{
"tag": "Mass media"
},
{
"tag": "Mass media -- Social aspects -- United States"
},
{
"tag": "Social aspects"
},
{
"tag": "United States"
},
{
"tag": "United States -- Social conditions -- 1960-"
}
],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/