<commit_before>module LogParser::Record::Content
  class User < Base
    attr_reader :user_id

    def initialize(user_id)
      @user_id = user_id
    end

    def student?
      if @user_id =~ fetch_config(:student_id, :legal_pattern)
        %i(faculty department).all? do |item|
          fetch_config(item).values.flatten.map(&:to_s).include?(Regexp.last_match[item])
        end
      else
        false
      end
    end

    def join_year
      @user_id.slice(fetch_config(:student_id, :legal_pattern), :join_year) if student?
    end

    def faculty
      get_section(:faculty) if student?
    end

    def department
      get_section(:department) if student?
    end

    private

    def get_section(query)
      fetch_config(query).find(->{[nil]}) {|_, codes|
        match = @user_id.slice(fetch_config(:student_id, :legal_pattern), query)<commit_msg>remove default value (nil) of `get_section'<commit_after>module LogParser::Record::Content
  class User < Base
    attr_reader :user_id

    def initialize(user_id)
      @user_id = user_id
    end

    def student?
      if @user_id =~ fetch_config(:student_id, :legal_pattern)
        %i(faculty department).all? do |item|
          fetch_config(item).values.flatten.map(&:to_s).include?(Regexp.last_match[item])
        end
      else
        false
      end
    end

    def join_year
      @user_id.slice(fetch_config(:student_id, :legal_pattern), :join_year) if student?
    end

    def faculty
      get_section(:faculty) if student?
    end

    def department
      get_section(:department) if student?
    end

    private

    def get_section(query)
      fetch_config(query).find {|_, codes|
        match = @user_id.slice(fetch_config(:student_id, :legal_pattern), query)
{'fraction_non_alphanumeric': 0.10394060536836093, 'fraction_numerical': 0.0, 'mean_word_length': 2.9020044543429844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '1065978', 'n_tokens_mistral': 573, 'n_tokens_neox': 556, 'n_words': 118}