Skip to content

Commit

Permalink
Fix journal abbbrev checker for curly braces (#9504)
Browse files Browse the repository at this point in the history
* Fix journal abbbrev checker for curly braces

Escape any curly braces
Also use latex free fields


Fixes #9475
Fixes #9503

* refactor abbreviation checker to latex free entry checker

* adjust test cases

* checkstyle

* checkstyle

* Streamline tests and add tests for 9475 and 9503

Co-authored-by: Christoph <siedlerkiller@gmail.com>
Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>

* Rename Medline to Dotless and add translations for the menu actions

* On our way

Co-authored-by: Christoph <siedlerkiller@gmail.com>

* Add misisng test

Co-authored-by: Christoph <siedlerkiller@gmail.com>

* Try to use full MVMap in groovy script

* Fix path

* Streamline action

* Try to commit changes

* Revert "Streamline action"

This reverts commit 626e41a.

* Try to fix action

* Debug: show branch

* Stay on current branch

* Fix action

* Remove bad files

* Serizalizabe version 1

* Fix duplicate handling

* Add trigger on braches

* fix

* Fix wrong comment

* Some debug maybe?

* debug

* Add warning

* Try to use a single MV store only

* Fix import

* CamleCase to dash-case

* Fix brace

* Update journal abbrev list

* Remove debug output

* Internalize loading

* Disable workflow

* Update CHANGELOG.md

* Remove initialization hack

* Update journal abbrev list

* No need to fetch

* Use right WoS file

* Update journal abbrev list

* fix l10n and reorder

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Co-authored-by: koppor <koppor@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 2, 2023
1 parent f626c72 commit 88c9f56
Show file tree
Hide file tree
Showing 25 changed files with 346 additions and 287 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/refresh-journal-lists.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Refresh Journal Lists

on:
# Allow to run manually
workflow_dispatch:
# Allow to run manually

permissions:
contents: read
Expand All @@ -15,12 +15,9 @@ jobs:
name: Refresh Journal List Files
runs-on: ubuntu-latest
steps:
- name: Fetch all history for all tags and branches
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
ref: main
persist-credentials: false
fetch-depth: 0
persist-credentials: true
- name: Set up JDK
uses: actions/setup-java@v3
with:
Expand All @@ -37,10 +34,10 @@ jobs:
cd abbrv.jabref.org/journals
# remove all lists without dot in them
# we use abbrevatiation lists containing dots in them only (to be consistent)
# we use abbreviation lists containing dots in them only (to be consistent)
rm journal_abbreviations_entrez.csv
rm journal_abbreviations_medicus.csv
rm journal_abbreviations_webofscience-dots.csv
rm journal_abbreviations_webofscience-dotless.csv
# we currently do not have good support for BibTeX strings
rm journal_abbreviations_ieee_strings.csv
Expand All @@ -50,14 +47,24 @@ jobs:
cp * $GITHUB_WORKSPACE/build/journals/
# ensure that the .java classes are the most recent ones
mkdir -p $GITHUB_WORKSPACE/buildSrc/src/copied/java/org/jabref/logic/journals
cp $GITHUB_WORKSPACE/src/main/java/org/jabref/logic/journals/* $GITHUB_WORKSPACE/buildSrc/src/copied/java/org/jabref/logic/journals
# create .mv file
cd $GITHUB_WORKSPACE
./gradlew generateJournalAbbreviationList
- uses: peter-evans/create-pull-request@v4
if: github.ref == 'refs/heads/main'
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-journallist
title: "[Bot] Update Journal abbrev list"
commit-message: Update journal abbrev list
- name: Commit and push changes
uses: EndBug/add-and-commit@v9
if: github.ref != 'refs/heads/main'
with:
message: 'Update journal abbrev list'
committer_email: actions@github.com
fetch: false
push: true
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

- We changed database structure: in MySQL/MariaDB we renamed tables by adding a `JABREF_` prefix, and in PGSQL we moved tables in `jabref` schema. We added `VersionDBStructure` variable in `METADATA` table to indicate current version of structure, this variable is needed for automatic migration. [#9312](https://github.com/JabRef/jabref/issues/9312)
- We moved some preferences options to a new tab in the preferences dialog. [#9442](https://github.com/JabRef/jabref/pull/9308)
- We renamed "Medline abbrevation" to "dotless abbreviation". [#9504](https://github.com/JabRef/jabref/pull/9504)
- We now have more "dots" in the offered journal abbrevations. [#9504](https://github.com/JabRef/jabref/pull/9504)



Expand All @@ -32,6 +34,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- In case a journal name of an IEEE journal is abbreviated, the "normal" abbreviation is used - and not the one of the IEEE BibTeX strings. [abbrv#91](https://github.com/JabRef/abbrv.jabref.org/issues/91)
- We fixed an issue where the last opened libraries were not remembered when a new unsaved libray was open as well. [#9190](https://github.com/JabRef/jabref/issues/9190)
- We fixed an issue where no context menu for the group "All entries" was present. [forum#3682](https://discourse.jabref.org/t/how-sort-groups-a-z-not-subgroups/3682)
- We fixed an issue where extra curly braces in some fields would trigger an exception when selecting the entry or doing an integrity check [#9475](https://github.com/JabRef/jabref/issues/9475), [#9503](https://github.com/JabRef/jabref/issues/9503)
- We fixed an issue where entering a date in the format "YYYY/MM" in the entry editor date field caused an exception. [#9492](https://github.com/JabRef/jabref/issues/9492)

### Removed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
package org.jabref.logic.journals;

import java.io.Serializable;
import java.util.Objects;

public class Abbreviation implements Comparable<Abbreviation> {
public class Abbreviation implements Comparable<Abbreviation>, Serializable {

private final String name;
private static final long serialVersionUID = 1;

private transient String name;
private final String abbreviation;
private transient String dotlessAbbreviation;
private final String shortestUniqueAbbreviation;

public Abbreviation(String name, String abbreviation) {
this(name, abbreviation, "");
}

public Abbreviation(String name, String abbreviation, String shortestUniqueAbbreviation) {
this.name = name;
this.abbreviation = abbreviation;
this.shortestUniqueAbbreviation = shortestUniqueAbbreviation.trim();
this(name,
abbreviation,
// "L. N." becomes "L N ", we need to remove the double spaces inbetween
abbreviation.replace(".", " ").replace(" ", " ").trim(),
shortestUniqueAbbreviation.trim());
}

public Abbreviation(String name, String abbreviation, String dotlessAbbreviation, String shortestUniqueAbbreviation) {
this.name = name.intern();
this.abbreviation = abbreviation.intern();
this.dotlessAbbreviation = dotlessAbbreviation.intern();
this.shortestUniqueAbbreviation = shortestUniqueAbbreviation.trim().intern();
}

public String getName() {
Expand All @@ -34,8 +47,8 @@ public String getShortestUniqueAbbreviation() {
return result;
}

public String getMedlineAbbreviation() {
return getAbbreviation().replace(".", " ").replace(" ", " ").trim();
public String getDotlessAbbreviation() {
return this.dotlessAbbreviation;
}

@Override
Expand All @@ -46,23 +59,23 @@ public int compareTo(Abbreviation toCompare) {
public String getNext(String current) {
String currentTrimmed = current.trim();

if (getMedlineAbbreviation().equals(currentTrimmed)) {
if (getDotlessAbbreviation().equals(currentTrimmed)) {
return getShortestUniqueAbbreviation().equals(getAbbreviation()) ? getName() : getShortestUniqueAbbreviation();
} else if (getShortestUniqueAbbreviation().equals(currentTrimmed) && !getShortestUniqueAbbreviation().equals(getAbbreviation())) {
return getName();
} else if (getName().equals(currentTrimmed)) {
return getAbbreviation();
} else {
return getMedlineAbbreviation();
return getDotlessAbbreviation();
}
}

@Override
public String toString() {
return String.format("Abbreviation{name=%s, abbreviation=%s, medlineAbbreviation=%s, shortestUniqueAbbreviation=%s}",
return String.format("Abbreviation{name=%s, abbreviation=%s, dotlessAbbreviation=%s, shortestUniqueAbbreviation=%s}",
this.name,
this.abbreviation,
this.getMedlineAbbreviation(),
this.dotlessAbbreviation,
this.shortestUniqueAbbreviation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* <p>
* This class loads abbreviations from a CSV file and stores them into a MV file
* </p>
* <p>
* Abbreviations are available at <a href="https://github.com/JabRef/abbrv.jabref.org/">https://github.com/JabRef/abbrv.jabref.org/</a>.
* </p>
*/
public class JournalAbbreviationLoader {

private static final Logger LOGGER = LoggerFactory.getLogger(JournalAbbreviationLoader.class);
Expand All @@ -26,8 +34,8 @@ public static JournalAbbreviationRepository loadRepository(JournalAbbreviationPr
// Initialize with built-in list
try {
Path tempDir = Files.createTempDirectory("jabref-journal");
Path tempJournalList = tempDir.resolve("journalList.mv");
Files.copy(JournalAbbreviationRepository.class.getResourceAsStream("/journals/journalList.mv"), tempJournalList);
Path tempJournalList = tempDir.resolve("journal-list.mv");
Files.copy(JournalAbbreviationRepository.class.getResourceAsStream("/journals/journal-list.mv"), tempJournalList);
repository = new JournalAbbreviationRepository(tempJournalList);
tempDir.toFile().deleteOnExit();
tempJournalList.toFile().deleteOnExit();
Expand All @@ -39,12 +47,13 @@ public static JournalAbbreviationRepository loadRepository(JournalAbbreviationPr
// Read external lists
List<String> lists = journalAbbreviationPreferences.getExternalJournalLists();
if (!(lists.isEmpty())) {
// reversing ensures that the latest lists overwrites the former one
Collections.reverse(lists);
for (String filename : lists) {
try {
repository.addCustomAbbreviations(readJournalListFromFile(Path.of(filename)));
} catch (IOException e) {
LOGGER.error(String.format("Cannot read external journal list file %s", filename), e);
LOGGER.error("Cannot read external journal list file {}", filename, e);
}
}
}
Expand Down
Loading

0 comments on commit 88c9f56

Please sign in to comment.