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

Add plain citation parsing with LLM #11831

Merged
merged 14 commits into from
Oct 6, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added support for drag'n'drop on an entry in the maintable to an external application to get the entry preview dropped. [#11846](https://github.com/JabRef/jabref/pull/11846)
- We added a different background color to the search bar to indicate when the search syntax is wrong. [#11658](https://github.com/JabRef/jabref/pull/11658)
- We added a setting which always adds the literal "Cited on pages" text before each JStyle citation. [#11691](https://github.com/JabRef/jabref/pull/11732)
- We added a new plain citation parser that uses LLMs. [#11825](https://github.com/JabRef/jabref/issues/11825)

### Changed

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/gui/actions/StandardActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ public enum StandardActions implements Action {
NEW_ENTRY(Localization.lang("New entry"), IconTheme.JabRefIcons.ADD_ENTRY, KeyBinding.NEW_ENTRY),
NEW_ARTICLE(Localization.lang("New article"), IconTheme.JabRefIcons.ADD_ARTICLE),
NEW_ENTRY_FROM_PLAIN_TEXT(Localization.lang("New entry from plain text"), IconTheme.JabRefIcons.NEW_ENTRY_FROM_PLAIN_TEXT),
NEW_ENTRY_FROM_PLAIN_TEXT_ONLINE(Localization.lang("New entry from plain text (online)"), IconTheme.JabRefIcons.NEW_ENTRY_FROM_PLAIN_TEXT, KeyBinding.NEW_ENTRY_FROM_PLAIN_TEXT_ONLINE),
NEW_ENTRY_FROM_PLAIN_TEXT_OFFLINE(Localization.lang("New entry from plain text (offline)"), IconTheme.JabRefIcons.NEW_ENTRY_FROM_PLAIN_TEXT),
LIBRARY_PROPERTIES(Localization.lang("Library properties")),
FIND_DUPLICATES(Localization.lang("Find duplicates"), IconTheme.JabRefIcons.FIND_DUPLICATES),
MERGE_ENTRIES(Localization.lang("Merge entries"), IconTheme.JabRefIcons.MERGE_ENTRIES, KeyBinding.MERGE_ENTRIES),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 2 additions & 5 deletions src/main/java/org/jabref/gui/frame/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.ai.ClearEmbeddingsAction;
import org.jabref.gui.auximport.NewSubLibraryAction;
import org.jabref.gui.bibtexextractor.ExtractBibtexActionOffline;
import org.jabref.gui.bibtexextractor.ExtractBibtexActionOnline;
import org.jabref.gui.citationkeypattern.GenerateCitationKeyAction;
import org.jabref.gui.cleanup.CleanupAction;
import org.jabref.gui.copyfiles.CopyFilesAction;
Expand Down Expand Up @@ -54,6 +52,7 @@
import org.jabref.gui.maintable.NewLibraryFromPdfActionOffline;
import org.jabref.gui.maintable.NewLibraryFromPdfActionOnline;
import org.jabref.gui.mergeentries.MergeEntriesAction;
import org.jabref.gui.plaincitationparser.PlainCitationParserAction;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.preferences.ShowPreferencesAction;
import org.jabref.gui.preview.CopyCitationAction;
Expand Down Expand Up @@ -232,11 +231,9 @@ private void createMenu() {
}
});

MenuItem newEntryFromPlainTextOnline = factory.createMenuItem(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT_ONLINE, new ExtractBibtexActionOnline(dialogService, preferences, stateManager, true));
library.getItems().addAll(
factory.createMenuItem(StandardActions.NEW_ENTRY, new NewEntryAction(frame::getCurrentLibraryTab, dialogService, preferences, stateManager)),
newEntryFromPlainTextOnline,
factory.createMenuItem(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT_OFFLINE, new ExtractBibtexActionOffline(dialogService, stateManager)),
factory.createMenuItem(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new PlainCitationParserAction(dialogService)),
factory.createMenuItem(StandardActions.DELETE_ENTRY, new EditAction(StandardActions.DELETE_ENTRY, frame::getCurrentLibraryTab, stateManager, undoManager)),

new SeparatorMenuItem(),
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/org/jabref/gui/frame/MainToolBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.bibtexextractor.ExtractBibtexActionOnline;
import org.jabref.gui.citationkeypattern.GenerateCitationKeyAction;
import org.jabref.gui.cleanup.CleanupAction;
import org.jabref.gui.edit.EditAction;
Expand All @@ -31,6 +30,7 @@
import org.jabref.gui.importer.NewDatabaseAction;
import org.jabref.gui.importer.NewEntryAction;
import org.jabref.gui.importer.actions.OpenDatabaseAction;
import org.jabref.gui.plaincitationparser.PlainCitationParserAction;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.push.PushToApplicationCommand;
import org.jabref.gui.search.GlobalSearchBar;
Expand Down Expand Up @@ -107,10 +107,6 @@ private void createToolBar() {

// Setup Toolbar

// The action itself asks the user if it is OK to use Grobid (in some cases).
// Therefore, the condition of enablement is "only" if a library is opened. (Parameter "false")
Button newEntryFromPlainTextOnlineButton = factory.createIconButton(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new ExtractBibtexActionOnline(dialogService, preferences, stateManager, false));

getItems().addAll(
new HBox(
factory.createIconButton(StandardActions.NEW_LIBRARY, new NewDatabaseAction(frame, preferences)),
Expand All @@ -127,7 +123,7 @@ private void createToolBar() {
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(frame::getCurrentLibraryTab, StandardEntryType.Article, dialogService, preferences, stateManager)),
factory.createIconButton(StandardActions.NEW_ENTRY, new NewEntryAction(frame::getCurrentLibraryTab, dialogService, preferences, stateManager)),
createNewEntryFromIdButton(),
newEntryFromPlainTextOnlineButton,
factory.createIconButton(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new PlainCitationParserAction(dialogService)),
factory.createIconButton(StandardActions.DELETE_ENTRY, new EditAction(StandardActions.DELETE_ENTRY, frame::getCurrentLibraryTab, stateManager, undoManager))),

new Separator(Orientation.VERTICAL),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.jabref.gui.importer;

import org.jabref.gui.DialogService;
import org.jabref.logic.importer.fetcher.GrobidPreferences;
import org.jabref.logic.importer.util.GrobidPreferences;
import org.jabref.logic.l10n.Localization;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jabref.gui.plaincitationparser;

import org.jabref.gui.DialogService;
import org.jabref.gui.actions.SimpleCommand;

public class PlainCitationParserAction extends SimpleCommand {
private final DialogService dialogService;

public PlainCitationParserAction(DialogService dialogService) {
this.dialogService = dialogService;
}

@Override
public void execute() {
dialogService.showCustomDialogAndWait(new PlainCitationParserDialog());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ButtonType?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.text.Font?>
<DialogPane
prefHeight="430.0"
prefWidth="586.0"
xmlns="http://javafx.com/javafx/8.0.171"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.jabref.gui.plaincitationparser.PlainCitationParserDialog">
<content>
<VBox fx:id="contentVbox"
spacing="10"
minHeight="-Infinity"
prefHeight="500.0"
prefWidth="100.0">
<children>
<TextArea
fx:id="input"
minHeight="-Infinity"
prefHeight="400.0"
prefWidth="586.0"
wrapText="true"/>

<HBox alignment="BASELINE_LEFT"
spacing="10">
<children>
<Label text="%Parser choice"/>
<ComboBox
fx:id="parserChoice"
HBox.hgrow="ALWAYS"/>
</children>
</HBox>

<VBox spacing="3">
<Label text="%Warning: plain citation parsing may generate inaccurate or inappropriate responses."
wrapText="true">
<font>
<Font name="System Italic"
size="13.0"/>
</font>
</Label>

<!-- Somehow, wrapping doesn't work there, so the warning notice is split into two labels. -->

<Label text="%Please verify any information provided."
wrapText="true">
<font>
<Font name="System Italic"
size="13.0"/>
</font>
</Label>
</VBox>
</children>
</VBox>
</content>
<ButtonType
fx:id="parseButtonType"
buttonData="OK_DONE"
text="%Add to current library"/>
<ButtonType
fx:constant="CANCEL"/>
</DialogPane>
Loading
Loading