<commit_before>package lcm.lc;

import java.util.*;
import java.util.regex.*;

public class URLParser
{
    String protocol;
    String host;
    String port;

    HashMap<String,String> params = new HashMap<String,String>();
    
    public URLParser(String url)
    {
	Matcher m = Pattern.compile("([^\\:]+)://([a-zA-Z0-9/\\.]+)?(:([0-9]+))?(\\?(.*))?").matcher(url);

	if (!m.matches()) {
	    System.out.println("URLParser: Invalid url: "+url);
	    return;
	}

	params.put("protocol", m.group(1));
	params.put("host", m.group(2));
	params.put("port", m.group(4));

	String paramString = m.group(6);

	if (paramString != null) {
	    String keyvalues[] = paramString.split("&");
	    for (int i = 0; i < keyvalues.length; i++) {
		String toks[] = keyvalues[i].split("=");
		if (toks.length != 2) 
		    System.out.println("Invalid key-value pair in URL : "+keyvalues[i]);
		else
		    params.put(toks[0], toks[1]);
	    }
	}

	/*
	System.out.println(paramString);

	System.out.println("protocol: "+protocol);
	System.out.println("host:     "+host);
	System.out.println("port:     "+port);

	for (String key : params.keySet()) {
	    System.out.printf("param %15s: %s\n", key, params.get(key));
	}
	*/
    }

    public String get(String key)
    {
	return params.get(key);
    }
    
    public String get(String key, String def)
    {
	if (params.get(key)==null)
	    return def;

	return params.get(key);
    }

    public int get(String key, int def)
    {
	String v = params.get(key);
	if (v==null)
	    return def;
	return Integer.parseInt(v);
    }

    public boolean get(String key, boolean def)
    {
	String v = params.get(key);
	if (v==null)
	    return def;
	return Boolean.parseBoolean(v);
    }

    public double get(String key, double def)
    {
	String v = params.get(key);
	if (v==null)
	    return def;
	return Double.parseDouble(v);
    }

    public static void main(String args[])
    {
	new URLParser(args[0]);
    }
}<commit_msg>urlparser: accept 1 as true<commit_after>package lcm.lc;

import java.util.*;
import java.util.regex.*;

public class URLParser
{
    String protocol;
    String host;
    String port;

    HashMap<String,String> params = new HashMap<String,String>();
    
    public URLParser(String url)
    {
	Matcher m = Pattern.compile("([^\\:]+)://([a-zA-Z0-9/\\.]+)?(:([0-9]+))?(\\?(.*))?").matcher(url);

	if (!m.matches()) {
	    System.out.println("URLParser: Invalid url: "+url);
	    return;
	}

	params.put("protocol", m.group(1));
	params.put("host", m.group(2));
	params.put("port", m.group(4));

	String paramString = m.group(6);

	if (paramString != null) {
	    String keyvalues[] = paramString.split("&");
	    for (int i = 0; i < keyvalues.length; i++) {
		String toks[] = keyvalues[i].split("=");
		if (toks.length != 2) 
		    System.out.println("Invalid key-value pair in URL : "+keyvalues[i]);
		else
		    params.put(toks[0], toks[1]);
	    }
	}

	/*
	System.out.println(paramString);

	System.out.println("protocol: "+protocol);
	System.out.println("host:     "+host);
	System.out.println("port:     "+port);

	for (String key : params.keySet()) {
	    System.out.printf("param %15s: %s\n", key, params.get(key));
	}
	*/
    }

    public String get(String key)
    {
	return params.get(key);
    }
    
    public String get(String key, String def)
    {
	if (params.get(key)==null)
	    return def;

	return params.get(key);
    }

    public int get(String key, int def)
    {
	String v = params.get(key);
	if (v==null)
	    return def;
	return Integer.parseInt(v);
    }

    public boolean get(String key, boolean def)
    {
	String v = params.get(key);
	if (v==null)
	    return def;
	return Boolean.parseBoolean(v) || v.equals("1");
    }

    public double get(String key, double def)
    {
	String v = params.get(key);
	if (v==null)
	    return def;
	return Double.parseDouble(v);
    }

    public static void main(String args[])
    {
	new URLParser(args[0]);
    }
}
{'fraction_non_alphanumeric': 0.18453738910012674, 'fraction_numerical': 0.008111533586818757, 'mean_word_length': 2.9778225806451615, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3372403', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1404, 'n_words': 315}