A simple Scala client for the TheySay AffectR API
Scala
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
project
src/main
.gitignore
.travis.yml
CHANGELOG.md
README.md

README.md

TheySay AffectR API Scala Client Build Status

The TheySay AffectR API Scala client provides a simple interface to the TheySay AffectR API.

You can sign up for a TheySay AffectR API account at http://theysay.io.

Requirements

Java 6 or later. Scala 2.10. Akka 2.1 or later.

Using with SBT

Add this dependency to your build.sbt or project/Build.scala file:

libraryDependencies += "io.theysay" %% "affectr-scala" % "1.0.3"

Scale better, use less threads

With a classic synchronous API client, each operation blocks the current thread until a response is received. This model is simple but has a major flaw - it can't scale that much.

This client is built using Spray to avoid any kind of blocking request. Every operation returns immediately, freeing the running thread and resuming execution when it is over. Analysing text for sentiment is not a bottleneck anymore.

If you prefer a synchronous client, have a look at our Java client.

Getting Started

First, import the AffectR class:

import io.theysay.affectr.client.AffectR

Next, create an Akka 2.1 actor system and instantiate the AffectR class with it and your account details:

val actorSystem = ActorSystem()

val affectr = AffectR(actorSystem, "your username", "your password")

Next, call any classification task with your text on the AffectR API class, for example:

affectr.classifySentiment("...") onComplete {
  case Success(sentiment) => println(sentiment)
  case Failure(e) => e.printStackTrace()
}

affectr.classifyEntitySentiment("...") onComplete {
  case Success(entitySentiments) => entitySentiments.foreach(entitySentiment => println(entitySentiment))
  case Failure(e) => e.printStackTrace()
}

For more information on working with Scala futures, have a look here.

For more information, please visit http://docs.theysay.apiary.io/.

Versioning

For transparency and insight into our release cycle, and for striving to maintain backward compatibility, this project will be maintained under the Semantic Versioning guidelines as much as possible.

Releases will be numbered with the follow format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major (and resets the minor and patch)
  • New additions without breaking backward compatibility bumps the minor (and resets the patch)
  • Bug fixes and misc changes bumps the patch

For more information on SemVer, please visit http://semver.org/.

License

Copyright 2013 TheySay Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.