Giter Club home page Giter Club logo

Comments (3)

gkellogg avatar gkellogg commented on June 2, 2024

You're right that the DSL doesn't really handle language-tagged literals. The point of the DSL, though, is to create sub-classes of RDF::Vocabulary (and the DSL is essentially just using the class-methods from RDF::Vocabulary and RDF::Vocabulary::Term). It's most easily done using RDF::Vocabulary::Writer from a graph, which is available through the rdf CLI. For example, from the rdf-vocab Rakefile

cmd = "bundle exec rdf"
if v[:patch]
  File.open("lib/rdf/vocab/#{id}.rb_p", "w") {|f| f.write v[:patch]}
  cmd += " patch --patch-file lib/rdf/vocab/#{id}.rb_p"
end
cmd += " serialize --uri '#{v[:uri]}' --output-format vocabulary --ordered"
cmd += " --module-name #{v.fetch(:module_name, "RDF::Vocab")}"
cmd += " --class-name #{v[:class_name] ? v[:class_name] : id.to_s.upcase}"
cmd += " --strict" if v.fetch(:strict, true)
cmd += " --noDoc"
cmd += " --extra #{URI.encode_www_form_component v[:extra].to_json}" if v[:extra]
cmd += " -o lib/rdf/vocab/#{id}.rb_t"
cmd += " '" + v.fetch(:source, v[:uri]) + "'"
puts "  #{cmd}"

The DSL for, say .property, instantiates a new RDF::Vocabulary::Term, where there are some heuristics to turn option entries into IRI keys and values. String or Symbol values that look like IRIs are used to create an RDF::URI, otherwise, they are either Date, DateTime, Integer, Decimal, Double, Boolean, or Literal. There isn't anything specific to create a language-tagged literal, but of course, the property option values could be instances of RDF::Literal, instead.

Given the way RDF::Vocabulary::Term#attribute_value is implemented, we could interpret an Hash value to be something like a language map. But, that would complicate many other places which use vocabularies and expect simple literal values for accessors such as #comment and #label.

In summary, there may be some ripple effects to things which use vocabularies, but something like you suggest is probably feasible, but ambitious.

from rdf.

gkellogg avatar gkellogg commented on June 2, 2024

@wu-lee I added support to this to the develop branch, and will also update the rdf-vocab representation. As this is potentially disruptive (but shouldn't be), I'll give the [email protected] mailing list an opportunity to object before releasing to RubyGems. If that happens, it will end up falling back to an option, at lest until the next dot release. It does affect many vocabularies in rdf-vocab.

from rdf.

wu-lee avatar wu-lee commented on June 2, 2024

Thank you for this. I'll investigate when I get a moment.

from rdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.