|
8 | 8 | import java.util.regex.Matcher; |
9 | 9 | import java.util.regex.Pattern; |
10 | 10 |
|
11 | | -import org.jabref.logic.importer.FetcherException; |
12 | 11 | import org.jabref.model.entry.BibEntry; |
13 | 12 | import org.jabref.model.entry.field.StandardField; |
14 | 13 | import org.jabref.model.entry.types.EntryType; |
15 | 14 | import org.jabref.model.entry.types.StandardEntryType; |
16 | 15 |
|
17 | | -/** |
18 | | - * Parse a plain citation using regex rules. |
19 | | - * <p> |
20 | | - * TODO: This class is similar to {@link org.jabref.logic.importer.fileformat.pdf.RuleBasedBibliographyPdfImporter}, we need to unify them. |
21 | | - */ |
| 16 | +/// Parse a plain citation using regex rules. |
| 17 | +/// |
| 18 | +/// TODO: This class is similar to {@link org.jabref.logic.importer.fileformat.pdf.RuleBasedBibliographyPdfImporter}, we need to unify them. |
22 | 19 | public class RuleBasedPlainCitationParser implements PlainCitationParser { |
23 | 20 | private static final String AUTHOR_TAG = "[author_tag]"; |
24 | 21 | private static final String URL_TAG = "[url_tag]"; |
@@ -52,16 +49,24 @@ public class RuleBasedPlainCitationParser implements PlainCitationParser { |
52 | 49 | "(p.)?\\s?\\d+(-\\d+)?", |
53 | 50 | Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); |
54 | 51 |
|
55 | | - private final List<String> urls = new ArrayList<>(); |
56 | | - private final List<String> authors = new ArrayList<>(); |
57 | | - private String year = ""; |
58 | | - private String pages = ""; |
59 | | - private String title = ""; |
60 | | - private boolean isArticle = true; |
61 | | - private String journalOrPublisher = ""; |
| 52 | + private List<String> urls; |
| 53 | + private List<String> authors; |
| 54 | + private String year; |
| 55 | + private String pages; |
| 56 | + private String title; |
| 57 | + private boolean isArticle; |
| 58 | + private String journalOrPublisher; |
62 | 59 |
|
63 | 60 | @Override |
64 | | - public Optional<BibEntry> parsePlainCitation(String text) throws FetcherException { |
| 61 | + public Optional<BibEntry> parsePlainCitation(String text) { |
| 62 | + urls = new ArrayList<>(); |
| 63 | + authors = new ArrayList<>(); |
| 64 | + year = ""; |
| 65 | + pages = ""; |
| 66 | + title = ""; |
| 67 | + isArticle = true; |
| 68 | + journalOrPublisher = ""; |
| 69 | + |
65 | 70 | String inputWithoutUrls = findUrls(text); |
66 | 71 | String inputWithoutAuthors = findAuthors(inputWithoutUrls); |
67 | 72 | String inputWithoutYear = findYear(inputWithoutAuthors); |
|
0 commit comments