/* * [RepairBornsInBookMacros.java] * * Summary: Fill in birth/death dates of authors if they don't have them already in macro Book. * * Copyright: (c) 2011-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2011-10-17 initial version */ package com.mindprod.repair; import com.mindprod.fastcat.FastCat; import java.io.File; import java.util.regex.Matcher; import java.util.regex.Pattern; import static java.lang.System.*; /** * Fill in birth/death dates of authors if they don't have them already in macro Book. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2011-10-17 initial version * @since 2011-10-17 */ class RepairBornsInBookMacros { /** * pattern of quote already handled, used to extract author in " " */ private static final Pattern AUTHOR_PATTERN_IN_BOOK_MACRO1 = Pattern.compile( "author=\"(.+?)\"", Pattern.DOTALL ); /** * pattern of quote already handled, used to extract author in {} */ private static final Pattern AUTHOR_PATTERN_IN_BOOK_MACRO2 = Pattern.compile( "author=\\{(.+?)\\}", Pattern.DOTALL ); /** * look for */ private static final Pattern BOOK_MACRO_PATTERN = Pattern.compile( "()", Pattern.DOTALL ); /** * pattern of quote already handled, used to extract author */ private static final Pattern MULTI_AUTHOR_SPLIT = Pattern.compile( "\\s+and\\s+|\\s+with\\s+|\\s+aka\\s+|,|&|\\(|\\)" ); /** * how many Book/DVD macros we corrected */ static int corrected = 0; /** * how many Book/DVD macros were missing birth fields */ static int missing = 0; /** * Study chuck, return modified