Class: Semaphore::Client
- Inherits:
-
Object
- Object
- Semaphore::Client
- Defined in:
- lib/semaphore_classification/client.rb
Constant Summary collapse
- LANGUAGES =
{ :english => "en", :english_marathon_stemmer => "en1", :english_morphological_stemmer => "en2", :english_morph_and_derivational_stemmer => "en3", :french => "fr", :italian => "it", :german => "de", :spanish => "es", :dutch => "nl", :portuguese => "pt", :danish => "da", :norwegian => "no", :swedish => "sv", :arabic => "ar" }
- CLUSTERING_TYPES =
{ :all => "ALL", :average => "AVERAGE_INCLUDING_EMPTY", :average_scored_only => "AVERAGE", :common_scored_only => "COMMON", :common => "COMMON_INCLUDING_EMPTY", :rms_scored_only => "RMS", :rms => "RMS_INCLUDING_EMPTY", :none => "NONE" }
- TERM_QUERY =
'select.exe?TBDB=disp_taxonomy&TEMPLATE=service.xml&SERVICE=browse&ID='
- @@default_options =
{ :title => "", :alternate_body => "", :debug => false, :clustering_type => CLUSTERING_TYPES[:rms_scored_only], :clustering_threshold => 48, :threshold => 48, :language => LANGUAGES[:english_marathon_stemmer], :generated_keys => true, :min_avg_article_page_size => 1.0, :character_cutoff => 500000, :document_score_limit => 0, :article_mode => :single }
- @@connection =
nil
- @@decode_term_ids =
nil
Class Method Summary collapse
- .classify(*args) ⇒ Object
- .decode_term_id(term_id) ⇒ Object
- .decode_term_ids ⇒ Object
- .decode_term_ids=(value) ⇒ Object
- .set_realm(realm, proxy = nil) ⇒ Object
Class Method Details
.classify(*args) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/semaphore_classification/client.rb', line 40 def classify(*args) = (args) raise InsufficientArgs if [:alternate_body].nil? && [:document_uri].nil? result = post .merge() end |
.decode_term_id(term_id) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/semaphore_classification/client.rb', line 47 def decode_term_id(term_id) raise RealmNotSpecified if @@connection.nil? begin raw_host = decode_host(@@connection.realm) path = [raw_host, 'cgi-bin', "#{TERM_QUERY}#{term_id}"].join('/') term_doc = Nokogiri::XML.parse(open(path)) rescue raise SemaphoreError end term_doc.xpath('//BROWSE_TERM/TERM/NAME').inner_text end |
.decode_term_ids ⇒ Object
36 37 38 |
# File 'lib/semaphore_classification/client.rb', line 36 def decode_term_ids @@decode_term_ids end |
.decode_term_ids=(value) ⇒ Object
30 31 32 33 34 |
# File 'lib/semaphore_classification/client.rb', line 30 def decode_term_ids=(value) raise RealmNotSpecified if @@connection.nil? @@decode_term_ids = value @@connection.decode_term_ids = @@decode_term_ids end |
.set_realm(realm, proxy = nil) ⇒ Object
26 27 28 |
# File 'lib/semaphore_classification/client.rb', line 26 def set_realm(realm, proxy=nil) @@connection = Connection.new(realm, proxy) end |