/* * [SortableQuote.java] * * Summary: Comparable to Sort quotations by author. * * Copyright: (c) 2009-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 2009-01-01 initial version. */ package com.mindprod.htmlmacros; import com.mindprod.common18.BigDate; import com.mindprod.common18.ST; import com.mindprod.entities.DeEntifyStrings; import com.mindprod.fastcat.FastCat; import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.Comparator; import java.util.HashSet; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Comparable to Sort quotations by author. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2009-01-01 initial version. * File to sort contains byDate, ByWeight, ByFrequency, ByWeight * @since 2009 */ class SortableQuote implements Comparable { /** * Regex pattern we look for embedded in big string. By default case-sensitive. */ private static final Pattern WEIGHT_FINDER = Pattern.compile( "" ); /** * Regex pattern we look for embedded in big string. By default case-sensitive. */ private static final Pattern ADDED_DATE_FINDER = Pattern.compile( "" ); /** * words ignored in sort */ private static final HashSet noiseWords = new HashSet<>( Arrays.asList( "a", "about", "as", "by", "is", "of", "the", "to" ) ); private static final Pattern SPLIT_ON_SPACE = Pattern.compile( " " ); /** * in lower case for sort, never displayed */ final String authorGivenName; /** * in lower case for sort, newer displayed */ final String authorSurname; /** * in lower case for sort, includes title between

*/ final String heading; /** * in lower case for sort, includes first part of quotation body */ final String precis; /** * weight, 0 if none */ final int weight; /** * bigdate ordinal */ final int date; /** * in mixed case, the complete quotation including
and
*/ final String quotation; /** * true if contains

*/ private final boolean hasTitle; /** * used to sort quotations * * @param author the author of the quotation, parsed out. * @param quotation, the complete quotation including
and
*/ SortableQuote( String author, String quotation ) { // might be bible verse as author // author = author.trim(); if ( author.startsWith( "