Skip to content

Commit

Permalink
Final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan committed Sep 25, 2024
1 parent 7d0c04f commit 05f2fd4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
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 starting a new SLR, the selected catalogs now persist within and across JabRef sessions. [koppor#614](https://github.com/koppor/jabref/issues/614)
- 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.

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,63 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ComboBox?>
<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.bibtexextractor.ExtractBibtexDialog">
<?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.bibtexextractor.ExtractBibtexDialog">
<content>
<VBox fx:id="contentVbox" spacing="10" minHeight="-Infinity" prefHeight="200.0" prefWidth="100.0">
<VBox fx:id="contentVbox"
spacing="10"
minHeight="-Infinity"
prefHeight="500.0"
prefWidth="100.0">
<children>
<TextArea fx:id="input" minHeight="-Infinity" prefHeight="450.0" prefWidth="586.0" wrapText="true"/>
<HBox alignment="BASELINE_LEFT" spacing="10">
<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 (only for online extraction):"/>
<ComboBox fx:id="parserChoice" HBox.hgrow="ALWAYS"/>
<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"/>
<ButtonType
fx:id="parseButtonType"
buttonData="OK_DONE"
text="%Add to current library"/>
<ButtonType
fx:constant="CANCEL"/>
</DialogPane>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.logic.importer.fetcher;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -32,12 +34,19 @@ public LlmCitationFetcher(ImportFormatPreferences importFormatPreferences, ChatL

@Override
public List<BibEntry> performSearch(String searchQuery) throws FetcherException {
return parseBibtexUsingLlm(searchQuery).map(List::of).orElse(List.of());
List<BibEntry> entries = new ArrayList<>();

for (String citation : searchQuery.split("\n\n")) {
Optional<BibEntry> entry = parseCitationUsingLlm(citation);
entry.ifPresent(entries::add);
}

return entries;
}

private Optional<BibEntry> parseBibtexUsingLlm(String searchQuery) throws FetcherException {
private Optional<BibEntry> parseCitationUsingLlm(String citation) throws FetcherException {
try {
return BibtexParser.singleFromString(getBibtexStringFromLlm(searchQuery), importFormatPreferences);
return BibtexParser.singleFromString(getBibtexStringFromLlm(citation), importFormatPreferences);
} catch (ParseException e) {
throw new FetcherException("Could not parse BibTeX returned from LLM", e);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2638,6 +2638,8 @@ Default\ online\ plain\ citation\ parser=Default online plain citation parser
GROBID=GROBID
LLM=LLM
Parser\ choice\ (only\ for\ online\ extraction)\:=Parser choice (only for online extraction):
Please\ verify\ any\ information\ provided.=Please verify any information provided.
Warning\:\ plain\ citation\ parsing\ may\ generate\ inaccurate\ or\ inappropriate\ responses.=Warning: plain citation parsing may generate inaccurate or inappropriate responses.
Link=Link
Source\ URL=Source URL
Expand Down

0 comments on commit 05f2fd4

Please sign in to comment.