<commit_before>// DNSUtil.java

package ed.net;

import java.io.*;
import java.net.*;
import java.util.*;

public class DNSUtil {

    public static String getSubdomain( String host ){
        String domain = getDomain( host );
        if ( host.length() == domain.length() )
            return "www";
        String sub = host.substring( 0 , host.length() - domain.length() );
        while ( sub.endsWith( "." ) )
            sub = sub.substring( 0 , sub.length() - 1 );
        sub = sub.trim();
        if ( sub.length() == 0 )
            return "www";
        return sub;
    }

    public static String getDomain( String host ){
        String tld = getTLD( host );
        int idx = host.lastIndexOf( "." , host.length() - ( tld.length() + 2 ) );
        if ( idx < 0 )
            return host;
        return host.substring( idx + 1 );
    }
    
    public static String getTLD( String host ){
        
        host = host.toLowerCase();

        // efficiency hack
        if ( host.endsWith( ".com" ) )
            return "com";
        
        int idx = host.lastIndexOf( "." );<commit_msg>getJustDomainName<commit_after>// DNSUtil.java

package ed.net;

import java.io.*;
import java.net.*;
import java.util.*;

public class DNSUtil {

    public static String getSubdomain( String host ){
        String domain = getDomain( host );
        if ( host.length() == domain.length() )
            return "www";
        String sub = host.substring( 0 , host.length() - domain.length() );
        while ( sub.endsWith( "." ) )
            sub = sub.substring( 0 , sub.length() - 1 );
        sub = sub.trim();
        if ( sub.length() == 0 )
            return "www";
        return sub;
    }

    public static String getDomain( String host ){
        String tld = getTLD( host );
        int idx = host.lastIndexOf( "." , host.length() - ( tld.length() + 2 ) );
        if ( idx < 0 )
            return host;
        return host.substring( idx + 1 );
    }

    public static String getJustDomainName( String host ){
        String tld = getTLD( host );
        host = host.substring( 0 , host.length() - ( tld.length() + 1 ) );

        int idx = host.lastIndexOf( "." );
        if ( idx < 0 )
            return host;
        return host.substring( idx + 1 );
    }
    
    public static String getTLD( String host ){
        
        host = host.toLowerCase();

        // efficiency hack
        if ( host.endsWith( ".com" ) )
            return "com";
        
        int idx = host.lastIndexOf( "." );
{'fraction_non_alphanumeric': 0.13827258320126784, 'fraction_numerical': 0.0071315372424722665, 'mean_word_length': 1.7121374865735768, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '95971', 'n_tokens_mistral': 757, 'n_tokens_neox': 723, 'n_words': 214}