Duplicated citation keys

A place for users to ask each other questions, make suggestions, and discuss Bookends.
Dellu
Posts: 268
Joined: Sun Mar 27, 2016 5:30 am

Duplicated citation keys

Post by Dellu »

This problem has been bugging me for a long time.

I have three BE libraries.
BE is smart enough to keep the bibtex keys unique within a single library. But, it has no capacity to compare across libraries.
So, I am getting a lot of duplicated citation keys, and the latex compiler is constantly annoying me.


Has anyone came up with any way around this problem?

(please don't tell me to use one library; that is out of question).
DrJJWMac
Posts: 345
Joined: Sat Jun 22, 2019 8:04 am
Location: Alabama USA

Re: Duplicated citation keys

Post by DrJJWMac »

It would seem that the field Preferences->BibTex->Precede with: would offer you a chance to make each citation key in each library unique.
--
JJW
Dellu
Posts: 268
Joined: Sun Mar 27, 2016 5:30 am

Re: Duplicated citation keys

Post by Dellu »

Thank you for the suggestion dear @DrJJWMac

The most ideal situation would be provide a format like the attachment renaming format.
Preferences 2022-04-09 12-04-47.jpg
Preferences 2022-04-09 12-04-47.jpg (4.18 KiB) Viewed 2268 times
That way, I would program the format to use different patterns just like in Jabref and many other reference managers.
@Book.bib - Library properties 2022-04-09 12-25-13.jpg
@Book.bib - Library properties 2022-04-09 12-25-13.jpg (15.68 KiB) Viewed 2264 times
or, we can attach some suffixes to each reference type:

Articles would have their keys with @ suffix;
and the books would have another suffix_b,
and the collection would have _c another suffix, etc.

As every library/entry type would have different types of suffix, there would never be a cross-library duplicate.


I can currently suffix them using find and replace system, manually. I have tried that one a couple of times. But, the problem is Be cannot keep them unique once I modify them manually (and, I have no way of keeping them unique).

This task of keeping the bibtex keys unique is probably what makes the implementation of the format difficult for John as well.
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Duplicated citation keys

Post by Jon »

Using a format to generate the key would apply to all libraries, so it wouldn't necessarily help. Having said that, with a format you can output the name of the library, and if you included that in the key field it would be unique across all of your libraries. Another approach you could use now is to do a Global Change -> Change Field and insert a library-specific tag in front of or after the key Bookends generates. The downside is that you'd have to do this periodically for new references and be careful to not touch references that have already been altered.

Jon
Sonny Software
Dellu
Posts: 268
Joined: Sun Mar 27, 2016 5:30 am

Re: Duplicated citation keys

Post by Dellu »

Jon wrote: Sat Apr 09, 2022 8:21 am Another approach you could use now is to do a Global Change -> Change Field and insert a library-specific tag in front of or after the key Bookends generates. The downside is that you'd have to do this periodically for new references and be careful to not touch references that have already been altered.

Jon
Sonny Software
I have tied that one by suffixing @ on articles; to differentiate them from books and collections.
Note that I am organizing my libraries by types: articles are in one library; books are in another library etc.

The system was able protect cross-library duplication because all keys from articles would have @ suffixes. That suffix made them unique.

But, it created library-internal duplication.

Here is how the library internal duplication is created:

Assume I have two papers authored by John, published in a year 2012; and assume that i have imported them to my library last year.

When I suffixed the @ symbol, the first paper will be: John2012@ and the second one will be John2012a@ .

Now, assume that i have found another (third) paper by the same author (or, another author with same last name) published in the same year, 2012.
Now, I am importing that third paper.

Bookends will assign John2012 to that one because the first two have been renamed. Now, I am going to add @ on this new paper. It will be John2012@; which is an exact duplicate of the first paper. Since I am manually inserting suffixes, BE cannot keep the keys unique.
Last edited by Dellu on Sat Apr 09, 2022 9:28 am, edited 1 time in total.
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Duplicated citation keys

Post by Jon »

Make it a prefix, not a suffix. @ may not be the best choice because BibTeX uses it, too. Maybe something like $

$John2012
$John2012a
$John2012b

Jon
Sonny Software
Dellu
Posts: 268
Joined: Sun Mar 27, 2016 5:30 am

Re: Duplicated citation keys

Post by Dellu »

I don't think the prefix makes a difference.


First round renaming:


John2012 -- > $John2012
John2012a --> $John2012a

Second round renaming:

John2012 --> $John2012


Still, the first and the third end up being identical.
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Duplicated citation keys

Post by Jon »

You're right. I think the only way to ensure uniqueness across libraries is to create the key yourself. Building on DrJJWMac's suggestion, you can use Copy Citation to generate one for you with a format, then paste it into the key field. The format can include the database name (use !). So this format

!_a_d

might generate

Library1_John_2012

Jon
Sonny Software
Dellu
Posts: 268
Joined: Sun Mar 27, 2016 5:30 am

Re: Duplicated citation keys

Post by Dellu »

The in-library duplication will still be there so far as I am doing it manually.

1. Having a format would have been great because the format can be programmed to assign those prefixes and suffixes we want; and then, the housekeeper (the feature which makes the keys unique in the current system) will suffix the letters on those keys that end up being duplicated.

A key generator format would have ad (John2012), for example, for a journal article; and simple a_d (John_2012) for books; and a-b (John-2012) for other things, etc.


Once the format generates these keys. The house keeper will check them if they will be unique in the library. Surely, they will be unique across libraries/types because each type would have a special suffix/prefix/pattern.

2. A second alternative is to hard code the above kinds of patterns into BE (if including a format into the key generating system is difficult to program).
The current patterns is ad across the board. So, if it is not hard to program, it would be an option to include patterns into the keys:

ad = articles
a-d = books
a_d = incollection
-ad= book chapter


3. Manually fixing a key is messy and is going to be a struggle to keep up with it as the libraries grow. I don't like this. But, if we have to do manual assignment of keys, adding the key field to the Remove Duplicates tool would be a great help. Once I have searched the references with duplicate keys, I can then change the duplicated keys to sth else manually. The manual suffixation/prefixation would work with this method.


Dear @Jon, I know I have been pushing you into the latex sphere too much. I promise this will be the last feature request I will make. BE is almost perfect to me. It has been like that since you add the Bibsync feature. I cannot think of anything else to add on this app. And, it doesn't have to be now. You can think about it; and can include it probably to the next big release of BE (BE15).
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Duplicated citation keys

Post by Jon »

How would the format ensure the keys were unique between libraries? Two different libraries could generate the same key if it's simply John2012. I think you would need to include the library name in the key. Maybe you segregate libraries by reference Type? Then it would work for you, but no one else.

Jon
Sonny Software
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Duplicated citation keys

Post by Jon »

Here's a thought. What if there was an option to include the unique ID in the citekey. Like this

John2012_54243

That would be unique among all libraries.

If I were to add an option like this, via a popup menu in preferences, what other option would people like? Here are the first two I'm thinking of:

authordate
authordate_uniqueid

Jon
Sonny Software
DrJJWMac
Posts: 345
Joined: Sat Jun 22, 2019 8:04 am
Location: Alabama USA

Re: Duplicated citation keys

Post by DrJJWMac »

I vote to provide an option field for the user to format the cite key using notations.

a - first author, last name
s - second author, last name (or blank)
e - etal if more than one author
y - publication year
u - unique ID (0 + time stamp hhmm)
! - library name
[sometext] - direct use of sometext

By example

ay --> John2012
asy --> JohnSmith2012
ae_u --> Johnetal_02000
!-ay --> books-John2012
ay_[book] --> John2012_book
ay_[book]u --> John2012_book01955

Default is ay.
--
JJW
Dellu
Posts: 268
Joined: Sun Mar 27, 2016 5:30 am

Re: Duplicated citation keys

Post by Dellu »

Yes, the unique id would definitely work.


I second DrJJWMac's proposal.

If his proposal is too much to include, adding the library name is very smart solution. If anyone is not interested in suffixing the 5 digit number (the unique id) into her keys, she can assign short library names (such as B for the library for books, A for the library for the Articles etc ) and then, attach those names on the keys. That is smart and simple solution.

If including the library name is hard, I would propose the "types" to be included.

Type-authordate

a-John2012 <if the type is article
b-John2012 <for books
c-John2012 <collection/conference
i-John2010 >incollection
ib->inbook
p- > for proceeding
mt > master thesis
ph >phd
u> unpublished
m>misc

These are the standard types:
ppic-23.png
ppic-23.png (22.62 KiB) Viewed 2198 times
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Duplicated citation keys

Post by Jon »

I'm thinking of a popup menu in preferences, not using a format or creating another similar format-like mechanism. Something simple.

Jon
Sonny Software
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Duplicated citation keys

Post by Jon »

I'm going to start a new thread so that possibly affected users don't miss this.

Jon
Sonny Software
Post Reply