-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fixes #1181: Improved "Normalize to BibTeX name format" #1470
Conversation
It shows |
The problem are always the GUI tests. It's annoying... |
@@ -36,6 +36,28 @@ public String getKey() { | |||
|
|||
@Override | |||
public String format(String value) { | |||
// Fixes https://github.com/JabRef/jabref/issues/1181 |
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.
Please remove this comment. It's not relevant that this solved some issue.
As I said in #1181, there should be some additional handling of author names with Jr part like |
public void testSeperatedCommaNames() { | ||
// Testing the issue "https://github.com/JabRef/jabref/issues/1181". | ||
// Every second comma should become a semicolon | ||
public void testSeperatedCommaNames_EverySecondCommaBecomesAnAnd() { |
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.
why not describe the use case here? allowConcatenationOfAuthorsWithCommas
or testConcatenationOfAuthorsWithCommas
I think (as outlined in #1181 (comment)), that The fix works for me and really improves my workflow. |
Do you often have authors separated by colons? I would have guessed this is also a very seldom case. |
In my opinion, the cleanup operations / save actions should respect the bib(la)tex standard before anything else. Otherwise they keep reformatting valid bibtex and thus become useless. Sorry, but I just can't see an automatic way to correctly determine the authors if they are only separated by comma. Consider strings like |
Is a comma even allowed for separating authors in Bib(la)tex? |
IMHO we discussed the separator at some other place that biblatex can be configured to use something else than In bibtex, This tweak happens only if only commans and 2 or more commas and even number of commas Thus, it will currently. destroy both of your examples. - We can include a checker if your special cases ( I still think that you have these special cases, but that these are not the majority of the cases. |
I'm fine with every change as long as standard bibtex names don't get destroyed. So in particular:
Moreover, semi-correct names using semicolon should still be converted to the correct format (i.e. replace every |
@@ -36,6 +36,25 @@ public String getKey() { | |||
|
|||
@Override | |||
public String format(String value) { | |||
// Handle case names in order lastname, firstname and separated by "," |
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.
Sourround the new block with
if (!value.containts(" and ")) {
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.
test also {
as well as ;
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.
For checking for Curly Braces there is a String Util Method which also has
a Unit Test. Maybe you can reuse that.
2016-06-03 14:13 GMT+02:00 Tobias Diez notifications@github.com:
In
src/main/java/net/sf/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java
#1470 (comment):@@ -36,6 +36,25 @@ public String getKey() {
@Override public String format(String value) {
// Handle case names in order lastname, firstname and separated by ","
test also { as well as ;
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/JabRef/jabref/pull/1470/files/efdced6ec231b82f0f8e82a32a57a2f0fb454fb7#r65697196,
or mute the thread
https://github.com/notifications/unsubscribe/AATi5PDxbzRee0GVpU2oQWEe35bpUgUMks5qIBpNgaJpZM4Is5D7
.
😮 - completely overseen that case. 🙈 - Thank you for clarifying! @bruehldev Please include that test and fix the issue. I indicated the necessary change (check for |
@@ -69,4 +105,15 @@ public String getExampleInput() { | |||
return "Albert Einstein and Alan Turing"; | |||
} | |||
|
|||
private static boolean contains(final String[] array, final String[] searchTerms) { |
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.
Do not use arrays. Use Collections. Collections.contains is your friend.
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.
Remove this unused method.
Please check whether your improvement also solves #1504 by adding the example as an additional test case. Thanks! |
@@ -24,6 +30,9 @@ | |||
*/ | |||
public class NormalizeNamesFormatter implements Formatter { | |||
|
|||
// Avoid partition where these values are contained | |||
private final Collection<String> avoidTermsInLowerCase = Arrays.asList("jr", "sr", "jnr", "snr", "von", "zu", "van", "der"); |
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.
Is "von", "zu", "van" also covered by test cases? My feeling is that the code might treat them wrong.
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.
Why isn't this called "affixesInLowerCase"? - Why is "von", "zu", "van" and "der" an affix? I think, only jr, sr, jnr, and snr are affixes. - As far as I can guess, "van" are not affixes
When reading https://en.wikipedia.org/wiki/Suffix_(name), it seems that jr is a name suffix, isn't it?
What is the status of this? |
… format" Added the jr, sr,... special cases for semicolon partition. Fixed to avoid the "and", "{", ";" cases. Added Test for every case.
- Fix codacy issues
- Renamed value and valuePart variable - Edit comment - Exchanged for loop
Replaced for-loops with fancy util methods.
Rebased to upstream master. Should be ready to merge now |
As far as I can see the new code is still in the NormalizeNamesFormatter. Please also add the cases mentioned in #1470 (comment) as tests for the AuthorList.parse method, i.e. as |
@tobiasdiez sorry for the wrong statement. I thought it was pushed, From now on i will double check my uploaded code. I added the test cases for semicolons. The standart format is already tested by threeAuthorsSeperatedByAnd, testMultipleNameAffixes, testNormalizeAuthorList. I hope it's okay that i'm using last2,3,4 and first2,3,4 as names in the semicolon test. |
# Conflicts: # CHANGELOG.md
Fixed #1181: Improved "Normalize to BibTeX name format": Separated names with colons only work now