<commit_before>
package org.marc4j;

import java.util.Properties;

public class MarcReaderConfig {

    private boolean permissiveReader;

    private String defaultEncoding;

    private boolean to_utf_8;

    private String combineConsecutiveRecordsFields = null;

    private String combineRecordsLeftField = null;

    private String combineRecordsRightField = null;

    private String unicodeNormalize = null;

    private String includeIfPresent = null;

    private String includeIfMissing = null;

    private String marcDeleteSubfields = null;

    private String marcRemapFile = null;

    public MarcReaderConfig(Properties configProps) {
        setCombineConsecutiveRecordsFields(configProps.getProperty("marc.combine_records"),
                configProps.getProperty("marc.combine_records.left_field"), configProps
                        .getProperty("marc.combine_records.right_field"));

        setPermissiveReader(Boolean.parseBoolean(configProps.getProperty("marc.permissive")));

        setDefaultEncoding(configProps.getProperty("marc.default_encoding"));

        setToUtf8(Boolean.parseBoolean(configProps.getProperty("marc.to_utf_8")));

        setUnicodeNormalize(configProps.getProperty("marc.unicode_normalize"));

        setFilterParams(configProps.getProperty("marc.include_if_present"), configProps
                .getProperty("marc.include_if_missing"));

        setDeleteSubfieldSpec(configProps.getProperty("marc.delete_subfields"));

        setMarcRemapFilename(configProps.getProperty("marc.reader.remap"));
    }

    public MarcReaderConfig() {
        defaultEncoding = null;
        permissiveReader = false;
        to_utf_8 = false;
        combineConsecutiveRecordsFields = null;
        unicodeNormalize = null;
    }

    public boolean isPermissiveReader() {
        return permissiveReader;
    }

    public MarcReaderConfig setPermissiveReader(boolean permissiveReader) {
        this.permissiveReader = permissiveReader;
        return this;
    }

    public String getDefaultEncoding() {
        if (defaultEncoding == null) {
            return (isPermissiveReader()) ? "BESTGUESS" : "MARC8";
        } else {
            return defaultEncoding;
        }
    }

    public MarcReaderConfig setDefaultEncoding(final String defaultEncoding) {
        if (defaultEncoding == null) {
            this.defaultEncoding = null;
        } else {
            this.defaultEncoding = defaultEncoding.trim();
        }
        return this;
    }

    public boolean toUtf8() {
        return to_utf_8;
    }

    public MarcReaderConfig setToUtf8(boolean to_utf_8) {
        this.to_utf_8 = to_utf_8;
        return this;
    }

    public String getCombineConsecutiveRecordsFields() {
        return combineConsecutiveRecordsFields;
    }

    public String getCombineRecordsLeftField() {
        return combineRecordsLeftField;
    }

    public String getCombineRecordsRightField() {
        return combineRecordsRightField;
    }

    public MarcReaderConfig setCombineConsecutiveRecordsFields(
            final String combineConsecutiveRecordsFields, final String leftField,
            final String rightField) {
        this.combineConsecutiveRecordsFields = combineConsecutiveRecordsFields;

        if (combineConsecutiveRecordsFields != null && combineConsecutiveRecordsFields.length() == 0) {
            this.combineConsecutiveRecordsFields = null;
        }
        combineRecordsLeftField = leftField;
        combineRecordsRightField = rightField;

        return this;
    }

    public String getUnicodeNormalize() {
        return unicodeNormalize;<commit_msg>allow the combine records feature to be initialized from a specially encoded string that can be provided as a command line argument<commit_after>
package org.marc4j;

import java.util.Properties;

public class MarcReaderConfig {

    private boolean permissiveReader;

    private String defaultEncoding;

    private boolean to_utf_8;

    private String combineConsecutiveRecordsFields = null;

    private String combineRecordsLeftField = null;

    private String combineRecordsRightField = null;

    private String unicodeNormalize = null;

    private String includeIfPresent = null;

    private String includeIfMissing = null;

    private String marcDeleteSubfields = null;

    private String marcRemapFile = null;

    public MarcReaderConfig(Properties configProps) {
        setCombineConsecutiveRecordsFields(configProps.getProperty("marc.combine_records"),
                configProps.getProperty("marc.combine_records.left_field"), configProps
                        .getProperty("marc.combine_records.right_field"));

        setPermissiveReader(Boolean.parseBoolean(configProps.getProperty("marc.permissive")));

        setDefaultEncoding(configProps.getProperty("marc.default_encoding"));

        setToUtf8(Boolean.parseBoolean(configProps.getProperty("marc.to_utf_8")));

        setUnicodeNormalize(configProps.getProperty("marc.unicode_normalize"));

        setFilterParams(configProps.getProperty("marc.include_if_present"), configProps
                .getProperty("marc.include_if_missing"));

        setDeleteSubfieldSpec(configProps.getProperty("marc.delete_subfields"));

        setMarcRemapFilename(configProps.getProperty("marc.reader.remap"));
    }

    public MarcReaderConfig() {
        defaultEncoding = null;
        permissiveReader = false;
        to_utf_8 = false;
        combineConsecutiveRecordsFields = null;
        unicodeNormalize = null;
    }

    public boolean isPermissiveReader() {
        return permissiveReader;
    }

    public MarcReaderConfig setPermissiveReader(boolean permissiveReader) {
        this.permissiveReader = permissiveReader;
        return this;
    }

    public String getDefaultEncoding() {
        if (defaultEncoding == null) {
            return (isPermissiveReader()) ? "BESTGUESS" : "MARC8";
        } else {
            return defaultEncoding;
        }
    }

    public MarcReaderConfig setDefaultEncoding(final String defaultEncoding) {
        if (defaultEncoding == null) {
            this.defaultEncoding = null;
        } else {
            this.defaultEncoding = defaultEncoding.trim();
        }
        return this;
    }

    public boolean toUtf8() {
        return to_utf_8;
    }

    public MarcReaderConfig setToUtf8(boolean to_utf_8) {
        this.to_utf_8 = to_utf_8;
        return this;
    }

    public String getCombineConsecutiveRecordsFields() {
        return combineConsecutiveRecordsFields;
    }

    public String getCombineRecordsLeftField() {
        return combineRecordsLeftField;
    }

    public String getCombineRecordsRightField() {
        return combineRecordsRightField;
    }

    public MarcReaderConfig setCombineConsecutiveRecordsFields(
            final String combineConsecutiveRecordsFields, final String leftField,
            final String rightField) {
        this.combineConsecutiveRecordsFields = combineConsecutiveRecordsFields;

        if (combineConsecutiveRecordsFields != null && combineConsecutiveRecordsFields.length() == 0) {
            this.combineConsecutiveRecordsFields = null;
        }
        combineRecordsLeftField = leftField;
        combineRecordsRightField = rightField;

        return this;
    }

    public MarcReaderConfig setCombineConsecutiveRecordsFields(final String combineConsecutiveRecordsFieldsStr) {
        if (combineConsecutiveRecordsFieldsStr == null ||
            combineConsecutiveRecordsFieldsStr.isEmpty() ) {
            return(setCombineConsecutiveRecordsFields(null, null, null));
        }
        String combineParms[] = combineConsecutiveRecordsFieldsStr.split("::",3);
        String fieldList =  combineParms.length >= 1 ? combineParms[0] : null;
        String leftField =  combineParms.length >= 2 ? combineParms[1] : null;
        String rightField = combineParms.length >= 3 ? combineParms[2] : null;
        return(setCombineConsecutiveRecordsFields(combineConsecutiveRecordsFields, leftField, rightField));
    }

    public String getUnicodeNormalize() {
        return unicodeNormalize;
{'fraction_non_alphanumeric': 0.07456626061277224, 'fraction_numerical': 0.004060538944259874, 'mean_word_length': 3.1767728674203495, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 6, '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': '5509091', 'n_tokens_mistral': 2157, 'n_tokens_neox': 2087, 'n_words': 412}