<commit_before>module Pacer
  # Methods to be mixed into Blueprints Graph objects from any
  # implementation.
  #
  # Adds more convenient/rubyish methods and adds support for extensions
  # to some methods where needed.
  module GraphMixin
    def self.included(target)
      target.class_eval do
        protected :addVertex, :addEdge
        protected :add_vertex, :add_edge rescue nil
        protected :getVertex, :getEdge
        protected :get_vertex, :get_edge rescue nil
      end
    end

    attr_accessor :in_bulk_job

    def graph_id
      @graph_id = Pacer.next_graph_id unless defined? @graph_id
      @graph_id
    end

    # Get a vertex by id.
    #
    # @overload vertex(id)
    #   @param [element id] id
    # @overload vertex(id, *modules)
    #   @param [element id] id
    #   @param [Module, Class] *modules extensions to add to the returned
    #     vertex.
    def vertex(id, *modules)
      v = getVertex(id) rescue nil
      if v
        wrapper = modules.detect { |obj| obj.ancestors.include? Pacer::Wrappers::VertexWrapper }
        if wrapper
          v = wrapper.new v
          modules.delete wrapper
        end
        v.graph = self
        v.add_extensions modules
      else
        v
      end
    end

    # Get an edge by id.
    #
    # @overload edge(id)
    #   @param [element id] id
    # @overload edge(id, *modules)
    #   @param [element id] id
    #   @param [Module, Class] *modules extensions to add to the returned
    #     edge.
    def edge(id, *modules)
      v = getEdge(id) rescue nil
      if v
        wrapper = modules.detect { |obj| obj.ancestors.include? Pacer::Wrappers::EdgeWrapper }
        if wrapper
          v = wrapper.new v
          modules.delete wrapper
        end
        v.graph = self
        v.add_extensions modules
      end
    end

    # Create a vertex in the graph.
    #
    # @overload create_vertex(*args)
    #   @param [extension, Hash] *args extension (Module/Class) arguments will be
    #     added to the current vertex. A Hash will be
    #     treated as element properties.
    # @overload create_vertex(id, *args)
    #   @param [element id] id the desired element id. Some graphs
    #     ignore this.
    #   @param [extension, Hash] *args extension (Module/Class) arguments will be
    #     added to the current vertex. A Hash will be
    #     treated as element properties.
    def create_vertex(*args)
      id, wrapper, modules, props = id_modules_properties(args)<commit_msg>I guess the exception changed here.<commit_after>module Pacer
  # Methods to be mixed into Blueprints Graph objects from any
  # implementation.
  #
  # Adds more convenient/rubyish methods and adds support for extensions
  # to some methods where needed.
  module GraphMixin
    def self.included(target)
      target.class_eval do
        protected :addVertex, :addEdge
        protected :add_vertex, :add_edge rescue nil
        protected :getVertex, :getEdge
        protected :get_vertex, :get_edge rescue nil
      end
    end

    attr_accessor :in_bulk_job

    def graph_id
      @graph_id = Pacer.next_graph_id unless defined? @graph_id
      @graph_id
    end

    # Get a vertex by id.
    #
    # @overload vertex(id)
    #   @param [element id] id
    # @overload vertex(id, *modules)
    #   @param [element id] id
    #   @param [Module, Class] *modules extensions to add to the returned
    #     vertex.
    def vertex(id, *modules)
      begin
        v = getVertex(id)
      rescue java.lang.RuntimeException
      end
      if v
        wrapper = modules.detect { |obj| obj.ancestors.include? Pacer::Wrappers::VertexWrapper }
        if wrapper
          v = wrapper.new v
          modules.delete wrapper
        end
        v.graph = self
        v.add_extensions modules
      else
        v
      end
    end

    # Get an edge by id.
    #
    # @overload edge(id)
    #   @param [element id] id
    # @overload edge(id, *modules)
    #   @param [element id] id
    #   @param [Module, Class] *modules extensions to add to the returned
    #     edge.
    def edge(id, *modules)
      begin
        v = getEdge(id)
      rescue Java::JavaLang::RuntimeException
      end
      if v
        wrapper = modules.detect { |obj| obj.ancestors.include? Pacer::Wrappers::EdgeWrapper }
        if wrapper
          v = wrapper.new v
          modules.delete wrapper
        end
        v.graph = self
        v.add_extensions modules
      end
    end

    # Create a vertex in the graph.
    #
    # @overload create_vertex(*args)
    #   @param [extension, Hash] *args extension (Module/Class) arguments will be
    #     added to the current vertex. A Hash will be
    #     treated as element properties.
    # @overload create_vertex(id, *args)
    #   @param [element id] id the desired element id. Some graphs
    #     ignore this.
    #   @param [extension, Hash] *args extension (Module/Class) arguments will be
    #     added to the current vertex. A Hash will be
    #     treated as element properties.
    def create_vertex(*args)
      id, wrapper, modules, props = id_modules_properties(args)
{'fraction_non_alphanumeric': 0.07952325127002735, 'fraction_numerical': 0.0, 'mean_word_length': 2.1814791796146675, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3926641', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1491, 'n_words': 512}