<commit_before>require 'umakadata/http_helper'
require 'umakadata/logging/log'

module Umakadata
  module Criteria
    module ContentNegotiation

      include Umakadata::HTTPHelper

      def check_content_negotiation(uri, content_type, logger: nil)
        query = <<-'SPARQL'
SELECT
  *
WHERE {
        GRAPH ?g { ?s ?p ?o } .
      }
LIMIT 1
SPARQL

        args = {:headers => {'Accept' => content_type}, :logger => logger}
        request = URI(uri.to_s + "?query=" + query)

        response = http_get_recursive(request, args)
        if !response.is_a?(Net::HTTPSuccess)
          logger.result = 'The endpoint could not return 200 HTTP response' unless logger.nil?
          return false
        end

        result = response.content_type == content_type
        if result
          logger.result = "The endpoint supports #{content_type} format by content_negotiation" unless logger.nil?
        else
          logger.result = "The endpoint could not support #{content_type} format by content_negotiation" unless logger.nil?
        end
        result
      end
    end
  end
end<commit_msg>Modify log message to content_negotiation<commit_after>require 'umakadata/http_helper'
require 'umakadata/logging/log'

module Umakadata
  module Criteria
    module ContentNegotiation

      include Umakadata::HTTPHelper

      def check_content_negotiation(uri, content_type, logger: nil)
        query = <<-'SPARQL'
SELECT
  *
WHERE {
        GRAPH ?g { ?s ?p ?o } .
      }
LIMIT 1
SPARQL

        args = {:headers => {'Accept' => content_type}, :logger => logger}
        request = URI(uri.to_s + "?query=" + query)

        response = http_get_recursive(request, args)
        if !response.is_a?(Net::HTTPSuccess)
          logger.result = 'The endpoint does not return 200 HTTP response' unless logger.nil?
          return false
        end

        result = response.content_type == content_type
        if result
          logger.result = "The endpoint supports #{content_type} in the content negotiation" unless logger.nil?
        else
          logger.result = "The endpoint does not support #{content_type} in the content negotiation" unless logger.nil?
        end
        result
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08812949640287769, 'fraction_numerical': 0.0035971223021582736, 'mean_word_length': 2.6061588330632093, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3437619', 'n_tokens_mistral': 658, 'n_tokens_neox': 634, 'n_words': 189}