Sha256: 51415f69ad34ebcf23c16e6f468c9c7595ae556001890d9fe7bddff8c5cf8350

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# encoding: UTF-8

require "faraday"
require "faraday_middleware"
require "json"

module Dandelionapi

  module SentimentAnalysis

    class Request < Analysis::Request

      ENDPOINT = "/sent/v1"

      MANDATORY_FIELDS = [
        "text",
        "url",
        "html",
        "html_fragment"
      ]

      OPTIONAL_FIELDS = [
        "lang"
      ]

      FIELDS_FORMAT = {
        "text" => {
          valid: lambda {|value| value.is_a? String},
          error_message: 'text needs to be String'
        }, 
        "url" => {
          valid: lambda {|value| value.is_a? String},
          error_message: 'url needs to be String'
        },  
        "html" => {
          valid: lambda {|value| value.is_a? String},
          error_message: 'html needs to be String'
        },  
        "html_fragment" => {
          valid: lambda {|value| value.is_a? String},
          error_message: 'html_fragment needs to be String'
        }, 
        "lang" => {
          valid: lambda {|value| (value.is_a? String and ["de", "en", "fr", "it", "pt", "auto"].include? value)},
          error_message: 'lang needs to be one of the following values: "de", "en", "fr", "it", "pt", "auto"'
        } 
      }

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dandelionapi-0.0.5 lib/dandelionapi/sentiment_analysis.rb