1. Martin Ostrovsky
  2. Repustate Clients

Commits

Martin Ostrovsky  committed a3e1415

updated client libraries to include an argument for language, defaults to 'en'

  • Participants
  • Parent commits 2f21f81
  • Branches default

Comments (0)

Files changed (4)

File java/RepustateClient.java

View file
 	{
 		//curl -d "author=Martin
 		//&report_id=10
-		//&report_title=My first report
+		//&title=My first report
 		//&slide_1_title=My first slide
 		//&slide_1_image=<b64 encoding>
 		//&slide_1_notes=A great slide to show people" 

File php/Repustate.php

View file
     //
     // Retreive the sentiment for a single URL or block of text.
     //
-    public function sentiment($text=null, $url=null)
+    public function sentiment($text=null, $url=null, $lang='en')
     {
         if (is_array($text))
         {
                 $text = null;
             }
         }
-        return $this->callApi('score', array('text' => $text, 'url' => $url));
+        return $this->callApi('score', array('text' => $text, 'url' => $url, 'lang' => $lang));
     }
 
     //
     // Bulk score multiple pieces of text (not urls!).
     //
-    public function bulkSentiment($items)
+    public function bulkSentiment($items, $lang='en')
     {
         $itemsToScore = array();
         foreach (array_values($items) as $k => $v)
         {
             $itemsToScore['text' . $k] = $v;
         }
-        return $this->callApi('bulk-score', $itemsToScore);
+        return $this->callApi('bulk-score', $itemsToScore, 'lang' => $lang);
     }
 
     //
                               $useHttpGet=TRUE);
     }
 
-    public function adjectives($cloud=null, $text=null, $url=null)
+    public function adjectives($cloud=null, $text=null, $url=null, $lang='en')
     {
         if (is_array($cloud))
         {
                 $cloud = null;
             }
         }
-        return $this->callNaturalLanguage('adj', $cloud, $text, $url);
+        return $this->callNaturalLanguage('adj', $cloud, $text, $url, $lang);
     }
 
-    public function verbs($cloud=null, $text=null, $url=null)
+    public function verbs($cloud=null, $text=null, $url=null, $lang='en')
     {
         if (is_array($cloud))
         {
                 $cloud = null;
             }
         }
-        return $this->callNaturalLanguage('verb', $cloud, $text, $url);
+        return $this->callNaturalLanguage('verb', $cloud, $text, $url, $lang);
     }
 
     public function ngrams($url=null, $text=null, $max=null, $min=null,
-                           $freq=null, $stopwords=null)
+                           $freq=null, $stopwords=null, $lang='en')
     {
         if (is_array($url))
         {
             'min' => $min,
             'freq' => $freq,
             'stopwords' => $stopwords,
+            'lang' => $lang
         );
         $useHttpGet = ($url != null);
         return $this->callApi('ngrams', $args, $useHttpGet);

File python/repustate.py

View file
         """
         return self._call_api(api_function, cloud=cloud, text=text, url=url)
 
-    def sentiment(self, text=None, url=None):
+    def sentiment(self, text=None, url=None, lang='en'):
         """
         Retrieve the sentiment for a single URl or block of text.
         """
-        return self._call_api('score', text=text, url=url)
+        return self._call_api('score', text=text, url=url, lang=lang)
 
-    def bulk_sentiment(self, items=None):
+    def bulk_sentiment(self, items=None, lang='en'):
         """
         Bulk score multiple pieces of text (not urls!).
         """
         for idx, item in enumerate(items):
             items_to_score['text%d' % idx] = item
 
-        return self._call_api('bulk-score', **items_to_score)
+        return self._call_api('bulk-score', **items_to_score, lang=lang)
 
     def clean_html(self, url=None):
         """
         """
         return self._call_api('clean-html', use_http_get=True, url=url)
 
-    def adjectives(self, cloud=None, text=None, url=None):
-        return self._call_natural_language('adj', cloud=cloud, text=text,
-                                           url=url)
+    def adjectives(self, cloud=None, text=None, url=None, lang='en'):
+        return self._call_natural_language('adj', cloud=cloud, text=text, url=url, lang=lang)
 
-    def verbs(self, cloud=None, text=None, url=None):
-        return self._call_natural_language('verb', cloud=cloud, text=text,
-                                           url=url)
+    def verbs(self, cloud=None, text=None, url=None, lang='en'):
+        return self._call_natural_language('verb', cloud=cloud, text=text, url=url, lang=lang)
 
-    def ngrams(self, url=None, text=None, max=None, min=None, freq=None,
-               stopwords=None):
+    def ngrams(self, url=None, text=None, max=None, min=None, freq=None, stopwords=None, lang='en'):
         return self._call_api('ngrams', use_http_get=bool(url), text=text,
                               url=url, max=max, min=min, freq=freq,
-                              stopwords=stopwords)
+                              stopwords=stopwords,
+                              lang=lang,
+                              )
 
     def date_extraction(self, text):
         """

File ruby/repustate.rb

View file
     @version = version
   end
 
-  # Retrieve the sentiment for a single URl or block of text.
-  def sentiment(options={:text => nil, :url => nil})
+  # Retrieve the sentiment for a single URl or block of text. Optionally select
+  # a language other than English.
+  def sentiment(options={:text => nil, :url => nil, :lang => 'en'})
     call_api('score', options)
   end
 
   # Bulk score multiple pieces of text (not urls!).
-  def bulk_sentiment(options={:items => []})
+  def bulk_sentiment(options={:items => [], :lang => 'en'})
     items_to_score = Hash[options[:items].enum_for(:each_with_index).collect {
                             |val, i| ["text#{i}", val]
                           }]
     call_api('clean-html', options, use_http_get)
   end
 
-  def adjectives(options={:cloud => nil, :text => nil, :url => nil})
+  def adjectives(options={:cloud => nil, :text => nil, :url => nil, :lang => 'en'})
     call_natural_language('adj', options)
   end
 
-  def verbs(options={:cloud => nil, :text => nil, :url => nil})
+  def verbs(options={:cloud => nil, :text => nil, :url => nil, :lang => 'en'})
     call_natural_language('verb', options)
   end
 
                :min => nil,
                :freq => nil,
                :stopwords => nil,
+               :lang => 'en'
              })
     use_http_get = (options[:text] == nil or options[:text].empty?)
     call_api('ngrams', options, use_http_get)