Copyright | (c) Joseph Canero, 2015 |
---|---|
License | MIT |
Maintainer | caneroj1@tcnj.edu |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Provides functionality for interacting with Clarifai's Image Tagging API. Users need a Clarifai account to use this, as the endpoints require an access token.
- data Client
- data TagSet = TagSet {}
- data Info = Info {}
- data Tag = Tag String Double
- verifyImageBatchSize :: Info -> [FilePath] -> Bool
- verifyVideoBatchSize :: Info -> [FilePath] -> Bool
- verifyFiles :: Info -> [FilePath] -> IO [(FilePath, IO VerificationStatus)]
- authorize :: Client -> IO (Either Errors Client)
- info :: Client -> IO (Either Errors Info)
- tag :: Client -> [FilePath] -> IO (Either Errors (Vector TagSet))
Documentation
The Client data type has two constructors. The first should be used when constructing a client with an access token. The second constructor should be used when passing in an application's client id and client secret.
A TagSet represents a single result from the Tag endpoint. Each result has a unique docid, but they can also have local IDs if those are provided. They also have words and probabilities.
The Info data type is used as a response from the /info endpoint. This type contains information about the various usage limits for the API.
A Tag is a pair of String and Double and represents a word class from the Clarifai model and the associated probability.
verifyImageBatchSize :: Info -> [FilePath] -> Bool Source
Given an API Info type and a list of FilePaths, we verify the length of the list with what the Info type specifies is acceptable batch size for images. This function assumes that the FilePaths all point to images.
verifyVideoBatchSize :: Info -> [FilePath] -> Bool Source
Given an API Info type and a list of FilePaths, we verify the length of the list with what the Info type specifies is acceptable batch size for videos. This function assumes that the FilePaths all point to videos.
verifyFiles :: Info -> [FilePath] -> IO [(FilePath, IO VerificationStatus)] Source
Given an API Info type and a list of FilePaths, we verify each of the files. If the file has an extension, we decide which Info attribute to use to verify the file. If it has no extension, we choose not to verify. This function maps each FilePath to a tuple of (FilePath, VerificationStatus), where VerificationStatus = Good | Bad | Unknown
authorize :: Client -> IO (Either Errors Client) Source
Authorize an application Sends a POST request to Clarifai's authentication endpoint. If we have a Client, we just return the client because I'm assuming the client was constructed with a valid access token. If we have an App, we would POST the client ID and client secret to Clarifai to get an access token.