Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRewrite Encore #1482
Conversation
adam3smith
requested a review
from
zuphilip
Nov 19, 2017
zuphilip
requested changes
Nov 22, 2017
The logic inside the loop is confusing and I suggest an alternative solution. Moreover, I commented some smaller things to look at. |
"tag": "Nursing" | ||
}, | ||
{ | ||
"tag": "Nursing" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
adam3smith
Nov 23, 2017
Author
Collaborator
Look at the MARC here: http://sallypro.sandiego.edu/iii/encore/record/C__Rb1516899__Stesting__P0,2__Orightresult__U__X6?lang=eng&suite=cobalt&marcData=Y
in the 650 fields:
650 0 Nursing|xEducation
650 0 Critical thinking
650 0 Constructivism (Education)
650 0 Nursing|xDecision making
650 0 Nursing|xPhilosophy
MARC imports both parts of the field as tag -- maybe that's not right? Or we should save the category in the 0 field and check against it to avoid duplication? In any case, this is a MARC issue, I'd like to address it separately
This comment has been minimized.
This comment has been minimized.
zuphilip
Nov 23, 2017
Collaborator
Okay, I see.
Although, I thought that duplicate tags were technically not possible. At least manually I cannot enter twice the same tag.
This comment has been minimized.
This comment has been minimized.
adam3smith
Nov 24, 2017
Author
Collaborator
Turns out they only show up in the tests, not in Zotero itself.
This comment has been minimized.
This comment has been minimized.
} | ||
] | ||
"url": "http://sallypro.sandiego.edu/iii/encore/record/C__Rb1516899__Stesting__P0%2C2__Orightresult__U__X6?lang=eng&suite=cobalt", | ||
"items": [{ |
This comment has been minimized.
This comment has been minimized.
zuphilip
Nov 22, 2017
Collaborator
Did you add these tests with Scaffold? The [{
is usually on two lines...
This comment has been minimized.
This comment has been minimized.
adam3smith
Nov 23, 2017
Author
Collaborator
of course tests are from scaffold, yes. I think this was jsbeautify which I ran on the whole file.
This comment has been minimized.
This comment has been minimized.
zuphilip
Nov 23, 2017
Collaborator
Ah, okay. For test it makes IMO sense to leave the formatting as Scaffold outputs it. Otherwise this will show differences the next time someone is updating and testing the same translator.
@@ -9,15 +9,14 @@ | |||
"inRepository": true, | |||
"translatorType": 4, | |||
"browserSupport": "gcsb", | |||
"lastUpdated": "2014-08-26 03:59:48" | |||
"lastUpdated": "2017-11-19 20:03:16" |
This comment has been minimized.
This comment has been minimized.
@@ -9,15 +9,14 @@ | |||
"inRepository": true, | |||
"translatorType": 4, | |||
"browserSupport": "gcsb", |
This comment has been minimized.
This comment has been minimized.
zuphilip
Nov 22, 2017
Collaborator
Add all of them (or do you have any reasons that they should not work?).
for (var i in items) { | ||
articles.push(i); | ||
} | ||
scrape(articles) |
This comment has been minimized.
This comment has been minimized.
scrape(articles) | ||
}); | ||
} else { | ||
var marcURL = createMarcURL(url) |
This comment has been minimized.
This comment has been minimized.
var record = new marc.record(); | ||
var newItem = new Zotero.Item(); | ||
|
||
var linee = text.split("\n"); |
This comment has been minimized.
This comment has been minimized.
zuphilip
Nov 22, 2017
Collaborator
Fix typo linee
(or do I miss the point in the variable name here?).
|
||
var linee = text.split("\n"); | ||
for (var i = 0; i < linee.length; i++) { | ||
if (!linee[i]) { |
This comment has been minimized.
This comment has been minimized.
|
||
if (linee[i].substr(0, 6) == " ") { | ||
// add this onto previous value | ||
tagValue += value; |
This comment has been minimized.
This comment has been minimized.
zuphilip
Nov 22, 2017
Collaborator
This is IMO quite confusing and tagValue
is not yet initialized.
I suggest to actually clean the text before splitting into lines with something like:
// delete empty lines, delete confusing newlines, e.g.
// 245 10 Testing a theoretical model of critical thinking and
// cognitive development /|cby Jane Rapps
text = text.replace(/^\n/mg, '').replace(/\s?\n\s+/gm, ' ');
This comment has been minimized.
This comment has been minimized.
Please take a look. I switched out the test because the catalog always detects book and the old test was a thesis so tests failed (probably not worth fixing detect here) |
zuphilip
merged commit 3b08a48
into
zotero:master
Nov 25, 2017
1 check passed
This comment has been minimized.
This comment has been minimized.
Thank you very much, @adam3smith ! (I simplified the code a little and add some nits.) |
This comment has been minimized.
This comment has been minimized.
Thanks! |
adam3smith commentedNov 19, 2017
closes #1481