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

Fix journal abbbrev checker for curly braces #9504

Merged
merged 45 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2628b59
Fix journal abbbrev checker for curly braces
Siedlerchr Dec 28, 2022
79e2531
refactor abbreviation checker to latex free entry checker
Siedlerchr Dec 28, 2022
28915bb
adjust test cases
Siedlerchr Dec 28, 2022
b8d72ce
checkstyle
Siedlerchr Dec 28, 2022
e4bf0af
checkstyle
Siedlerchr Dec 28, 2022
6bb8db4
Merge branch 'main' into fixJournalAbbrevChecker
Siedlerchr Dec 31, 2022
1a5c777
Streamline tests and add tests for 9475 and 9503
koppor Jan 1, 2023
c2c590b
Merge remote-tracking branch 'origin/main' into fixJournalAbbrevChecker
koppor Jan 1, 2023
54fcbd4
Rename Medline to Dotless and add translations for the menu actions
koppor Jan 1, 2023
2779e18
On our way
koppor Jan 1, 2023
630c772
Add misisng test
koppor Jan 1, 2023
9399277
Try to use full MVMap in groovy script
koppor Jan 1, 2023
5801e92
Fix path
koppor Jan 1, 2023
626e41a
Streamline action
koppor Jan 1, 2023
b6beabe
Try to commit changes
koppor Jan 1, 2023
e649c5e
Revert "Streamline action"
koppor Jan 1, 2023
155617e
Try to fix action
koppor Jan 1, 2023
ac82d8e
Debug: show branch
koppor Jan 1, 2023
f6d743f
Stay on current branch
koppor Jan 1, 2023
acf5b91
Fix action
koppor Jan 1, 2023
0e37d5d
Remove bad files
koppor Jan 1, 2023
16e0bd8
Serizalizabe version 1
koppor Jan 1, 2023
d8fd007
Fix duplicate handling
koppor Jan 1, 2023
46d8027
Add trigger on braches
koppor Jan 1, 2023
a45c505
fix
koppor Jan 1, 2023
b5fcfad
Fix wrong comment
koppor Jan 1, 2023
e8a6124
Some debug maybe?
koppor Jan 1, 2023
6d0e9b8
debug
koppor Jan 1, 2023
f6f6aa8
Add warning
koppor Jan 1, 2023
623514e
Try to use a single MV store only
koppor Jan 2, 2023
38bcf84
Fix import
koppor Jan 2, 2023
c7b4267
CamleCase to dash-case
koppor Jan 2, 2023
1b0e431
Fix brace
koppor Jan 2, 2023
540b26a
Update journal abbrev list
koppor Jan 2, 2023
ba04c0a
Remove debug output
koppor Jan 2, 2023
90f7825
Internalize loading
koppor Jan 2, 2023
28bf41d
Disable workflow
koppor Jan 2, 2023
25f517e
Update CHANGELOG.md
koppor Jan 2, 2023
b012a08
Remove initialization hack
koppor Jan 2, 2023
5c66561
Update journal abbrev list
koppor Jan 2, 2023
f579568
No need to fetch
koppor Jan 2, 2023
e61c492
Use right WoS file
koppor Jan 2, 2023
3b23a41
Update journal abbrev list
koppor Jan 2, 2023
70a804f
fix l10n and reorder
Siedlerchr Jan 2, 2023
a6c791d
Merge remote-tracking branch 'origin/main' into fixJournalAbbrevChecker
koppor Jan 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,24 +34,34 @@ 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

# prepare building
mkdir -p $GITHUB_WORKSPACE/build/journals
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 @@ -31,6 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- The tab "deprecated fields" is shown in biblatex-mode only. [#7757](https://github.com/JabRef/jabref/issues/7757)
- 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