<commit_before>// StringParseUtil.java

package ed.util;

public final class StringParseUtil {
    

    public static boolean parseBoolean( String s , boolean d ){

        if ( s == null )
            return d;
        
        s = s.trim();
        if ( s.length() == 0 )
            return d;
        
        char c = s.charAt( 0 );

        if ( c == 't' || c == 'T' ||
             c == 'y' || c == 'Y' )
            return true;

        if ( c == 'f' || c == 'F' ||
             c == 'n' || c == 'N' )
            return false;
        
        return d;
    }

    public static int parseInt( String s , int def ){
        return parseInt( s , def , null , true );
    }

    public static Number parseIntRadix( String s , int radix ){
        if ( s == null )
            return Double.NaN;
        
        s = s.trim();
        if ( s.length() == 0 )
            return Double.NaN;

        int firstDigit = -1;
        int i = 0;
        if ( s.charAt( 0 ) == '-' ) 
            i = 1;
        for ( ; i<s.length(); i++ ){
            char c = s.charAt ( i );
            if ( '0' <= c && c <= '9' && c < '0' + radix ){
                // OK; c is 0..n-1
            }
            else if ( 'a' <= c && c <= 'z' && c < 'a' + radix - 10 ){
                // OK; if radix is 11, c can be 'a', etc.
            }
            else if ( 'A' <= c && c <= 'Z' && c < 'A' + radix - 10 ){
                // OK; same as above, with caps.
            }
            else {
                break;
            }
        }
        
        try {
            return Integer.parseInt( s.substring( 0, i ) , radix );
        }
        catch (Exception e) {
            return Double.NaN;
        }
    }

    public static int parseInt( String s , int def , final int[] lastIdx , final boolean allowNegative ){
        final boolean useLastIdx = lastIdx != null && lastIdx.length > 0;
        if ( useLastIdx )
            lastIdx[0] = -1;
        
        if ( s == null )
            return def;
        
        s = s.trim();
        if ( s.length() == 0 )
            return def;

        int firstDigit = -1;
        for ( int i=0; i<s.length(); i++ ){
            if ( Character.isDigit( s.charAt( i ) ) ){
                firstDigit = i;
                break;<commit_msg>Simplify code using Java functions.<commit_after>// StringParseUtil.java

package ed.util;

public final class StringParseUtil {
    

    public static boolean parseBoolean( String s , boolean d ){

        if ( s == null )
            return d;
        
        s = s.trim();
        if ( s.length() == 0 )
            return d;
        
        char c = s.charAt( 0 );

        if ( c == 't' || c == 'T' ||
             c == 'y' || c == 'Y' )
            return true;

        if ( c == 'f' || c == 'F' ||
             c == 'n' || c == 'N' )
            return false;
        
        return d;
    }

    public static int parseInt( String s , int def ){
        return parseInt( s , def , null , true );
    }

    public static Number parseIntRadix( String s , int radix ){
        if ( s == null )
            return Double.NaN;
        
        s = s.trim();
        if ( s.length() == 0 )
            return Double.NaN;

        int firstDigit = -1;
        int i = 0;
        if ( s.charAt( 0 ) == '-' ) 
            i = 1;
        // Find first non-digit.
        for ( ; i<s.length(); i++ ){
            if ( Character.digit( s.charAt( i ) , radix ) == -1 )
                break;
        }
        
        try {
            return Integer.parseInt( s.substring( 0, i ) , radix );
        }
        catch (Exception e) {
            return Double.NaN;
        }
    }

    public static int parseInt( String s , int def , final int[] lastIdx , final boolean allowNegative ){
        final boolean useLastIdx = lastIdx != null && lastIdx.length > 0;
        if ( useLastIdx )
            lastIdx[0] = -1;
        
        if ( s == null )
            return def;
        
        s = s.trim();
        if ( s.length() == 0 )
            return def;

        int firstDigit = -1;
        for ( int i=0; i<s.length(); i++ ){
            if ( Character.isDigit( s.charAt( i ) ) ){
                firstDigit = i;
                break;
{'fraction_non_alphanumeric': 0.13811892916370527, 'fraction_numerical': 0.009476427386875147, 'mean_word_length': 1.12054244098443, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 5, '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': '915388', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1273, 'n_words': 403}