Skip to content

Commit

Permalink
Add minor improvements and remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemdot committed Aug 24, 2019
1 parent 58f5c57 commit 74a3ac5
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -17,8 +18,6 @@ public class BibtexExtractor {
private static final String URL_TAG = "[url_tag]";
private static final String YEAR_TAG = "[year_tag]";
private static final String PAGES_TAG = "[pages_tag]";
private static final String TITLE_TAG = "[title_tag]";
private static final String JOURNAL_TAG = "[journal_tag]";

private static final String INITIALS_GROUP = "INITIALS";
private static final String LASTNAME_GROUP = "LASTNAME";
Expand Down Expand Up @@ -47,8 +46,8 @@ public class BibtexExtractor {
"(p.)?\\s?\\d+(-\\d+)?",
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);

private final ArrayList<String> urls = new ArrayList<>();
private final ArrayList<String> authors = new ArrayList<>();
private final List<String> urls = new ArrayList<>();
private final List<String> authors = new ArrayList<>();
private String year = "";
private String pages = "";
private String title = "";
Expand All @@ -60,8 +59,8 @@ public BibEntry extract(String input) {
String inputWithoutAuthors = findAuthors(inputWithoutUrls);
String inputWithoutYear = findYear(inputWithoutAuthors);
String inputWithoutPages = findPages(inputWithoutYear);
String nonparsed = findParts(inputWithoutPages);
return generateEntity(nonparsed);
String nonParsed = findParts(inputWithoutPages);
return generateEntity(nonParsed);
}

private BibEntry generateEntity(String input) {
Expand Down Expand Up @@ -135,7 +134,6 @@ private String fixSpaces(String input) {

private String findParts(String input) {
ArrayList<String> lastParts = new ArrayList<>();
String line = input;
int afterAuthorsIndex = input.lastIndexOf(AUTHOR_TAG);
if (afterAuthorsIndex == -1) {
return input;
Expand All @@ -160,15 +158,13 @@ private String findParts(String input) {
}
if (nonDigitParts > 0) {
title = lastParts.get(0);
line.replace(title, TITLE_TAG);
}
if (nonDigitParts > 1) {
journalOrPublisher = lastParts.get(1);
line.replace(journalOrPublisher, JOURNAL_TAG);
}
if (nonDigitParts > 2) {
isArticle = false;
}
return fixSpaces(line);
return fixSpaces(input);
}
}

0 comments on commit 74a3ac5

Please sign in to comment.