wshanks / Zutilo

Zotero plugin providing some additional editing features
Other
1.49k stars 70 forks source link

Feature request: Split author name to Last Name, First Name. #192

Closed tangofil closed 3 years ago

tangofil commented 3 years ago

I have many literature references that have the full author name, imported into the field Author-Last name, while Author-First name is empty. I would love to have a keyboard short cut or submeny that I can use when standing in the Author-LastName field, that would copy all except the last word, and jump to the Author-FirstName field and paste there.

An example of what I would like to do. This is what it looks now:
Author: Mary Douglas, (first) Select "Split Author" or press alt-s. Result: Author: Douglas, Mary

Now I am achieving roughly the same when importing from RIS format with a Grep command in my text editor that searches for (A1 - )(\w+.?) ([ .\ws]+)?(\<\w+s?$) and replaces it with \1\4, \2 \3 But this obviously does not work with items that have already been imported to Zotero.

Nor is this fool proof, as it does make errors with Jr., Sr., de, von, and other unusual formats, but it gets more than 90% right. And as long as "Split Author" it does not do bulk editing I can always check that the result is what I wanted. For bulk editing, it obviously would need to get more accurate. (Perhaps one of the Import Translations does have this feature already in java-script, as many of them does get the last name, first name correctly.)

tangofil commented 3 years ago

One addition to the feature would be to do this change for ALL items. There is in reality only the correct author: Douglas, Mary If I find and fix the erroneous Author: Mary Douglas, (first) with the above solution, I would love to have the fix appleid to every item. So one manual inspection would automatically fix every occurance of the same error.

wshanks commented 3 years ago

It seems like a reasonable feature. It would be good to look into what functions from Zotero could be called because there are a lot of subtleties with multiword names and it would be good not to reimplement that in Zutilo if it is already maintained somewhere else.

qqobb commented 3 years ago

@tangofil: For your first example, Author: Mary Douglas, (first), double-click the "Switch to..." button to the left of the "minus" button. This should fix the creator to Author: Douglas, Mary. (It will first "Switch to single field", then "Switch to two fields" again, but in the correct form.)

You could also try using Zotero's JavaScript API for this, see here for some examples. The creator's fieldMode would be relevant here. But I'm not sure there's a fool-proof bulk editing method, see the "Socrates" example in [2].

Zotero's documentation on creator names: [1] https://www.zotero.org/support/kb/name_parsing [2] https://www.zotero.org/support/adding_items_to_zotero#editing_items

tangofil commented 3 years ago

@qqobb Thank you! Your solution is great. I just never figured out that Zotero GUI did already have built in what I was looking for. And if my first impression is correct, it changes the same name parsing error in several items automatically! Fantastic.