<commit_before>module Api
  module Extensions
    module Fields
      # Process the fields functional extension
      def process_fields(keys, response, full_link = nil)
        fields = parse_fields keys
        response.reject! { |k, v| !fields.include? k } if fields.length > 0
        response['links']['full'] = { 'href' => full_link } unless full_link.nil?

        response
      end

      # Parse a string for the fields functional extension
      #   - Add the required fields if not present
      def parse_fields(fields_string)
        required_fields + fields_string.split(',')
      end

      # Get the required fields for any response<commit_msg>Added a little documentation :)<commit_after>#
# Fields extension
#
# https://github.com/ncuesta/api-doc/blob/master/README.en.md#partial-responses
#
module Api
  module Extensions
    module Fields
      # Process the fields functional extension
      def process_fields(keys, response, full_link = nil)
        fields = parse_fields keys
        response.reject! { |k, v| !fields.include? k } if fields.length > 0
        response['links']['full'] = { 'href' => full_link } unless full_link.nil?

        response
      end

      # Parse a string for the fields functional extension
      #   - Add the required fields if not present
      def parse_fields(fields_string)
        required_fields + fields_string.split(',')
      end

      # Get the required fields for any response
{'fraction_non_alphanumeric': 0.08638562543192813, 'fraction_numerical': 0.00138217000691085, 'mean_word_length': 2.761038961038961, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 1, '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': '1334434', 'n_tokens_mistral': 395, 'n_tokens_neox': 384, 'n_words': 129}