Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Encore #1482

Merged
merged 3 commits into from Nov 25, 2017
Merged

Rewrite Encore #1482

merged 3 commits into from Nov 25, 2017

Conversation

adam3smith
Copy link
Collaborator

closes #1481

Copy link
Contributor

@zuphilip zuphilip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have here duplicate tags?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see.

Although, I thought that duplicate tags were technically not possible. At least manually I cannot enter twice the same tag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out they only show up in the tests, not in Zotero itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

}
]
"url": "http://sallypro.sandiego.edu/iii/encore/record/C__Rb1516899__Stesting__P0%2C2__Orightresult__U__X6?lang=eng&suite=cobalt",
"items": [{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you add these tests with Scaffold? The [{ is usually on two lines...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course tests are from scaffold, yes. I think this was jsbeautify which I ran on the whole file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a rewrite we should IMO increase the minVersion also to 3.0.

@@ -9,15 +9,14 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsb",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ;

scrape(articles)
});
} else {
var marcURL = createMarcURL(url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ;

var record = new marc.record();
var newItem = new Zotero.Item();

var linee = text.split("\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add comment here, e.g. // skip empty line?


if (linee[i].substr(0, 6) == " ") {
// add this onto previous value
tagValue += value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, ' ');

@adam3smith
Copy link
Collaborator Author

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 zuphilip merged commit 3b08a48 into zotero:master Nov 25, 2017
@zuphilip
Copy link
Contributor

Thank you very much, @adam3smith ! (I simplified the code a little and add some nits.)

@adam3smith
Copy link
Collaborator Author

Thanks!

danmichaelo pushed a commit to danmichaelo/translators that referenced this pull request Nov 28, 2017
jonschz pushed a commit to jonschz/translators that referenced this pull request Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Encore Translator fails
2 participants