README.rdoc in openamplify-0.2.3 vs README.rdoc in openamplify-0.3.0
- old
+ new
@@ -4,94 +4,109 @@
explaining and classifying the content. What you do with that analysis is,
in the fine tradition of APIs and mashups, up to you. Some possibilities
might include pairing ads with articles, creating rich tag-clouds, or
monitoring the tone of forum threads.
+=== Supported version
+
+2.1
+
== Helpful links
-* <b>Overview:</b> http://community.openamplify.com/blogs/quickstart/pages/overview.aspx
+* <b>Overview:</b> http://openamplify.com/quickstart
== Install
gem install openamplify
== Usage
-=== Show the result from OpenAmplify as a Hash
+=== Configure
- require 'openamplify'
+ OpenAmplify.configure do |config|
+ config.api_key = 'YOUR_API_KEY'
- API_KEY = "register to get a key"
- client = OpenAmplify::Client.new(:api_key => API_KEY)
+ # default :get
+ config.method = :post
- text = "After getting the MX1000 laser mouse and the Z-5500 speakers i fell in love with logitech"
- response = client.analyze_text(text)
+ # default :xml
+ config.output_format = :json
- # List all the keys and values returned by OpenAmplify
- response.each do |k, v|
- pp k
- pp v
+ # default :all
+ config.analysis = :topics
+
+ # default :standard
+ config.scoring = :todo
end
+Default settings can be overriden by the client
- # 'response' works like a Hash
- puts response['Topics']
+ client = OpenAmplify::Client.new(:method => :get)
- # or use the shortcuts
- response.top_topics
- response.proper_nouns
- response.locations
- response.domains
+Or when you start 'amplifying'.
-=== Output Format
+ result = client.amplify('input', :output_format => :rdf)
+=== Usage
+
+ client = OpenAmplify::Client.new
+
+ text = "After getting the MX1000 laser mouse and the Z-5500 speakers i fell in love with logitech"
+ analysis = client.amplify(text)
+ puts analysis # default as xml
+
+It knows if the input is a URL and uses the right webservice param (ie. sourceurl)
+
+ client.amplify('http://theonion.com')
+
In case you need a different format, OpenAmplify supports XML, JSON, RDF, CSV.
It can also return the result as a fancy HTML page.
# assuming you use Nokogiri
- doc = Nokogiri::XML(response.to_xml)
+ doc = Nokogiri::XML(analysis.to_xml)
# or you want a JSON
- json = JSON.parse(response.to_json)
+ json = JSON.parse(analysis.to_json)
# you should really try the pretty formats
- puts response.to_pretty
+ puts analysis.to_pretty
# or
- puts response.to_signals
+ puts analysis.to_signals
-=== Analysis options
-By default, OpenAmplify returns a number of 'signals' about your text.
-You can limit the result by setting the 'analysis' option.
+== Command-line
-The different options and explanations are available at http://community.openamplify.com/blogs/quickstart/pages/overview.aspx
+OpenAmplify gem comes with a command-line tool.
- client = OpenAmplify::Client.new(:api_key => API_KEY, :analysis => 'topics')
+ openamplify --api-key=APIKEY --format=json --analysis=topics "sample input text"
- # or if you have a client instance already
- client.analysis = 'topics'
+== Upgrading from 0.2.3 to 0.3.0
- response = client.analyze_text(text)
- response['Topics'] # => should be another big Hash of key-value pairs
- response['Demographics'] # => nil
+Note 0.3.0 is a major revamp of the code. In general, it is better but
+if you encounter a problem, please let me know. Or better, submit a pull
+request.
-=== POST method
+The following methods are deprecated and will be removed in 0.3.1
-By default, GET is used. If you need to analyze lots of text, use POST
+ client.analyze_text('input')
+ client.base_url = 'http://domain.dev'
- client = OpenAmplify::Client.new(:api_key => API_KEY, :method => :post)
+The following methods are no longer supported. I figure it's better to
+let the caller decide how they want to traverse the results.
- # or
- client.method = :post
-
-=== Request URL
+ # Treating the result as hash
+ response.each do |k, v|
+ pp k
+ pp v
+ end
-In case you are wondering what the request URL looks like:
+ # 'response' works like a Hash
+ puts response['Topics']
- response.request_url
-
-If someday, OpenAmplify decides to change their API URL:
-
- client.base_url = 'http://newurl'
+ # Nor the shortcuts
+ response.top_topics
+ response.proper_nouns
+ response.locations
+ response.domains
== Testing
rake test OPEN_AMPLIFY_KEY=YOUR_KEY