Class: UClassifyQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/uclassify_query.rb

Instance Method Summary collapse

Constructor Details

#initialize(read_api_key) ⇒ UClassifyQuery

Returns a new instance of UClassifyQuery.



2
3
4
5
6
# File 'lib/uclassify_query.rb', line 2

def initialize (read_api_key)
  @read_api_key = read_api_key
  @texts = Array.new
  @classifiers = Array.new
end

Instance Method Details

#add_classifier(classifier_name, text) ⇒ Object



14
15
16
17
18
# File 'lib/uclassify_query.rb', line 14

def add_classifier (classifier_name,text)
  classifier = UClassifyClassifier.new(classifier_name,text)
  @classifiers << classifier 
  self  
end

#add_text(text) ⇒ Object



8
9
10
11
12
# File 'lib/uclassify_query.rb', line 8

def add_text (text)
  text = UClassifyText.new(text)
  @texts << text
  self
end

#classify_text(classifier_name, text) ⇒ Object



20
21
22
23
# File 'lib/uclassify_query.rb', line 20

def classify_text(classifier_name,text)
  add_classifier(classifier_name,text)
  add_text(text)
end

#get_query_stringObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/uclassify_query.rb', line 26

def get_query_string
  @document = Nokogiri::XML::Document.new("1.0")
  @document.encoding="utf-8"
  @uclassify_root_node =  Nokogiri::XML::Node.new('uclassify',@document)
  @uclassify_root_node['xmlns']="http://api.uclassify.com/1/RequestSchema"
  @uclassify_root_node['version']="1.01"
  @document.root=@uclassify_root_node
  generate_texts
  generate_read_calls
  @document.to_xml
end