Political Analysis

political(data, {[api_key]: String, [cloud]: String, [top_n]: Integer, [threshold]: Float})
Gauge the political leanings of a phrase or document.

Current Version: 2

Arguments

data – String | List – required – text to be analyzed
[api_key] – String – optional – your indico API key
[cloud] – String – optional – your private cloud subdomain
[v or version] – Integer – optional (defaults to 2) – specify model version, versions 1 and 2 are available
[top_n] – Integer – optional (defaults to 3) – only return this many of the most likely topics
[threshold] – Float – optional (defaults to .0) – only return topics with likelihood greater than this number

Output

This function will return a dictionary with 4 key-value pairs. These key-value pairs represent the likelihood that each of 4 political leanings are expressed in the analyzed text. The keys in the dictionary are strings containing the political leanings and the values are the probabilities that the analyzed text is expressing each political view.

Values less than 0.05 indicate that it is very unlikely the text is expressing that particular political leaning.

  # single output
  {
      'libertarian': 0.27192999211817354,
      'green': 0.06525078204908323,
      'liberal': 0.11033990553871972,
      'conservative': 0.5524793202940235
  }

  # batch output
  [
      {
          'libertarian': 0.27192999211817354,
          'green': 0.06525078204908323,
          'liberal': 0.11033990553871972,
          'conservative': 0.5524793202940235
      },
      {
          'libertarian': 0.02334343866477883,
          'green': 0.03302544570586526,
          'liberal': 0.9254000702504355,
          'conservative': 0.01823104537892042
      }
  ]

Example

  require 'indico'
  Indico.api_key =  'YOUR_API_KEY'

  # single example
  Indico.political("I have a constitutional right to bear arms!")

  # batch example
  Indico.political([
      "I have a constitutional right to bear arms!",
      "I wish more candidates cared about the environment."
  ])