-
Notifications
You must be signed in to change notification settings - Fork 770
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
[Zenodo] Prevent mis-importing software as report #1578
Conversation
How are you generating the tests in Scaffold? This is fine now, but to save you the work going forward, if you actually generate the test using the Scaffold testing panel, you won't get the + and - (which are from a diff display Scaffold shows). |
Zenodo.js
Outdated
@@ -195,6 +195,11 @@ function scrape(doc, url) { | |||
|
|||
if (item.itemType == "document" && zoteroType[type]) { | |||
item.itemType = zoteroType[type]; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would happen if we replace this whole thing, including l. 197 by item.itemType = detectWeb(doc, url)
That seems like a cleaner solution, provided our detect function is good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the var zoteroType
block be removed as well, then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly, yes
The Zenodo item types in the CSL are fine -- they are as good as it gets for e.g. automated citation generation directly from the CSL and Zotero can customize at will in the import. For the names, we can't really parse these correctly without breaking institutional names since they're entered incorrectly in Zenodo, but we can switch fieldMode to true along the lines for
This makes them easier to fix manually. |
Zenodo.js
Outdated
@@ -175,6 +175,7 @@ function scrape(doc, url) { | |||
if (!item.creators[i].firstName && item.creators[i].lastName.indexOf(",")!=-1) { | |||
item.creators[i].firstName = item.creators[i].lastName.replace(/.+?,\s*/, ""); | |||
item.creators[i].lastName = item.creators[i].lastName.replace(/,.+/, ""); | |||
item.creators[i].fieldMode = true; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work? No changes in the test cases??
I think what we want is rather want is:
if (!item.creators[i].firstName) {
if (item.creators[i].lastName.indexOf(",")!=-1) {
item.creators[i].firstName = item.creators[i].lastName.replace(/.+?,\s*/, "");
item.creators[i].lastName = item.creators[i].lastName.replace(/,.+/, "");
} else {
item.creators[i].fieldMode = true;
}
}
|
||
if (item.itemType == "document" && zoteroType[type]) { | ||
item.itemType = zoteroType[type]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delete the first introduction of the variable type
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the latter one seems not necessarily anymore. We certainly still need the first one.
Zenodo.js
Outdated
if (item.itemType == "document" && zoteroType[type]) { | ||
item.itemType = zoteroType[type]; | ||
} | ||
item.itemType = detectWeb(doc, url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add ;
at the end.
Zenodo.js
Outdated
"lastName": "Carl Boettiger" | ||
"firstName": "" | ||
"creatorType": "author" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rerun the tests should yield some fieldMode
fields.
🎉 Thank you @katrinleinweber ! |
You're welcome, and thanks for merging :-) |
As discussed in the forum this ensures that
Software
items on Zenodo are imported ascomputerProgram
, even though along the way, Zenodo is offering a non-CSL item typePotential/Remaining isues to discuss
lastName
. This could occur in https://github.com/zotero/translators/blame/master/Zenodo.js#L172-L180, but I'm not sure whether or how to adjust that. Or, should I adjust the new test case to expectlastName
andfirstName
normally?-
and+
in thedoWeb
test output (near the bottom in the diff). Not sure what those mean, but I guess both symbols need to be removed from the JSON block.