Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d578f69
Port DuplicateCheck.similarity to StringSimilarity and add tests
TheYorouzoya Aug 15, 2025
022bcd4
Add ICORE2023 Rank Data To Resources
TheYorouzoya Aug 20, 2025
5bacb29
Add Core Classes For ICORE Rank Lookup
TheYorouzoya Aug 22, 2025
e035e0e
Integrate ICORE Rank Lookup Feature Into The GUI
TheYorouzoya Aug 26, 2025
3a36afe
Merge branch 'main' into add-ICORE-ranking-support
TheYorouzoya Aug 26, 2025
a7b1b94
Add Missing Localization Keys and Fix Broken Test
TheYorouzoya Aug 27, 2025
33ed0db
Use List.of() and fix grammar
koppor Aug 28, 2025
806309e
Reorder fields
koppor Aug 28, 2025
5330632
Fix unsupported operation exception
koppor Aug 28, 2025
b092aa9
Rename field
koppor Aug 28, 2025
52d3acd
Merge branch 'main' into add-ICORE-ranking-support
koppor Aug 28, 2025
75d2b47
Hotfix: calling of publish.yml
koppor Aug 28, 2025
45a1d10
Port DuplicateCheck.similarity to StringSimilarity and add tests
TheYorouzoya Aug 15, 2025
290cf6c
Add ICORE2023 Rank Data To Resources
TheYorouzoya Aug 20, 2025
93da09f
Add Core Classes For ICORE Rank Lookup
TheYorouzoya Aug 22, 2025
cbd4dda
Fix Merge Conflict From Upstream Fetch
TheYorouzoya Aug 26, 2025
2a1a73e
Add Missing Localization Keys and Fix Broken Test
TheYorouzoya Aug 27, 2025
6747ad1
Merged changes to FieldFactory and StandardField
TheYorouzoya Aug 28, 2025
ff5c144
Add Minor Fixes, Documentation, and Refactor
TheYorouzoya Aug 28, 2025
89c6600
Revert "Hotfix: calling of publish.yml"
TheYorouzoya Aug 28, 2025
c63e2da
Remove duplicate line in CHANGELOG
TheYorouzoya Aug 28, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- When relativizing file names, symlinks are now taken into account. [#12995](https://github.com/JabRef/jabref/issues/12995)
- We added a new button for shortening the DOI near the DOI field in the general tab when viewing an entry. [#13639](https://github.com/JabRef/jabref/issues/13639)
- We added support for finding CSL-Styles based on their short title (e.g. apa instead of "american psychological association"). [#13728](https://github.com/JabRef/jabref/pull/13728)
- We added a field for the latest ICORE conference ranking lookup on the General Tab. [#13476](https://github.com/JabRef/jabref/issues/13476)

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public static FieldEditorFX getForField(final Field field,
return new CitationKeyEditor(field, suggestionProvider, fieldCheckers, databaseContext, undoAction, redoAction);
} else if (fieldProperties.contains(FieldProperty.MARKDOWN)) {
return new MarkdownEditor(field, suggestionProvider, fieldCheckers, preferences, undoManager, undoAction, redoAction);
} else if (field == StandardField.ICORERANKING) {
return new ICORERankingEditor(field, suggestionProvider, fieldCheckers);
} else {
// There was no specific editor found

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package org.jabref.gui.fieldeditors;

import java.util.Optional;

import javax.swing.undo.UndoManager;

import javafx.fxml.FXML;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;

import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.logic.icore.ConferenceRepository;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;

import com.airhacks.afterburner.injection.Injector;
import com.airhacks.afterburner.views.ViewLoader;
import jakarta.inject.Inject;

public class ICORERankingEditor extends HBox implements FieldEditorFX {
@FXML private ICORERankingEditorViewModel viewModel;
@FXML private EditorTextField textField;
@FXML private Button lookupICORERankButton;
@FXML private Button visitICOREConferencePageButton;

@Inject private DialogService dialogService;
@Inject private TaskExecutor taskExecutor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable - remove - also at constructor

@Inject private GuiPreferences preferences;
@Inject private UndoManager undoManager;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable- remove

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • UndoManager is required by the constructor inside the AbstractEditorViewModel superclass.
  • GuiPreferences is required to open the conference page via the call to NativeDesktop.openBrowser() since it needs the user's externalApplicationPreferences.
  • DialogService will be required to apply the fix suggested here.

I'll remove the TaskExecutor since it is not being used.

@Inject private StateManager stateManager;
@Inject private ConferenceRepository conferenceRepository;

private Optional<BibEntry> entry = Optional.empty();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Optional as a field is against Java best practices. Optional should only be used as method return type, not as a field or parameter type.


public ICORERankingEditor(Field field,
SuggestionProvider<?> suggestionProvider,
FieldCheckers fieldCheckers) {

Injector.registerExistingAndInject(this);

ViewLoader.view(this)
.root(this)
.load();

this.viewModel = new ICORERankingEditorViewModel(
field,
suggestionProvider,
fieldCheckers,
taskExecutor,
dialogService,
undoManager,
stateManager,
preferences,
conferenceRepository
);

textField.textProperty().bindBidirectional(viewModel.textProperty());

lookupICORERankButton.setTooltip(
new Tooltip(Localization.lang("Look up conference rank"))
);
visitICOREConferencePageButton.setTooltip(
new Tooltip(Localization.lang("Visit ICORE conference page"))
);

new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textField);
}

@Override
public void bindToEntry(BibEntry entry) {
this.entry = Optional.of(entry);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct assignment of Optional.of() could throw NullPointerException if entry is null. Should use Optional.ofNullable() for safer null handling.

viewModel.bindToEntry(entry);
}

@Override
public Parent getNode() {
return this;
}

@FXML
private void lookupRank() {
entry.ifPresent(viewModel::lookupIdentifier);
}

@FXML
private void openExternalLink() {
viewModel.openExternalLink();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package org.jabref.gui.fieldeditors;

import java.io.IOException;
import java.util.Optional;

import javax.swing.undo.UndoManager;

import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.desktop.os.NativeDesktop;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.logic.icore.ConferenceAcronymExtractor;
import org.jabref.logic.icore.ConferenceRepository;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.icore.ConferenceEntry;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ICORERankingEditorViewModel extends AbstractEditorViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(ICORERankingEditorViewModel.class);

private final TaskExecutor taskExecutor;
private final DialogService dialogService;
private final UndoManager undoManager;
private final StateManager stateManager;
private final GuiPreferences preferences;
private final ConferenceRepository repo;

private ConferenceEntry matchedConference;

public ICORERankingEditorViewModel(
Field field,
SuggestionProvider<?> suggestionProvider,
FieldCheckers fieldCheckers,
TaskExecutor taskExecutor,
DialogService dialogService,
UndoManager undoManager,
StateManager stateManager,
GuiPreferences preferences,
ConferenceRepository conferenceRepository
) {
super(field, suggestionProvider, fieldCheckers, undoManager);
this.taskExecutor = taskExecutor;
this.dialogService = dialogService;
this.undoManager = undoManager;
this.stateManager = stateManager;
this.preferences = preferences;
this.repo = conferenceRepository;
}

public void lookupIdentifier(BibEntry bibEntry) {
Optional<String> bookTitle = bibEntry.getFieldOrAlias(StandardField.BOOKTITLE);

if (bookTitle.isEmpty()) {
bookTitle = bibEntry.getFieldOrAlias(StandardField.JOURNAL);
}

if (bookTitle.isEmpty()) {
return;
}

Optional<ConferenceEntry> conference;
Optional<String> acronym = ConferenceAcronymExtractor.extract(bookTitle.get());
if (acronym.isPresent()) {
conference = repo.getConferenceFromAcronym(acronym.get());
if (conference.isPresent()) {
entry.setField(field, conference.get().rank());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using setField instead of withField violates JabRef's immutability pattern for BibEntry modifications. Should use withField to maintain immutability.

matchedConference = conference.get();
return;
}
}

conference = repo.getConferenceFromBookTitle(bookTitle.get());
if (conference.isPresent()) {
entry.setField(field, conference.get().rank());
matchedConference = conference.get();
} else {
entry.setField(field, Localization.lang("not found"));
}
}

public void openExternalLink() {
if (matchedConference != null) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using null check instead of Optional for matchedConference field. New public methods and fields should use Optional to avoid null checks.

try {
NativeDesktop.openBrowser(matchedConference.getICOREURL(), preferences.getExternalApplicationsPreferences());
} catch (IOException e) {
LOGGER.error("Error opening external link in browser", e);
dialogService.showErrorDialogAndWait(Localization.lang("Could not open website."), e);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.UnaryOperator;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
Expand All @@ -25,6 +26,7 @@
import org.jabref.logic.preferences.JabRefCliPreferences;
import org.jabref.logic.shared.security.Password;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.SpecialField;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.EntryTypeFactory;
Expand Down Expand Up @@ -65,6 +67,7 @@ public static void runMigrations(JabRefGuiPreferences preferences) {
upgradeCleanups(preferences);
moveApiKeysToKeyring(preferences);
removeCommentsFromCustomEditorTabs(preferences);
addICORERankingFieldToGeneralTab(preferences);
upgradeResolveBibTeXStringsFields(preferences);
}

Expand Down Expand Up @@ -558,6 +561,37 @@ static void moveApiKeysToKeyring(JabRefCliPreferences preferences) {
}
}

static void addICORERankingFieldToGeneralTab(GuiPreferences preferences) {
Map<String, Set<Field>> entryEditorPrefs = preferences.getEntryEditorPreferences().getEntryEditorTabs();
Set<Field> currentGeneralPrefs = entryEditorPrefs.get("General");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, Localization.lang("General") should be used - see org.jabref.logic.preferences.JabRefCliPreferences#setLanguageDependentDefaultValues


Set<Field> expectedGeneralPrefs = Set.of(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think org.jabref.model.entry.field.FieldFactory#getDefaultGeneralFields should be linked - to enable others to lookup things if they implement something similar.

StandardField.DOI, StandardField.CROSSREF, StandardField.KEYWORDS, StandardField.EPRINT,
StandardField.URL, StandardField.FILE, StandardField.GROUPS, StandardField.OWNER,
StandardField.TIMESTAMP,

SpecialField.PRINTED, SpecialField.PRIORITY, SpecialField.QUALITY, SpecialField.RANKING,
SpecialField.READ_STATUS, SpecialField.RELEVANCE
);

if (!currentGeneralPrefs.equals(expectedGeneralPrefs)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice check!

return;
}

entryEditorPrefs.put(
"General",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also org.jabref.logic.preferences.JabRefCliPreferences#setLanguageDependentDefaultValues

Set.of(
StandardField.DOI, StandardField.ICORERANKING, StandardField.CROSSREF, StandardField.KEYWORDS,
StandardField.EPRINT, StandardField.URL, StandardField.FILE, StandardField.GROUPS,
StandardField.OWNER, StandardField.TIMESTAMP,

SpecialField.PRINTED, SpecialField.PRIORITY, SpecialField.QUALITY, SpecialField.RANKING,
SpecialField.READ_STATUS, SpecialField.RELEVANCE
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, rg.jabref.model.entry.field.FieldFactory#getDefaultGeneralFields can be used directly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this fit the expectations?

/**
 * Updates the default preferences for the editor fields under the "General" tab to include the ICORE Ranking Field
 * if it is missing.
 *<p>
 * The function first ensures that the current preferences match the previous default (before the ICORE field was added)
 * and only then does the update.
 *
 * @implNote The default fields for the "General" tab are defined by {@link FieldFactory#getDefaultGeneralFields()}.
 * @param preferences the user's current preferences
 */
static void addICORERankingFieldToGeneralTab(GuiPreferences preferences) {
    Map<String, Set<Field>> entryEditorPrefs = preferences.getEntryEditorPreferences().getEntryEditorTabs();
    Set<Field> currentGeneralPrefs = entryEditorPrefs.get(Localization.lang("General"));

    Set<Field> expectedGeneralPrefs = Set.of(
        StandardField.DOI, StandardField.CROSSREF, StandardField.KEYWORDS, StandardField.EPRINT,
        StandardField.URL, StandardField.FILE, StandardField.GROUPS, StandardField.OWNER,
        StandardField.TIMESTAMP,

        SpecialField.PRINTED, SpecialField.PRIORITY, SpecialField.QUALITY, SpecialField.RANKING,
        SpecialField.READ_STATUS, SpecialField.RELEVANCE
    );

    if (!currentGeneralPrefs.equals(expectedGeneralPrefs)) {
        return;
    }

    entryEditorPrefs.put(
            Localization.lang("General"),
            FieldFactory.getDefaultGeneralFields().stream().collect(Collectors.toSet())
    );
    preferences.getEntryEditorPreferences().setEntryEditorTabList(entryEditorPrefs);
}

);
preferences.getEntryEditorPreferences().setEntryEditorTabList(entryEditorPrefs);
}

/**
* The tab "Comments" is hard coded using {@link CommentsTab} since v5.10 (and thus hard-wired in {@link org.jabref.gui.entryeditor.EntryEditor#createTabs()}.
* Thus, the configuration ih the preferences is obsolete
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.fieldeditors.EditorTextField?>
<?import org.jabref.gui.icon.JabRefIconView?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" xmlns="http://javafx.com/javafx/8.0.112"
fx:controller="org.jabref.gui.fieldeditors.ICORERankingEditor">
<EditorTextField fx:id="textField"/>
<Button fx:id="lookupICORERankButton"
onAction="#lookupRank"
styleClass="icon-button">
<graphic>
<JabRefIconView glyph="LOOKUP_IDENTIFIER"/>
</graphic>
</Button>
<Button fx:id="visitICOREConferencePageButton"
onAction="#openExternalLink"
styleClass="icon-button">
<graphic>
<JabRefIconView glyph="OPEN_LINK"/>
</graphic>
</Button>
</fx:root>
2 changes: 2 additions & 0 deletions jablib/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
exports org.jabref.logic.command;
exports org.jabref.logic.git.util;
exports org.jabref.logic.git.preferences;
exports org.jabref.logic.icore;
exports org.jabref.model.icore;

requires java.base;

Expand Down
30 changes: 2 additions & 28 deletions jablib/src/main/java/org/jabref/logic/database/DuplicateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,10 @@ public static double correlateByWords(final String s1, final String s2) {
final String[] w1 = s1.split("\\s");
final String[] w2 = s2.split("\\s");
final int n = Math.min(w1.length, w2.length);
final StringSimilarity match = new StringSimilarity();
int misses = 0;
for (int i = 0; i < n; i++) {
double corr = similarity(w1[i], w2[i]);
double corr = match.similarity(w1[i], w2[i]);
if (corr < 0.75) {
misses++;
}
Expand All @@ -300,33 +301,6 @@ public static double correlateByWords(final String s1, final String s2) {
return 1 - missRate;
}

/**
* Calculates the similarity (a number within 0 and 1) between two strings.
* http://stackoverflow.com/questions/955110/similarity-string-comparison-in-java
*/
private static double similarity(final String first, final String second) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find :)

final String longer;
final String shorter;

if (first.length() < second.length()) {
longer = second;
shorter = first;
} else {
longer = first;
shorter = second;
}

final int longerLength = longer.length();
// both strings are zero length
if (longerLength == 0) {
return 1.0;
}
final double distanceIgnoredCase = new StringSimilarity().editDistanceIgnoreCase(longer, shorter);
final double similarity = (longerLength - distanceIgnoredCase) / longerLength;
LOGGER.trace("Longer string: {} Shorter string: {} Similarity: {}", longer, shorter, similarity);
return similarity;
}

/**
* Checks if the two entries represent the same publication.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.jabref.logic.icore;

import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ConferenceAcronymExtractor {
// Regex that'll extract the string within the first deepest set of parentheses
// A slight modification of: https://stackoverflow.com/a/17759264
private static final Pattern PATTERN = Pattern.compile("\\(([^()]*)\\)");

public static Optional<String> extract(String input) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method lacks input validation for null parameter which could lead to NullPointerException. While Optional return is good, the input should be validated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NonNull jspecify annotation is OK

Please add JavaDoc.

Matcher matcher = PATTERN.matcher(input);

if (matcher.find()) {
String match = matcher.group(1).strip();
if (!match.isEmpty()) {
return Optional.of(match);
}
}

return Optional.empty();
}
}
Loading
Loading