<commit_before>require "active_model"
require "metadata/ingest/form_backer"
require "metadata/ingest/association"

module Metadata
  module Ingest
    # Form-backing object for ingesting generic data
    class Form < FormBacker
      # Container for raw RDF data stored as an array of hashes for easy use on forms (currently used
      # for statements which didn't match the digital object's subject)
      attr_reader :raw_statements

      include ActiveModel::Validations

      validate :children_must_be_valid

      class << self
        # This makes our object work better with various gems, particularly cocoon.  This probably
        # doesn't belong here, but I know this is necessary within the context of the whole project.
        #
        # The code here is basically telling cocoon (and any other Railsy gems that care to ask) that
        # it has no explicit associations (has_many, for instance).  Being non-ActiveRecord, this is
        # the easiest and safest approach.
        def reflect_on_association(association)
          return nil
        end
      end

      def initialize(attr = {})
        @raw_statements = []
        @data = {}
        @empty = true
        self.attributes = attr if attr
      end

      # Assigns list of groups for ingest forms to use.  Please note:
      # - This should only be set ONCE unless you REALLY know what you're doing
      # - The groups should be strings, not symbols
      # - Groups should be singular - "title", not "titles" - in order to work with the magic in
      #   the dynamic_method_map function.
      def internal_groups=(val)
        @internal_groups = val
      end

      def internal_groups
        @internal_groups ||= []
        return @internal_groups
      end

      def association_class
        @association_class ||= Ingest::Association
        return @association_class
      end

      def association_class=(klass)
        @association_class = klass
      end

      def groups
        return internal_groups + ["unmapped_association"]
      end

      def valid_group?(group)
        return groups.include?(group)
      end
<commit_msg>Use full namespace for association class<commit_after>require "active_model"
require "metadata/ingest/form_backer"
require "metadata/ingest/association"

module Metadata
  module Ingest
    # Form-backing object for ingesting generic data
    class Form < FormBacker
      # Container for raw RDF data stored as an array of hashes for easy use on forms (currently used
      # for statements which didn't match the digital object's subject)
      attr_reader :raw_statements

      include ActiveModel::Validations

      validate :children_must_be_valid

      class << self
        # This makes our object work better with various gems, particularly cocoon.  This probably
        # doesn't belong here, but I know this is necessary within the context of the whole project.
        #
        # The code here is basically telling cocoon (and any other Railsy gems that care to ask) that
        # it has no explicit associations (has_many, for instance).  Being non-ActiveRecord, this is
        # the easiest and safest approach.
        def reflect_on_association(association)
          return nil
        end
      end

      def initialize(attr = {})
        @raw_statements = []
        @data = {}
        @empty = true
        self.attributes = attr if attr
      end

      # Assigns list of groups for ingest forms to use.  Please note:
      # - This should only be set ONCE unless you REALLY know what you're doing
      # - The groups should be strings, not symbols
      # - Groups should be singular - "title", not "titles" - in order to work with the magic in
      #   the dynamic_method_map function.
      def internal_groups=(val)
        @internal_groups = val
      end

      def internal_groups
        @internal_groups ||= []
        return @internal_groups
      end

      def association_class
        @association_class ||= Metadata::Ingest::Association
        return @association_class
      end

      def association_class=(klass)
        @association_class = klass
      end

      def groups
        return internal_groups + ["unmapped_association"]
      end

      def valid_group?(group)
        return groups.include?(group)
      end

{'fraction_non_alphanumeric': 0.05755395683453238, 'fraction_numerical': 0.0, 'mean_word_length': 2.4424920127795526, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '6245452', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1092, 'n_words': 439}