semantically-taggable¶ ↑
A tagging system, based extremely heavily on acts_as_taggable_on (to the point of being a little grubby, so please, if you need a general non-semantic tagging system, see Mike Bleigh’s excellent github.com/mbleigh/acts-as-taggable-on), but which moves the acts-as-taggable-on
‘context’ concept into semantic tagging schemes. So, for example, “Environment” in a green_tags
scheme is not semantically equivalent to “Environment” in a sysadmin_tags
tagging scheme.
It also adds support for (poly)hierarchical thesaurus/taxonomy with SKOS import support and hierarchy tagging. For example, if you had a hierarchical taxonomy called animal_classifications
which had a topic hierarchy Animals > Marsupials > Kangaroo, the following code would create a kangaroo called “Skippy” and then retrieve him via hierarchy tagging:
class Animal < ActiveRecord::Base semantically_taggable :animal_classifications end animal = Animal.create(:name => 'Skippy', :animal_classification_list => 'Kangaroo') Animal.tagged_with('Marsupials', :on => :animal_classifications) => #<Animal id: 1, Name: "Skippy">
Also removes tagger/related capability, Postgres support and restricts compatibility to Rails 3 and above - so you need to be sure you need semantic tagging before using this!
Using semantically-taggable¶ ↑
Add to your Rails 3 or higher application’s Gemfile:
gem "semantically-taggable"
You’ll need to run the rails migration generator:
rails g semantically_taggable:migration
This will create a migration in your rails project. Run with
rake db:migrate
This gem is purposely less ad-hoc than acts-as-taggable-on
. All tags must exist in a SemanticallyTaggable::Scheme
. This means you’ll need to add schemes to your database before you can tag. The easiest way to do this is by using rake db:seed
. An example db/seeds.rb
file may help here:
SemanticallyTaggable::Scheme.create( [ { :name => 'taxonomy_topics', :meta_name => 'DC.subject', :meta_scheme => 'MyTaxonomy.Topic', :description => 'A polyhierarchical taxonomy', :delimiter => ';', :polyhierarchical => true }, { :name => 'keywords', :meta_name => 'keywords', :description => 'Folksonomic keyword taggings' }, ] )
Important notes for indirect tagging support in hierarchical schemes¶ ↑
You’ll need to import your taxonomy/thesaurus first. Grab a handy SKOS file which your favourite tool has produced, and import to a scheme (which must be marked polyhierarchical) as follows:
rake import:skos[my_scheme_topics,db/my_skos_file.rdf]
This will create your hierarchy, but to enable indirect tagging support, you’ll also need
rake import:refresh_closure
Contributing to semantically-taggable¶ ↑
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
-
Fork the project
-
Start a feature/bugfix branch
-
Commit and push until you are happy with your contribution
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright¶ ↑
Copyright © 2011 Russell Garner. See LICENSE.txt for further details.