<commit_before>package edu.wustl.common.querysuite.queryobject;

// TODO (date - date) = numeric (days). this is a limitation.
// NOTE: Thus, DateOffset is NEVER a result of any operation.

// TODO use termtype of LHS to validate RHS.
public enum TermType {
    // TODO String?
    // TODO DateOffset + Numeric??

    // TODO Boolean ??
    Date, DateOffset, Numeric, Invalid;

    public static TermType getResultTermType(TermType leftOpndType, TermType rightOpndType,
            ArithmeticOperator operator) {
        if (leftOpndType == Invalid || rightOpndType == Invalid) {
            return Invalid;
        }
        if (leftOpndType == Numeric && rightOpndType == Numeric) {
            return Numeric;
        }
        if (leftOpndType == Date && rightOpndType == Date && operator == ArithmeticOperator.Minus) {
            return Numeric;
        }
        if (leftOpndType == Date && (rightOpndType == DateOffset || rightOpndType == Numeric)
                && (operator == ArithmeticOperator.Plus || operator == ArithmeticOperator.Minus)) {
            return Date;
        }
        if ((leftOpndType == DateOffset || leftOpndType == Numeric) && rightOpndType == Date
                && operator == ArithmeticOperator.Plus) {
            return Date;
        }
        return Invalid;

    }
}<commit_msg>*** empty log message ***<commit_after>package edu.wustl.common.querysuite.queryobject;

// TODO (date - date) = numeric (days). this is a limitation.
// NOTE: Thus, DateOffset is NEVER a result of any operation.

// TODO use termtype of LHS to validate RHS.
public enum TermType {
    // TODO String?
    // TODO DateOffset + Numeric??

    // TODO Boolean ??
    Date, DateOffset, Numeric, Invalid;

    /**
     * Date (D), Numeric (N), dateOffset(O).
     * <ul>
     * <li>D +/- N = D</li>
     * <li>D +/- O = D</li>
     * <li>D - D = N</li>
     * </ul>
     * otherwise Invalid.
     * 
     * @param leftOpndType
     * @param rightOpndType
     * @param operator
     * @return
     */
    public static TermType getResultTermType(TermType leftOpndType, TermType rightOpndType,
            ArithmeticOperator operator) {
        if (leftOpndType == Invalid || rightOpndType == Invalid) {
            return Invalid;
        }
        if (leftOpndType == Numeric && rightOpndType == Numeric) {
            return Numeric;
        }
        if (leftOpndType == Date && rightOpndType == Date && operator == ArithmeticOperator.Minus) {
            return Numeric;
        }
        if (leftOpndType == Date && (rightOpndType == DateOffset || rightOpndType == Numeric)
                && (operator == ArithmeticOperator.Plus || operator == ArithmeticOperator.Minus)) {
            return Date;
        }
        if ((leftOpndType == DateOffset || leftOpndType == Numeric) && rightOpndType == Date
                && operator == ArithmeticOperator.Plus) {
            return Date;
        }
        return Invalid;

    }
}
{'fraction_non_alphanumeric': 0.11766700576466599, 'fraction_numerical': 0.0, 'mean_word_length': 2.1823085221143472, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4889816', 'n_tokens_mistral': 865, 'n_tokens_neox': 834, 'n_words': 231}