Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.importer.plaincitation

public Class RuleBasedPlainCitationParser

extends Object
implements PlainCitationParser
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.plaincitation.PlainCitationParser
Imports
java.util.ArrayList, .Arrays, .Calendar, .List, .Optional, java.util.regex.Matcher, .Pattern, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, org.jabref.model.entry.identifier.DOI, org.jabref.model.entry.types.EntryType, .StandardEntryType

Parse a plain citation using regex rules.

Todo

This class is similar to org.jabref.logic.importer.fileformat.pdf.RuleBasedBibliographyPdfImporter, we need to unify them.

Field Summary

Modifier and TypeField and Description
private static final Pattern
private static final Pattern
private static final String
private List<String>
private String
private static final String
private boolean
private String
private static final String
private String
private static final Pattern
private static final String
private String
private static final Pattern
private static final String
private List<String>
private String
private static final Pattern
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static boolean
containsDigit(String input)

Checks whether input contains at least one digit.

private String
private String
private String

Returns:

the input with the DOI stripped, or the original input if no DOI was found
findDoi
(String
raw citation text
input
)

Extracts the first DOI found in input, stores its canonical form in doi, and returns input with the matched DOI (including any leading doi: or https://doi.org/ prefix) removed so the remaining rules do not re-parse it as a URL or title.

private String
private String
private String
private String
private String
private String
GenerateAuthor(String lastName, String initials)

private Optional<BibEntry>
public Optional<BibEntry>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AUTHOR_PATTERNback to summary
private static final Pattern AUTHOR_PATTERN
AUTHOR_PATTERN_2back to summary
private static final Pattern AUTHOR_PATTERN_2
AUTHOR_TAGback to summary
private static final String AUTHOR_TAG
authorsback to summary
private List<String> authors
doiback to summary
private String doi
INITIALS_GROUPback to summary
private static final String INITIALS_GROUP
isArticleback to summary
private boolean isArticle
journalOrPublisherback to summary
private String journalOrPublisher
LASTNAME_GROUPback to summary
private static final String LASTNAME_GROUP
pagesback to summary
private String pages
PAGES_PATTERNback to summary
private static final Pattern PAGES_PATTERN
PAGES_TAGback to summary
private static final String PAGES_TAG
titleback to summary
private String title
URL_PATTERNback to summary
private static final Pattern URL_PATTERN
URL_TAGback to summary
private static final String URL_TAG
urlsback to summary
private List<String> urls
yearback to summary
private String year
YEAR_PATTERNback to summary
private static final Pattern YEAR_PATTERN
YEAR_TAGback to summary
private static final String YEAR_TAG

Constructor Detail

RuleBasedPlainCitationParserback to summary
public RuleBasedPlainCitationParser()

Method Detail

containsDigitback to summary
private static boolean containsDigit(String input)

Checks whether input contains at least one digit. Used instead of a ".*\\d.*" regex on user-provided text: a direct scan is linear time and not susceptible to regex backtracking on adversarial input.

findAuthorsback to summary
private String findAuthors(String input)
findAuthorsByPatternback to summary
private String findAuthorsByPattern(String input, Pattern pattern)
findDoiback to summary
private String findDoi(String input)

Extracts the first DOI found in input, stores its canonical form in doi, and returns input with the matched DOI (including any leading doi: or https://doi.org/ prefix) removed so the remaining rules do not re-parse it as a URL or title.

The DOI is replaced with an empty string rather than a placeholder token: findParts later infers the title and journal/publisher from the count of non-numeric segments, and a placeholder would skew that count because DOIs typically contain digits while a token like [doi_tag] would not.

Called before findUrls so a doi.org link is recorded as a DOI rather than being swallowed by the generic URL rule.

Parameters
input:String

raw citation text

Returns:String

the input with the DOI stripped, or the original input if no DOI was found

findPagesback to summary
private String findPages(String input)
findPartsback to summary
private String findParts(String input)
findUrlsback to summary
private String findUrls(String input)
findYearback to summary
private String findYear(String input)
fixSpacesback to summary
private String fixSpaces(String input)
GenerateAuthorback to summary
private String GenerateAuthor(String lastName, String initials)
generateEntityback to summary
private Optional<BibEntry> generateEntity(String input)
parsePlainCitationback to summary
public Optional<BibEntry> parsePlainCitation(String text)

Implements org.jabref.logic.importer.plaincitation.PlainCitationParser.parsePlainCitation.

Annotations
@Override