Giter Site home page Giter Site logo

semantically-taggable's Introduction

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 © 2011 Russell Garner. See LICENSE.txt for further details.

semantically-taggable's People

Contributors

rgarner avatar

Stargazers

Meredith avatar

Watchers

Meredith avatar James Cloos avatar

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.