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

[Zenodo] Prevent mis-importing software as report #1578

Merged
merged 10 commits into from Mar 9, 2018

Conversation

Projects
None yet
3 participants
@katrinleinweber
Copy link
Contributor

katrinleinweber commented Mar 7, 2018

As discussed in the forum this ensures that Software items on Zenodo are imported as computerProgram, even though along the way, Zenodo is offering a non-CSL item type

Potential/Remaining isues to discuss

  • Scaffold imports the full author names as 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 expect lastName and firstName normally?
  • Would it be helpful, if Zenodo stopped putting a clearly mis-matching CSL type in the JSON that Zotero parses, and instead send none? If yes, could we then omit both the "fix" and this "undo"?
  • Scaffold added - and + in the doWeb 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.

katrinleinweber added some commits Mar 7, 2018

@adam3smith

This comment has been minimized.

Copy link
Collaborator

adam3smith commented Mar 7, 2018

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];

This comment has been minimized.

@adam3smith

adam3smith Mar 7, 2018

Collaborator

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.

This comment has been minimized.

@katrinleinweber

katrinleinweber Mar 7, 2018

Author Contributor

Could the var zoteroType block be removed as well, then?

This comment has been minimized.

@adam3smith

adam3smith Mar 7, 2018

Collaborator

exactly, yes

@adam3smith

This comment has been minimized.

Copy link
Collaborator

adam3smith commented Mar 7, 2018

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

for (let i =0; i< item.creators.length; i++) {
  if (!item.creators[i].firstName) {
    item.creators[i].fieldMode = true;
  }
}

This makes them easier to fix manually.

katrinleinweber added some commits Mar 7, 2018

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;
}

This comment has been minimized.

@zuphilip

zuphilip Mar 7, 2018

Collaborator

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];
}

This comment has been minimized.

@zuphilip

zuphilip Mar 7, 2018

Collaborator

Can we delete the first introduction of the variable type as well?

This comment has been minimized.

@katrinleinweber

katrinleinweber Mar 8, 2018

Author Contributor

Do you mean L42 or L133? Removing the latter indeed doesn't break the tests :-)

This comment has been minimized.

@zuphilip

zuphilip Mar 8, 2018

Collaborator

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)

This comment has been minimized.

@zuphilip

zuphilip Mar 7, 2018

Collaborator

Add ; at the end.

Zenodo.js Outdated
"lastName": "Carl Boettiger"
"firstName": ""
"creatorType": "author"
}

This comment has been minimized.

@zuphilip

zuphilip Mar 7, 2018

Collaborator

Rerun the tests should yield some fieldMode fields.

@zuphilip zuphilip merged commit 5fa9a68 into zotero:master Mar 9, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@zuphilip

This comment has been minimized.

Copy link
Collaborator

zuphilip commented Mar 9, 2018

🎉 Thank you @katrinleinweber !

@katrinleinweber

This comment has been minimized.

Copy link
Contributor Author

katrinleinweber commented Mar 9, 2018

You're welcome, and thanks for merging :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.