Sha256: b6f07737adafdb185d0c1e06bd9247340915f168db85fee1f3ff77e2ce96a36c

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

module RDF::Reasoner
  ##
  # LD::Patch format specification. Note that this format does not define any readers or writers.
  #
  # @example Obtaining an LD Patch format class
  #     RDF::Format.for(:reasoner)           #=> RDF::Reasoner::Format
  #
  # @see http://www.w3.org/TR/ldpatch/
  class Format < RDF::Format

    ##
    # Hash of CLI commands appropriate for this format
    # @return [Hash{Symbol => Lambda(Array, Hash)}]
    def self.cli_commands
      {
        entail: {
          description: "Perform RDFS entailment to expand the repository based on referenced built-in vocabuaries",
          help: "entail",
          parse: true,
          lambda: ->(argv, opts) do
            RDF::Reasoner.apply(:rdfs, :owl, :schema)
            start, stmt_cnt = Time.now, RDF::CLI.repository.count
            RDF::CLI.repository.entail!
            secs, new_cnt = (Time.new - start), (RDF::CLI.repository.count - stmt_cnt)
            $stdout.puts "\nEntailed #{new_cnt} new statements in #{secs} seconds."
          end
        },
        lint: {
          description: "Lint the repository using built-in vocabularies",
          help: "lint",
          parse: true,
          lambda: ->(argv, opts) do
            RDF::Reasoner.apply(:rdfs, :owl, :schema)
            start = Time.now
            messages = RDF::CLI.repository.lint
            secs = Time.new - start
            messages.each do |kind, term_messages|
              term_messages.each do |term, messages|
                $stdout.puts "#{kind}  #{term}"
                messages.each {|m| $stdout.puts "  #{m}"}
              end
            end
            $stdout.puts "\nLinted in #{secs} seconds."
          end
        }
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rdf-reasoner-0.4.2 lib/rdf/reasoner/format.rb
rdf-reasoner-0.4.1 lib/rdf/reasoner/format.rb
rdf-reasoner-0.4.0 lib/rdf/reasoner/format.rb