Sha256: b1e86af27b3b9387fe3c1251ca9bc032abbf96fdd0d634500b982d4802ea9c41

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# encoding: UTF-8

class SimilarTermsController < ApplicationController
  resource_description do
    name 'Similar concepts'
  end

  api :GET, ':lang/similar', <<-DOC
    Returns labels which are semantically (not orthographically) similar,
    as determined by concept relations.
  DOC
  formats [:html, :ttl, :rdf]
  param :terms, String, :required => true, :desc => <<-DOC
    One or more terms (comma-separated, CSV-style) to be processed.
  DOC
  example <<-DOC
    GET /de/similar.ttl?terms=wald,baum

    # omitted namespace definitions
    query:top skos:altLabel "Dünenwald"@de;
              skos:altLabel "Baumart"@de.
  DOC

  def show
    authorize! :read, Iqvoc::Concept.base_class

    unless params[:terms]
      head 400 unless request.format.html? # non-GUI
      return
    end

    @terms = InlineDataHelper.parse_inline_values(params[:terms])
    lang = params[:lang]

    respond_to do |format|
      format.html do
        @results = Iqvoc::SimilarTerms.ranked(lang, *@terms)
      end
      format.any(:rdf, :ttl, :xml) do
        @results = Iqvoc::SimilarTerms.alphabetical(lang, *@terms)
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iqvoc_similar_terms-2.7.0 app/controllers/similar_terms_controller.rb