class Typingpool::Amazon::Question
Class encapsulating the HTML form presented to Mechanical Turk workers transcribing a Typingpool
audio chunk.
Attributes
html[R]
url[R]
Public Class Methods
new(url, html)
click to toggle source
Constructor. Takes the URL of where the question HTML has been uploaded, followed by the question HTML itself.
# File lib/typingpool/amazon/question.rb, line 14 def initialize(url, html) @url = url @html = html end
Public Instance Methods
annotation()
click to toggle source
Returns URL-encoded key-value pairs that can be used as the text for a HIT#annotation. The key-value pairs correspond to all hidden HTML form fields in the question HTML.
# File lib/typingpool/amazon/question.rb, line 22 def annotation CGI.escapeHTML(URI.encode_www_form(Hash[*noko.css('input[type="hidden"]').select{|e| e['name'].match(/^typingpool_/) }.map{|e| [e['name'], e['value']]}.flatten])) end
description()
click to toggle source
Returns the description, extracted from the element with the id 'description' in the HTML.
# File lib/typingpool/amazon/question.rb, line 34 def description noko.css('#description')[0].content end
title()
click to toggle source
Returns the title, extracted from the title element of the HTML.
# File lib/typingpool/amazon/question.rb, line 28 def title noko.css('title')[0].content end
Protected Instance Methods
noko(html=@html)
click to toggle source
# File lib/typingpool/amazon/question.rb, line 40 def noko(html=@html) Nokogiri::HTML(html, nil, 'UTF-8') end