uclassify 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  = uclassify
2
2
 
3
- Description goes here.
3
+ A Ruby gem for the UClassify API - http://www.uclassify.com/XmlApiDocumentation.aspx#examples
4
4
 
5
5
  == Contributing to uclassify
6
6
 
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ Jeweler::Tasks.new do |gem|
21
21
  gem.description = %Q{A gem enabling you to create classsifers and use them using the UClassify API. www.uclassify.com/XmlApiDocumentation.aspx#examples}
22
22
  gem.email = "manishchaks@gmail.com"
23
23
  gem.authors = ["Manish Chakravarty"]
24
- gem.version = '0.1.0'
24
+ gem.version = '0.1.1'
25
25
  # dependencies defined in Gemfile
26
26
  end
27
27
  Jeweler::RubygemsDotOrgTasks.new
@@ -5,6 +5,7 @@ require File.join(File.dirname(__FILE__), 'uclassify_create_id.rb')
5
5
  require File.join(File.dirname(__FILE__), 'uclassify_class.rb')
6
6
  require File.join(File.dirname(__FILE__), 'uclassify_text.rb')
7
7
  require File.join(File.dirname(__FILE__), 'uclassify_training_class.rb')
8
+ require File.join(File.dirname(__FILE__), 'uclassify_untraining_class.rb')
8
9
  require File.join(File.dirname(__FILE__), 'uclassify_classifier.rb')
9
10
  require File.join(File.dirname(__FILE__), 'uclassify_query.rb')
10
11
  require File.join(File.dirname(__FILE__), 'uclassify_request.rb')
@@ -85,6 +86,14 @@ class UClassify
85
86
  train_text(text)
86
87
  end
87
88
 
89
+ def untrain_class_with_text(class_name,text)
90
+ train_id = UClassifyUtils.string_to_id(class_name)
91
+ text_id = UClassifyUtils.string_to_id(text)
92
+ untrain_class(train_id,class_name,text_id)
93
+ train_text(text)
94
+
95
+ end
96
+
88
97
  private
89
98
 
90
99
  def add_training_class (train_id,class_name,text_id)
@@ -92,6 +101,11 @@ private
92
101
  @write_calls.last.add_training_class(training_class)
93
102
  self
94
103
  end
104
+
105
+ def untrain_class(train_id,class_name,text_id)
106
+ untraining_class = UClassifyUnTrainClass.new(train_id,class_name,text_id)
107
+ @write_calls.last.add_training_class(untraining_class)
108
+ end
95
109
 
96
110
  def train_text(text)
97
111
  text = UClassifyText.new(text)
@@ -0,0 +1,15 @@
1
+ class UClassifyUnTrainClass
2
+ def initialize(train_id,class_name,text_id)
3
+ @train_id = train_id
4
+ @class_name = class_name
5
+ @text_id = text_id
6
+ end
7
+
8
+ def to_xml_node xml_document
9
+ class_node = Nokogiri::XML::Node.new('untrain',xml_document)
10
+ class_node['id']=@train_id
11
+ class_node['className']=@class_name
12
+ class_node['textId']=@text_id
13
+ class_node
14
+ end
15
+ end
@@ -63,4 +63,12 @@ describe "UClassify base" do
63
63
 
64
64
  xml_cmp(uclassify.generate_request_string,expected_string).should==true
65
65
  end
66
+
67
+ it "should be possible to untrain classifiers on texts" do
68
+ uclassify = UClassify.new
69
+ uclassify.write_api_key = "Dummy API Key "
70
+ uclassify.with_classifier_name("DUMMY Classifier").untrain_class_with_text("ClassOne","SomeTextOne")
71
+ expected_string = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<uclassify xmlns=\"http://api.uclassify.com/1/RequestSchema\" version=\"1.01\">\n <texts>\n <textBase64 id=\"a9aea8382b0cfabd38baaa7ae6e66937\">U29tZVRleHRPbmU=</textBase64>\n </texts>\n <writeCalls writeApiKey=\"Dummy API Key \" classifierName=\"DUMMY Classifier\">\n <untrain id=\"7f2e5c9c34e90179ea539c7f7bc1cc1a\" className=\"ClassOne\" textId=\"a9aea8382b0cfabd38baaa7ae6e66937\"/>\n </writeCalls>\n</uclassify>\n"
72
+ xml_cmp(uclassify.generate_request_string,expected_string).should == true
73
+ end
66
74
  end
@@ -0,0 +1,86 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{uclassify}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Manish Chakravarty}]
12
+ s.date = %q{2011-11-06}
13
+ s.description = %q{A gem enabling you to create classsifers and use them using the UClassify API. www.uclassify.com/XmlApiDocumentation.aspx#examples}
14
+ s.email = %q{manishchaks@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "lib/uclassify.rb",
29
+ "lib/uclassify_class.rb",
30
+ "lib/uclassify_classifier.rb",
31
+ "lib/uclassify_create_id.rb",
32
+ "lib/uclassify_query.rb",
33
+ "lib/uclassify_request.rb",
34
+ "lib/uclassify_response.rb",
35
+ "lib/uclassify_text.rb",
36
+ "lib/uclassify_training_class.rb",
37
+ "lib/uclassify_untraining_class.rb",
38
+ "lib/uclassify_utils.rb",
39
+ "lib/uclassify_write_call.rb",
40
+ "spec/spec_helper.rb",
41
+ "spec/uclassify_class_spec.rb",
42
+ "spec/uclassify_classifier_spec.rb",
43
+ "spec/uclassify_create_id_spec.rb",
44
+ "spec/uclassify_query_spec.rb",
45
+ "spec/uclassify_spec.rb",
46
+ "spec/uclassify_text_spec.rb",
47
+ "spec/uclassify_training_class_spec.rb",
48
+ "spec/uclassify_utils_spec.rb",
49
+ "spec/uclassify_write_call_spec.rb",
50
+ "test-helpers/xml_compare.rb",
51
+ "uclassify.gemspec"
52
+ ]
53
+ s.homepage = %q{http://github.com/manishchaks/uclassify}
54
+ s.licenses = [%q{MIT}]
55
+ s.require_paths = [%q{lib}]
56
+ s.rubygems_version = %q{1.8.6}
57
+ s.summary = %q{A Ruby gem for UClassify}
58
+
59
+ if s.respond_to? :specification_version then
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
64
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
65
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
67
+ s.add_development_dependency(%q<rcov>, [">= 0"])
68
+ s.add_development_dependency(%q<httparty>, ["= 0.8.1"])
69
+ else
70
+ s.add_dependency(%q<nokogiri>, [">= 0"])
71
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
74
+ s.add_dependency(%q<rcov>, [">= 0"])
75
+ s.add_dependency(%q<httparty>, ["= 0.8.1"])
76
+ end
77
+ else
78
+ s.add_dependency(%q<nokogiri>, [">= 0"])
79
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
80
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
81
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
82
+ s.add_dependency(%q<rcov>, [">= 0"])
83
+ s.add_dependency(%q<httparty>, ["= 0.8.1"])
84
+ end
85
+ end
86
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uclassify
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Manish Chakravarty
@@ -136,6 +136,7 @@ files:
136
136
  - lib/uclassify_response.rb
137
137
  - lib/uclassify_text.rb
138
138
  - lib/uclassify_training_class.rb
139
+ - lib/uclassify_untraining_class.rb
139
140
  - lib/uclassify_utils.rb
140
141
  - lib/uclassify_write_call.rb
141
142
  - spec/spec_helper.rb
@@ -149,6 +150,7 @@ files:
149
150
  - spec/uclassify_utils_spec.rb
150
151
  - spec/uclassify_write_call_spec.rb
151
152
  - test-helpers/xml_compare.rb
153
+ - uclassify.gemspec
152
154
  homepage: http://github.com/manishchaks/uclassify
153
155
  licenses:
154
156
  - MIT