Search in sources :

Example 1 with NormalizeNamesFormatter

use of org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter in project jabref by JabRef.

the class EditorMenus method getNameMenu.

public static List<MenuItem> getNameMenu(TextArea textArea) {
    MenuItem normalizeNames = new MenuItem(Localization.lang("Normalize to BibTeX name format"));
    //normalizeNames.setTooltip(Localization.lang("If possible, normalize this list of names to conform to standard BibTeX name formatting"))
    normalizeNames.setOnAction(event -> textArea.setText(new NormalizeNamesFormatter().format(textArea.getText())));
    return Collections.singletonList(normalizeNames);
}
Also used : NormalizeNamesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) MenuItem(javafx.scene.control.MenuItem)

Example 2 with NormalizeNamesFormatter

use of org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter in project jabref by JabRef.

the class CiteSeerXFetcher method getSingleCitation.

private static BibEntry getSingleCitation(String urlString) throws IOException {
    String cont = new URLDownload(urlString).asString();
    // Find title, and create entry if we do. Otherwise assume we did not get an entry:
    Matcher m = CiteSeerXFetcher.TITLE_PATTERN.matcher(cont);
    if (m.find()) {
        BibEntry entry = new BibEntry();
        entry.setField(FieldName.TITLE, m.group(1));
        // Find authors:
        m = CiteSeerXFetcher.AUTHOR_PATTERN.matcher(cont);
        if (m.find()) {
            String authors = m.group(1);
            entry.setField(FieldName.AUTHOR, new NormalizeNamesFormatter().format(authors));
        }
        // Find year:
        m = CiteSeerXFetcher.YEAR_PATTERN.matcher(cont);
        if (m.find()) {
            entry.setField(FieldName.YEAR, m.group(1));
        }
        // Find abstract:
        m = CiteSeerXFetcher.ABSTRACT_PATTERN.matcher(cont);
        if (m.find()) {
            entry.setField(FieldName.ABSTRACT, m.group(1));
        }
        return entry;
    } else {
        return null;
    }
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) Matcher(java.util.regex.Matcher) NormalizeNamesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter) URLDownload(org.jabref.logic.net.URLDownload)

Example 3 with NormalizeNamesFormatter

use of org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter in project jabref by JabRef.

the class AstrophysicsDataSystem method doPostCleanup.

@Override
public void doPostCleanup(BibEntry entry) {
    new FieldFormatterCleanup(FieldName.ABSTRACT, new RemoveBracesFormatter()).cleanup(entry);
    new FieldFormatterCleanup(FieldName.TITLE, new RemoveBracesFormatter()).cleanup(entry);
    new FieldFormatterCleanup(FieldName.AUTHOR, new NormalizeNamesFormatter()).cleanup(entry);
    // Remove ADS note
    new FieldFormatterCleanup("adsnote", new ClearFormatter()).cleanup(entry);
    // Move adsurl to url field
    new MoveFieldCleanup("adsurl", FieldName.URL).cleanup(entry);
}
Also used : NormalizeNamesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter) RemoveBracesFormatter(org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) ClearFormatter(org.jabref.logic.formatter.bibtexfields.ClearFormatter) MoveFieldCleanup(org.jabref.logic.cleanup.MoveFieldCleanup)

Example 4 with NormalizeNamesFormatter

use of org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter in project jabref by JabRef.

the class IsbnViaEbookDeFetcher method doPostCleanup.

@Override
public void doPostCleanup(BibEntry entry) {
    // We MUST NOT clean the URL. this is the deal with ebook.de
    // DO NOT add following code:
    // new FieldFormatterCleanup(FieldName.URL, new ClearFormatter()).cleanup(entry);
    // Fetcher returns page numbers as "30 Seiten" -> remove every non-digit character in the PAGETOTAL field
    entry.getField(FieldName.PAGETOTAL).ifPresent(pages -> entry.setField(FieldName.PAGETOTAL, pages.replaceAll("[\\D]", "")));
    new FieldFormatterCleanup(FieldName.PAGETOTAL, new NormalizePagesFormatter()).cleanup(entry);
    new FieldFormatterCleanup(FieldName.AUTHOR, new NormalizeNamesFormatter()).cleanup(entry);
}
Also used : NormalizeNamesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) NormalizePagesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter)

Aggregations

NormalizeNamesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter)4 FieldFormatterCleanup (org.jabref.model.cleanup.FieldFormatterCleanup)2 Matcher (java.util.regex.Matcher)1 MenuItem (javafx.scene.control.MenuItem)1 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)1 MoveFieldCleanup (org.jabref.logic.cleanup.MoveFieldCleanup)1 ClearFormatter (org.jabref.logic.formatter.bibtexfields.ClearFormatter)1 NormalizePagesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter)1 RemoveBracesFormatter (org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter)1 URLDownload (org.jabref.logic.net.URLDownload)1 BibEntry (org.jabref.model.entry.BibEntry)1