<commit_before>module DNSResolver
  class Resolver
    include DNSResolver::Logging
    include DNSResolver::Configuration
    include DNSResolver::Exceptions

    attr_reader :resolver

    def initialize(options = {})
      @options = DNSResolver.config.merge(options)
      @resolver = Resolv::DNS.new(:nameserver => @options[:nameservers])
    end

    def resolve(name)
      @resolver.getaddress(name)
    end

    def resolve_naptr(name, &callback)
      uris = []

      EM::DnsResolver::Request(EM::DnsResolver.socket, name, Resolv::DNS::Resource::IN::NAPTR).callback { |res|
        regex = res.regex
        c = regex[0,1]
        substr = regex[1,regex.length - 2]
        match, replace = substr.split(c)
        uris << name.gsub(/#{match}/, replace)
      }.errback { |e|
        logger.warn "Problem resolving #{name}"
        logger.warn e
      }.timeout(1, 'timeout')
<commit_msg>latest<commit_after>module DNSResolver
  class Resolver
    include DNSResolver::Logging
    include DNSResolver::Configuration
    include DNSResolver::Exceptions

    attr_reader :resolver

    def initialize(options = {})
      @options = DNSResolver.config.merge(options)
      @resolver = Resolv::DNS.new(:nameserver => @options[:nameservers])
    end

    def resolve(name)
      @resolver.getaddress(name)
    end

    def resolve_naptr(name, &callback)
      uris = []

      EM::DnsResolver::Request.new(EM::DnsResolver.socket, name, Resolv::DNS::Resource::IN::NAPTR).callback { |res|
        regex = res.regex
        c = regex[0,1]
        substr = regex[1,regex.length - 2]
        match, replace = substr.split(c)
        uris << name.gsub(/#{match}/, replace)
      }.errback { |e|
        logger.warn "Problem resolving #{name}"
        logger.warn e
      }.timeout(1, 'timeout')

{'fraction_non_alphanumeric': 0.132033426183844, 'fraction_numerical': 0.005571030640668524, 'mean_word_length': 2.921397379912664, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2732029', 'n_tokens_mistral': 579, 'n_tokens_neox': 552, 'n_words': 110}