From 72a86536caac77f7044b94411a4ae75c9536d861 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 24 Feb 2015 15:34:11 -0500 Subject: [PATCH 1/3] Added facetagging --- alchemyapi.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/alchemyapi.py b/alchemyapi.py index 2f64b5a..860d6fd 100644 --- a/alchemyapi.py +++ b/alchemyapi.py @@ -123,6 +123,9 @@ class AlchemyAPI: ENDPOINTS['imagetagging'] = {} ENDPOINTS['imagetagging']['url'] = '/url/URLGetRankedImageKeywords' ENDPOINTS['imagetagging']['image'] = '/image/ImageGetRankedImageKeywords' + ENDPOINTS['facetagging'] = {} + ENDPOINTS['facetagging']['url'] = '/url/URLGetRankedImageFaceTags' + ENDPOINTS['facetagging']['image'] = '/image/ImageGetRankedImageFaceTags' ENDPOINTS['taxonomy'] = {} ENDPOINTS['taxonomy']['url'] = '/url/URLGetRankedTaxonomy' ENDPOINTS['taxonomy']['html'] = '/html/HTMLGetRankedTaxonomy' @@ -720,6 +723,24 @@ def imageTagging(self, flavor, data, options={}): options[flavor] = data return self.__analyze(AlchemyAPI.ENDPOINTS['imagetagging'][flavor], {}, options) + def faceTagging(self, flavor, data, options={}): + """ + + INPUT: + flavor -> which version of the call only url or image. + data -> the data to analyze, either the the url or path to image. + options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. + """ + if flavor not in AlchemyAPI.ENDPOINTS['facetagging']: + return {'status': 'ERROR', 'statusInfo': 'facetagging for ' + flavor + ' not available'} + elif 'image' == flavor: + image = open(data, 'rb').read() + options['imagePostMode'] = 'raw' + return self.__analyze(AlchemyAPI.ENDPOINTS['facetagging'][flavor], options, image) + + options[flavor] = data + return self.__analyze(AlchemyAPI.ENDPOINTS['facetagging'][flavor], {}, options) + def __analyze(self, endpoint, params, post_data=bytearray()): """ HTTP Request wrapper that is called by the endpoint functions. This function is not intended to be called through an external interface. @@ -757,3 +778,4 @@ def __analyze(self, endpoint, params, post_data=bytearray()): print(results) print(e) return {'status': 'ERROR', 'statusInfo': 'parse-error'} + From 026c98236f8db16415647168cd8f7719449b4da8 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 24 Feb 2015 15:35:43 -0500 Subject: [PATCH 2/3] removed whitespace --- alchemyapi.py | 1 - 1 file changed, 1 deletion(-) diff --git a/alchemyapi.py b/alchemyapi.py index 860d6fd..34ded5b 100644 --- a/alchemyapi.py +++ b/alchemyapi.py @@ -778,4 +778,3 @@ def __analyze(self, endpoint, params, post_data=bytearray()): print(results) print(e) return {'status': 'ERROR', 'statusInfo': 'parse-error'} - From f63716a1b08a67361f40a904f1514f97ace44ca6 Mon Sep 17 00:00:00 2001 From: AlchemyAPI Date: Wed, 28 Sep 2016 09:49:45 -0600 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84254e2..8340edd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # alchemyapi_python # -A sdk for AlchemyAPI using Python +A sdk for AlchemyAPI using Python - **_Please note that this legacy AlchemyAPI SDK is no longer supported by IBM. Please use the Watson SDKs https://github.com/watson-developer-cloud?utf8=✓&query=sdk_** ## AlchemyAPI ##