<commit_before>module Ecore
  module Labels

    attr_accessor :primary_label_id

    # returns all nodes labeled with current node
    # this method is similar to a hierarchical "children" method
    #
    # ==== Paramters
    #
    # +options+ - options hash containing only :type => ClassName or "class_name"
    #
    def nodes(attrs={})
      cond = "label_node_ids LIKE '%#{id}%'"
      (cond << " AND " << attrs[:conditions]) if attrs[:conditions] and attrs[:conditions].is_a?(String)
      options = {:conditions => cond}
      options[:order] = attrs[:order] if attrs[:order]
      options[:limit] = attrs[:limit] if attrs[:limit]
      if attrs.is_a?(Hash) and !attrs[:type].blank?
        const = attrs[:type]
        const = const.classify.constantize if const.is_a?(String)
        const.find(session, options)
      else
        Ecore::Node.find(session, options)
      end
    end

    # finds all nodes within the current node (similar to find method, but
    # not session is required). Only :conditions => "STRING" is allowed
    #
    # ==== Parameters
    #
    # +find_options+ - like in active_record plus 'type' which will be
    # filtered out before passed on to active_record an only nodes of that
    # type will be looked up then. node_type can only take one class
    # 
    # e.g.:
    # @node.find(:type => Contact, :name => "strauss")
    #
    def find(options={})
      ns = NodeArray.new
      type = options.delete(:type)
      nodes(:type => type).each do |n|
        if options.size > 0 and options.is_a?(Hash)
          met = true
          options.each_pair do |key,value|<commit_msg>.nodes method takes :conditions, :order and :limit<commit_after>module Ecore
  module Labels

    attr_accessor :primary_label_id

    # returns all nodes labeled with current node
    # this method is similar to a hierarchical "children" method
    #
    # ==== Paramters
    #
    # +options+ - options hash containing only :type => ClassName or "class_name"
    #
    def nodes(attrs={})
      cond = "label_node_ids LIKE '%#{id}%'"
      (cond << " AND (" << attrs[:conditions] << ")") if attrs[:conditions] and attrs[:conditions].is_a?(String)
      options = {:conditions => cond}
      options[:order] = attrs[:order] if attrs[:order]
      options[:limit] = attrs[:limit] if attrs[:limit]
      if attrs.is_a?(Hash) and !attrs[:type].blank?
        const = attrs[:type]
        const = const.classify.constantize if const.is_a?(String)
        const.find(session, options)
      else
        Ecore::Node.find(session, options)
      end
    end

    # finds all nodes within the current node (similar to find method, but
    # not session is required). Only :conditions => "STRING" is allowed
    #
    # ==== Parameters
    #
    # +find_options+ - like in active_record plus 'type' which will be
    # filtered out before passed on to active_record an only nodes of that
    # type will be looked up then. node_type can only take one class
    # 
    # e.g.:
    # @node.find(:type => Contact, :name => "strauss")
    #
    def find(options={})
      ns = NodeArray.new
      type = options.delete(:type)
      nodes(:type => type).each do |n|
        if options.size > 0 and options.is_a?(Hash)
          met = true
          options.each_pair do |key,value|
{'fraction_non_alphanumeric': 0.1223808077740662, 'fraction_numerical': 0.0006073489219556636, 'mean_word_length': 2.701123595505618, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5797545', 'n_tokens_mistral': 978, 'n_tokens_neox': 984, 'n_words': 311}