|
def | __init__ (self) |
|
def | entities (self, flavor, data, options={}) |
|
def | keywords (self, flavor, data, options={}) |
|
def | concepts (self, flavor, data, options={}) |
|
def | sentiment (self, flavor, data, options={}) |
|
def | sentiment_targeted (self, flavor, data, target, options={}) |
|
def | text (self, flavor, data, options={}) |
|
def | text_raw (self, flavor, data, options={}) |
|
def | author (self, flavor, data, options={}) |
|
def | language (self, flavor, data, options={}) |
|
def | title (self, flavor, data, options={}) |
|
def | relations (self, flavor, data, options={}) |
|
def | category (self, flavor, data, options={}) |
|
def | feeds (self, flavor, data, options={}) |
|
def | microformats (self, flavor, data, options={}) |
|
def | imageExtraction (self, flavor, data, options={}) |
|
def | taxonomy (self, flavor, data, options={}) |
|
def | combined (self, flavor, data, options={}) |
|
def | imageTagging (self, flavor, data, options={}) |
|
Definition at line 65 of file alchemyapi.py.
def dc_processor.alchemyapi.AlchemyAPI.__analyze |
( |
|
self, |
|
|
|
endpoint, |
|
|
|
params, |
|
|
|
post_data = bytearray() |
|
) |
| |
|
private |
HTTP Request wrapper that is called by the endpoint functions. This function is not intended to be called through an external interface.
It makes the call, then converts the returned JSON string into a Python object.
INPUT:
url -> the full URI encoded url
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 723 of file alchemyapi.py.
723 def __analyze(self, endpoint, params, post_data=bytearray()):
725 HTTP Request wrapper that is called by the endpoint functions. This function is not intended to be called through an external interface. 726 It makes the call, then converts the returned JSON string into a Python object. 729 url -> the full URI encoded url 732 The response, already converted from JSON to a Python object. 736 params[
'apikey'] = self.apikey
737 params[
'outputMode'] =
'json' 742 post_url = AlchemyAPI.BASE_URL + endpoint + \
743 '?' + urlencode(params).
encode(
'utf-8')
745 post_url = AlchemyAPI.BASE_URL + endpoint +
'?' + urlencode(params)
749 results = self.s.post(url=post_url, data=post_data)
750 except Exception
as e:
752 return {
'status':
'ERROR',
'statusInfo':
'network-error'}
754 return results.json()
755 except Exception
as e:
759 return {
'status':
'ERROR',
'statusInfo':
'parse-error'}
◆ author()
def dc_processor.alchemyapi.AlchemyAPI.author |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Extracts the author from a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/author-extraction/
For the docs, please refer to: http://www.alchemyapi.com/api/author-extraction/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Availble Options:
none
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 374 of file alchemyapi.py.
374 def author(self, flavor, data, options={}):
376 Extracts the author from a URL or HTML. 377 For an overview, please refer to: http://www.alchemyapi.com/products/features/author-extraction/ 378 For the docs, please refer to: http://www.alchemyapi.com/api/author-extraction/ 381 flavor -> which version of the call, i.e. text, url or html. 382 data -> the data to analyze, either the text, the url or html code. 383 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 389 The response, already converted from JSON to a Python object. 393 if flavor
not in AlchemyAPI.ENDPOINTS[
'author']:
394 return {
'status':
'ERROR',
'statusInfo':
'author extraction for ' + flavor +
' not available'}
397 options[flavor] = data
398 return self.__analyze(AlchemyAPI.ENDPOINTS[
'author'][flavor], {}, options)
◆ category()
def dc_processor.alchemyapi.AlchemyAPI.category |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Categorizes the text for text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/text-categorization/
For the docs, please refer to: http://www.alchemyapi.com/api/text-categorization/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
showSourceText -> 0: disabled (default), 1: enabled
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 487 of file alchemyapi.py.
487 def category(self, flavor, data, options={}):
489 Categorizes the text for text, a URL or HTML. 490 For an overview, please refer to: http://www.alchemyapi.com/products/features/text-categorization/ 491 For the docs, please refer to: http://www.alchemyapi.com/api/text-categorization/ 494 flavor -> which version of the call, i.e. text, url or html. 495 data -> the data to analyze, either the text, the url or html code. 496 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 499 showSourceText -> 0: disabled (default), 1: enabled 502 The response, already converted from JSON to a Python object. 506 if flavor
not in AlchemyAPI.ENDPOINTS[
'category']:
507 return {
'status':
'ERROR',
'statusInfo':
'text categorization for ' + flavor +
' not available'}
510 options[flavor] = data
512 return self.__analyze(AlchemyAPI.ENDPOINTS[
'category'][flavor], {}, options)
◆ combined()
def dc_processor.alchemyapi.AlchemyAPI.combined |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Combined call for page-image, entity, keyword, title, author, taxonomy, concept.
INPUT:
flavor -> which version of the call, i.e. url or html.
data -> the data to analyze, either the the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
extract ->
Possible values: page-image, entity, keyword, title, author, taxonomy, concept
default : entity, keyword, taxonomy, concept
disambiguate ->
disambiguate detected entities
Possible values:
1 : enabled (default)
0 : disabled
linkedData ->
include Linked Data content links with disambiguated entities
Possible values :
1 : enabled (default)
0 : disabled
coreference ->
resolve he/she/etc coreferences into detected entities
Possible values:
1 : enabled (default)
0 : disabled
quotations ->
enable quotations extraction
Possible values:
1 : enabled
0 : disabled (default)
sentiment ->
enable entity-level sentiment analysis
Possible values:
1 : enabled
0 : disabled (default)
showSourceText ->
include the original 'source text' the entities were extracted from within the API response
Possible values:
1 : enabled
0 : disabled (default)
maxRetrieve ->
maximum number of named entities to extract
default : 50
baseUrl ->
rel-tag output base http url
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 639 of file alchemyapi.py.
639 def combined(self, flavor, data, options={}):
641 Combined call for page-image, entity, keyword, title, author, taxonomy, concept. 644 flavor -> which version of the call, i.e. url or html. 645 data -> the data to analyze, either the the url or html code. 646 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 650 Possible values: page-image, entity, keyword, title, author, taxonomy, concept 651 default : entity, keyword, taxonomy, concept 654 disambiguate detected entities 656 1 : enabled (default) 660 include Linked Data content links with disambiguated entities 662 1 : enabled (default) 666 resolve he/she/etc coreferences into detected entities 668 1 : enabled (default) 672 enable quotations extraction 675 0 : disabled (default) 678 enable entity-level sentiment analysis 681 0 : disabled (default) 684 include the original 'source text' the entities were extracted from within the API response 687 0 : disabled (default) 690 maximum number of named entities to extract 694 rel-tag output base http url 698 The response, already converted from JSON to a Python object. 700 if flavor
not in AlchemyAPI.ENDPOINTS[
'combined']:
701 return {
'status':
'ERROR',
'statusInfo':
'combined for ' + flavor +
' not available'}
702 options[flavor] = data
703 return self.__analyze(AlchemyAPI.ENDPOINTS[
'combined'][flavor], {}, options)
◆ concepts()
def dc_processor.alchemyapi.AlchemyAPI.concepts |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Tags the concepts for text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/concept-tagging/
For the docs, please refer to: http://www.alchemyapi.com/api/concept-tagging/
Available Options:
maxRetrieve -> the maximum number of concepts to retrieve (default: 8)
linkedData -> include linked data, 0: disabled, 1: enabled (default)
showSourceText -> 0:disabled (default), 1: enabled
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 240 of file alchemyapi.py.
240 def concepts(self, flavor, data, options={}):
242 Tags the concepts for text, a URL or HTML. 243 For an overview, please refer to: http://www.alchemyapi.com/products/features/concept-tagging/ 244 For the docs, please refer to: http://www.alchemyapi.com/api/concept-tagging/ 247 maxRetrieve -> the maximum number of concepts to retrieve (default: 8) 248 linkedData -> include linked data, 0: disabled, 1: enabled (default) 249 showSourceText -> 0:disabled (default), 1: enabled 252 The response, already converted from JSON to a Python object. 256 if flavor
not in AlchemyAPI.ENDPOINTS[
'concepts']:
257 return {
'status':
'ERROR',
'statusInfo':
'concept tagging for ' + flavor +
' not available'}
260 options[flavor] = data
261 return self.__analyze(AlchemyAPI.ENDPOINTS[
'concepts'][flavor], {}, options)
◆ entities()
def dc_processor.alchemyapi.AlchemyAPI.entities |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Extracts the entities for text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/entity-extraction/
For the docs, please refer to: http://www.alchemyapi.com/api/entity-extraction/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
disambiguate -> disambiguate entities (i.e. Apple the company vs. apple the fruit). 0: disabled, 1: enabled (default)
linkedData -> include linked data on disambiguated entities. 0: disabled, 1: enabled (default)
coreference -> resolve coreferences (i.e. the pronouns that correspond to named entities). 0: disabled, 1: enabled (default)
quotations -> extract quotations by entities. 0: disabled (default), 1: enabled.
sentiment -> analyze sentiment for each entity. 0: disabled (default), 1: enabled. Requires 1 additional API transction if enabled.
showSourceText -> 0: disabled (default), 1: enabled
maxRetrieve -> the maximum number of entities to retrieve (default: 50)
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 179 of file alchemyapi.py.
179 def entities(self, flavor, data, options={}):
181 Extracts the entities for text, a URL or HTML. 182 For an overview, please refer to: http://www.alchemyapi.com/products/features/entity-extraction/ 183 For the docs, please refer to: http://www.alchemyapi.com/api/entity-extraction/ 186 flavor -> which version of the call, i.e. text, url or html. 187 data -> the data to analyze, either the text, the url or html code. 188 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 191 disambiguate -> disambiguate entities (i.e. Apple the company vs. apple the fruit). 0: disabled, 1: enabled (default) 192 linkedData -> include linked data on disambiguated entities. 0: disabled, 1: enabled (default) 193 coreference -> resolve coreferences (i.e. the pronouns that correspond to named entities). 0: disabled, 1: enabled (default) 194 quotations -> extract quotations by entities. 0: disabled (default), 1: enabled. 195 sentiment -> analyze sentiment for each entity. 0: disabled (default), 1: enabled. Requires 1 additional API transction if enabled. 196 showSourceText -> 0: disabled (default), 1: enabled 197 maxRetrieve -> the maximum number of entities to retrieve (default: 50) 200 The response, already converted from JSON to a Python object. 204 if flavor
not in AlchemyAPI.ENDPOINTS[
'entities']:
205 return {
'status':
'ERROR',
'statusInfo':
'entity extraction for ' + flavor +
' not available'}
208 options[flavor] = data
209 return self.__analyze(AlchemyAPI.ENDPOINTS[
'entities'][flavor], {}, options)
◆ feeds()
def dc_processor.alchemyapi.AlchemyAPI.feeds |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Detects the RSS/ATOM feeds for a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/feed-detection/
For the docs, please refer to: http://www.alchemyapi.com/api/feed-detection/
INPUT:
flavor -> which version of the call, i.e. url or html.
data -> the data to analyze, either the the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
none
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 514 of file alchemyapi.py.
514 def feeds(self, flavor, data, options={}):
516 Detects the RSS/ATOM feeds for a URL or HTML. 517 For an overview, please refer to: http://www.alchemyapi.com/products/features/feed-detection/ 518 For the docs, please refer to: http://www.alchemyapi.com/api/feed-detection/ 521 flavor -> which version of the call, i.e. url or html. 522 data -> the data to analyze, either the the url or html code. 523 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 529 The response, already converted from JSON to a Python object. 533 if flavor
not in AlchemyAPI.ENDPOINTS[
'feeds']:
534 return {
'status':
'ERROR',
'statusInfo':
'feed detection for ' + flavor +
' not available'}
537 options[flavor] = data
538 return self.__analyze(AlchemyAPI.ENDPOINTS[
'feeds'][flavor], {}, options)
◆ imageExtraction()
def dc_processor.alchemyapi.AlchemyAPI.imageExtraction |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Extracts main image from a URL
INPUT:
flavor -> which version of the call (url only currently).
data -> URL to analyze
options -> various parameters that can be used to adjust how the API works,
see below for more info on the available options.
Available Options:
extractMode ->
trust-metadata : (less CPU intensive, less accurate)
always-infer : (more CPU intensive, more accurate)
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 566 of file alchemyapi.py.
566 def imageExtraction(self, flavor, data, options={}):
568 Extracts main image from a URL 571 flavor -> which version of the call (url only currently). 572 data -> URL to analyze 573 options -> various parameters that can be used to adjust how the API works, 574 see below for more info on the available options. 578 trust-metadata : (less CPU intensive, less accurate) 579 always-infer : (more CPU intensive, more accurate) 581 The response, already converted from JSON to a Python object. 583 if flavor
not in AlchemyAPI.ENDPOINTS[
'image']:
584 return {
'status':
'ERROR',
'statusInfo':
'image extraction for ' + flavor +
' not available'}
585 options[flavor] = data
586 return self.__analyze(AlchemyAPI.ENDPOINTS[
'image'][flavor], {}, options)
◆ imageTagging()
def dc_processor.alchemyapi.AlchemyAPI.imageTagging |
( |
|
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.
Definition at line 705 of file alchemyapi.py.
705 def imageTagging(self, flavor, data, options={}):
709 flavor -> which version of the call only url or image. 710 data -> the data to analyze, either the the url or path to image. 711 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 713 if flavor
not in AlchemyAPI.ENDPOINTS[
'imagetagging']:
714 return {
'status':
'ERROR',
'statusInfo':
'imagetagging for ' + flavor +
' not available'}
715 elif 'image' == flavor:
716 image = open(data,
'rb').read()
717 options[
'imagePostMode'] =
'raw' 718 return self.__analyze(AlchemyAPI.ENDPOINTS[
'imagetagging'][flavor], options, image)
720 options[flavor] = data
721 return self.__analyze(AlchemyAPI.ENDPOINTS[
'imagetagging'][flavor], {}, options)
◆ keywords()
def dc_processor.alchemyapi.AlchemyAPI.keywords |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Extracts the keywords from text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/keyword-extraction/
For the docs, please refer to: http://www.alchemyapi.com/api/keyword-extraction/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
keywordExtractMode -> normal (default), strict
sentiment -> analyze sentiment for each keyword. 0: disabled (default), 1: enabled. Requires 1 additional API transaction if enabled.
showSourceText -> 0: disabled (default), 1: enabled.
maxRetrieve -> the max number of keywords returned (default: 50)
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 211 of file alchemyapi.py.
211 def keywords(self, flavor, data, options={}):
213 Extracts the keywords from text, a URL or HTML. 214 For an overview, please refer to: http://www.alchemyapi.com/products/features/keyword-extraction/ 215 For the docs, please refer to: http://www.alchemyapi.com/api/keyword-extraction/ 218 flavor -> which version of the call, i.e. text, url or html. 219 data -> the data to analyze, either the text, the url or html code. 220 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 223 keywordExtractMode -> normal (default), strict 224 sentiment -> analyze sentiment for each keyword. 0: disabled (default), 1: enabled. Requires 1 additional API transaction if enabled. 225 showSourceText -> 0: disabled (default), 1: enabled. 226 maxRetrieve -> the max number of keywords returned (default: 50) 229 The response, already converted from JSON to a Python object. 233 if flavor
not in AlchemyAPI.ENDPOINTS[
'keywords']:
234 return {
'status':
'ERROR',
'statusInfo':
'keyword extraction for ' + flavor +
' not available'}
237 options[flavor] = data
238 return self.__analyze(AlchemyAPI.ENDPOINTS[
'keywords'][flavor], {}, options)
◆ language()
def dc_processor.alchemyapi.AlchemyAPI.language |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Detects the language for text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/api/language-detection/
For the docs, please refer to: http://www.alchemyapi.com/products/features/language-detection/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
none
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 400 of file alchemyapi.py.
400 def language(self, flavor, data, options={}):
402 Detects the language for text, a URL or HTML. 403 For an overview, please refer to: http://www.alchemyapi.com/api/language-detection/ 404 For the docs, please refer to: http://www.alchemyapi.com/products/features/language-detection/ 407 flavor -> which version of the call, i.e. text, url or html. 408 data -> the data to analyze, either the text, the url or html code. 409 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 415 The response, already converted from JSON to a Python object. 419 if flavor
not in AlchemyAPI.ENDPOINTS[
'language']:
420 return {
'status':
'ERROR',
'statusInfo':
'language detection for ' + flavor +
' not available'}
423 options[flavor] = data
424 return self.__analyze(AlchemyAPI.ENDPOINTS[
'language'][flavor], {}, options)
◆ microformats()
def dc_processor.alchemyapi.AlchemyAPI.microformats |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Parses the microformats for a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/microformats-parsing/
For the docs, please refer to: http://www.alchemyapi.com/api/microformats-parsing/
INPUT:
flavor -> which version of the call, i.e. url or html.
data -> the data to analyze, either the the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
none
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 540 of file alchemyapi.py.
540 def microformats(self, flavor, data, options={}):
542 Parses the microformats for a URL or HTML. 543 For an overview, please refer to: http://www.alchemyapi.com/products/features/microformats-parsing/ 544 For the docs, please refer to: http://www.alchemyapi.com/api/microformats-parsing/ 547 flavor -> which version of the call, i.e. url or html. 548 data -> the data to analyze, either the the url or html code. 549 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 555 The response, already converted from JSON to a Python object. 559 if flavor
not in AlchemyAPI.ENDPOINTS[
'microformats']:
560 return {
'status':
'ERROR',
'statusInfo':
'microformat extraction for ' + flavor +
' not available'}
563 options[flavor] = data
564 return self.__analyze(AlchemyAPI.ENDPOINTS[
'microformats'][flavor], {}, options)
◆ relations()
def dc_processor.alchemyapi.AlchemyAPI.relations |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Extracts the relations for text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/relation-extraction/
For the docs, please refer to: http://www.alchemyapi.com/api/relation-extraction/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
sentiment -> 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled.
keywords -> extract keywords from the subject and object. 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled.
entities -> extract entities from the subject and object. 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled.
requireEntities -> only extract relations that have entities. 0: disabled (default), 1: enabled.
sentimentExcludeEntities -> exclude full entity name in sentiment analysis. 0: disabled, 1: enabled (default)
disambiguate -> disambiguate entities (i.e. Apple the company vs. apple the fruit). 0: disabled, 1: enabled (default)
linkedData -> include linked data with disambiguated entities. 0: disabled, 1: enabled (default).
coreference -> resolve entity coreferences. 0: disabled, 1: enabled (default)
showSourceText -> 0: disabled (default), 1: enabled.
maxRetrieve -> the maximum number of relations to extract (default: 50, max: 100)
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 452 of file alchemyapi.py.
452 def relations(self, flavor, data, options={}):
454 Extracts the relations for text, a URL or HTML. 455 For an overview, please refer to: http://www.alchemyapi.com/products/features/relation-extraction/ 456 For the docs, please refer to: http://www.alchemyapi.com/api/relation-extraction/ 459 flavor -> which version of the call, i.e. text, url or html. 460 data -> the data to analyze, either the text, the url or html code. 461 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 464 sentiment -> 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled. 465 keywords -> extract keywords from the subject and object. 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled. 466 entities -> extract entities from the subject and object. 0: disabled (default), 1: enabled. Requires one additional API transaction if enabled. 467 requireEntities -> only extract relations that have entities. 0: disabled (default), 1: enabled. 468 sentimentExcludeEntities -> exclude full entity name in sentiment analysis. 0: disabled, 1: enabled (default) 469 disambiguate -> disambiguate entities (i.e. Apple the company vs. apple the fruit). 0: disabled, 1: enabled (default) 470 linkedData -> include linked data with disambiguated entities. 0: disabled, 1: enabled (default). 471 coreference -> resolve entity coreferences. 0: disabled, 1: enabled (default) 472 showSourceText -> 0: disabled (default), 1: enabled. 473 maxRetrieve -> the maximum number of relations to extract (default: 50, max: 100) 476 The response, already converted from JSON to a Python object. 480 if flavor
not in AlchemyAPI.ENDPOINTS[
'relations']:
481 return {
'status':
'ERROR',
'statusInfo':
'relation extraction for ' + flavor +
' not available'}
484 options[flavor] = data
485 return self.__analyze(AlchemyAPI.ENDPOINTS[
'relations'][flavor], {}, options)
◆ sentiment()
def dc_processor.alchemyapi.AlchemyAPI.sentiment |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Calculates the sentiment for text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/sentiment-analysis/
For the docs, please refer to: http://www.alchemyapi.com/api/sentiment-analysis/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
showSourceText -> 0: disabled (default), 1: enabled
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 263 of file alchemyapi.py.
263 def sentiment(self, flavor, data, options={}):
265 Calculates the sentiment for text, a URL or HTML. 266 For an overview, please refer to: http://www.alchemyapi.com/products/features/sentiment-analysis/ 267 For the docs, please refer to: http://www.alchemyapi.com/api/sentiment-analysis/ 270 flavor -> which version of the call, i.e. text, url or html. 271 data -> the data to analyze, either the text, the url or html code. 272 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 275 showSourceText -> 0: disabled (default), 1: enabled 278 The response, already converted from JSON to a Python object. 282 if flavor
not in AlchemyAPI.ENDPOINTS[
'sentiment']:
283 return {
'status':
'ERROR',
'statusInfo':
'sentiment analysis for ' + flavor +
' not available'}
286 options[flavor] = data
287 return self.__analyze(AlchemyAPI.ENDPOINTS[
'sentiment'][flavor], {}, options)
◆ sentiment_targeted()
def dc_processor.alchemyapi.AlchemyAPI.sentiment_targeted |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
target, |
|
|
|
options = {} |
|
) |
| |
Calculates the targeted sentiment for text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/sentiment-analysis/
For the docs, please refer to: http://www.alchemyapi.com/api/sentiment-analysis/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
target -> the word or phrase to run sentiment analysis on.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
showSourceText -> 0: disabled, 1: enabled
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 289 of file alchemyapi.py.
289 def sentiment_targeted(self, flavor, data, target, options={}):
291 Calculates the targeted sentiment for text, a URL or HTML. 292 For an overview, please refer to: http://www.alchemyapi.com/products/features/sentiment-analysis/ 293 For the docs, please refer to: http://www.alchemyapi.com/api/sentiment-analysis/ 296 flavor -> which version of the call, i.e. text, url or html. 297 data -> the data to analyze, either the text, the url or html code. 298 target -> the word or phrase to run sentiment analysis on. 299 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 302 showSourceText -> 0: disabled, 1: enabled 305 The response, already converted from JSON to a Python object. 309 if target
is None or target ==
'':
310 return {
'status':
'ERROR',
'statusInfo':
'targeted sentiment requires a non-null target'}
313 if flavor
not in AlchemyAPI.ENDPOINTS[
'sentiment_targeted']:
314 return {
'status':
'ERROR',
'statusInfo':
'targeted sentiment analysis for ' + flavor +
' not available'}
317 options[flavor] = data
318 options[
'target'] = target
319 return self.__analyze(AlchemyAPI.ENDPOINTS[
'sentiment_targeted'][flavor], {}, options)
◆ taxonomy()
def dc_processor.alchemyapi.AlchemyAPI.taxonomy |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Taxonomy classification operations.
INPUT:
flavor -> which version of the call, i.e. url or html.
data -> the data to analyze, either the the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
showSourceText ->
include the original 'source text' the taxonomy categories were extracted from within the API response
Possible values:
1 - enabled
0 - disabled (default)
sourceText ->
where to obtain the text that will be processed by this API call.
AlchemyAPI supports multiple modes of text extraction:
web page cleaning (removes ads, navigation links, etc.), raw text extraction
(processes all web page text, including ads / nav links), visual constraint queries, and XPath queries.
Possible values:
cleaned_or_raw : cleaning enabled, fallback to raw when cleaning produces no text (default)
cleaned : operate on 'cleaned' web page text (web page cleaning enabled)
raw : operate on raw web page text (web page cleaning disabled)
cquery : operate on the results of a visual constraints query
Note: The 'cquery' http argument must also be set to a valid visual constraints query.
xpath : operate on the results of an XPath query
Note: The 'xpath' http argument must also be set to a valid XPath query.
cquery ->
a visual constraints query to apply to the web page.
xpath ->
an XPath query to apply to the web page.
baseUrl ->
rel-tag output base http url (must be uri-argument encoded)
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 588 of file alchemyapi.py.
588 def taxonomy(self, flavor, data, options={}):
590 Taxonomy classification operations. 593 flavor -> which version of the call, i.e. url or html. 594 data -> the data to analyze, either the the url or html code. 595 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 600 include the original 'source text' the taxonomy categories were extracted from within the API response 603 0 - disabled (default) 606 where to obtain the text that will be processed by this API call. 608 AlchemyAPI supports multiple modes of text extraction: 609 web page cleaning (removes ads, navigation links, etc.), raw text extraction 610 (processes all web page text, including ads / nav links), visual constraint queries, and XPath queries. 613 cleaned_or_raw : cleaning enabled, fallback to raw when cleaning produces no text (default) 614 cleaned : operate on 'cleaned' web page text (web page cleaning enabled) 615 raw : operate on raw web page text (web page cleaning disabled) 616 cquery : operate on the results of a visual constraints query 617 Note: The 'cquery' http argument must also be set to a valid visual constraints query. 618 xpath : operate on the results of an XPath query 619 Note: The 'xpath' http argument must also be set to a valid XPath query. 622 a visual constraints query to apply to the web page. 625 an XPath query to apply to the web page. 628 rel-tag output base http url (must be uri-argument encoded) 631 The response, already converted from JSON to a Python object. 634 if flavor
not in AlchemyAPI.ENDPOINTS[
'taxonomy']:
635 return {
'status':
'ERROR',
'statusInfo':
'taxonomy for ' + flavor +
' not available'}
636 options[flavor] = data
637 return self.__analyze(AlchemyAPI.ENDPOINTS[
'taxonomy'][flavor], {}, options)
◆ text()
def dc_processor.alchemyapi.AlchemyAPI.text |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Extracts the cleaned text (removes ads, navigation, etc.) for text, a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/text-extraction/
For the docs, please refer to: http://www.alchemyapi.com/api/text-extraction/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
useMetadata -> utilize meta description data, 0: disabled, 1: enabled (default)
extractLinks -> include links, 0: disabled (default), 1: enabled.
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 321 of file alchemyapi.py.
321 def text(self, flavor, data, options={}):
323 Extracts the cleaned text (removes ads, navigation, etc.) for text, a URL or HTML. 324 For an overview, please refer to: http://www.alchemyapi.com/products/features/text-extraction/ 325 For the docs, please refer to: http://www.alchemyapi.com/api/text-extraction/ 328 flavor -> which version of the call, i.e. text, url or html. 329 data -> the data to analyze, either the text, the url or html code. 330 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 333 useMetadata -> utilize meta description data, 0: disabled, 1: enabled (default) 334 extractLinks -> include links, 0: disabled (default), 1: enabled. 337 The response, already converted from JSON to a Python object. 341 if flavor
not in AlchemyAPI.ENDPOINTS[
'text']:
342 return {
'status':
'ERROR',
'statusInfo':
'clean text extraction for ' + flavor +
' not available'}
345 options[flavor] = data
346 return self.__analyze(AlchemyAPI.ENDPOINTS[
'text'][flavor], options)
◆ text_raw()
def dc_processor.alchemyapi.AlchemyAPI.text_raw |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Extracts the raw text (includes ads, navigation, etc.) for a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/text-extraction/
For the docs, please refer to: http://www.alchemyapi.com/api/text-extraction/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
none
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 348 of file alchemyapi.py.
348 def text_raw(self, flavor, data, options={}):
350 Extracts the raw text (includes ads, navigation, etc.) for a URL or HTML. 351 For an overview, please refer to: http://www.alchemyapi.com/products/features/text-extraction/ 352 For the docs, please refer to: http://www.alchemyapi.com/api/text-extraction/ 355 flavor -> which version of the call, i.e. text, url or html. 356 data -> the data to analyze, either the text, the url or html code. 357 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 363 The response, already converted from JSON to a Python object. 367 if flavor
not in AlchemyAPI.ENDPOINTS[
'text_raw']:
368 return {
'status':
'ERROR',
'statusInfo':
'raw text extraction for ' + flavor +
' not available'}
371 options[flavor] = data
372 return self.__analyze(AlchemyAPI.ENDPOINTS[
'text_raw'][flavor], {}, options)
◆ title()
def dc_processor.alchemyapi.AlchemyAPI.title |
( |
|
self, |
|
|
|
flavor, |
|
|
|
data, |
|
|
|
options = {} |
|
) |
| |
Extracts the title for a URL or HTML.
For an overview, please refer to: http://www.alchemyapi.com/products/features/text-extraction/
For the docs, please refer to: http://www.alchemyapi.com/api/text-extraction/
INPUT:
flavor -> which version of the call, i.e. text, url or html.
data -> the data to analyze, either the text, the url or html code.
options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
Available Options:
useMetadata -> utilize title info embedded in meta data, 0: disabled, 1: enabled (default)
OUTPUT:
The response, already converted from JSON to a Python object.
Definition at line 426 of file alchemyapi.py.
426 def title(self, flavor, data, options={}):
428 Extracts the title for a URL or HTML. 429 For an overview, please refer to: http://www.alchemyapi.com/products/features/text-extraction/ 430 For the docs, please refer to: http://www.alchemyapi.com/api/text-extraction/ 433 flavor -> which version of the call, i.e. text, url or html. 434 data -> the data to analyze, either the text, the url or html code. 435 options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. 438 useMetadata -> utilize title info embedded in meta data, 0: disabled, 1: enabled (default) 441 The response, already converted from JSON to a Python object. 445 if flavor
not in AlchemyAPI.ENDPOINTS[
'title']:
446 return {
'status':
'ERROR',
'statusInfo':
'title extraction for ' + flavor +
' not available'}
449 options[flavor] = data
450 return self.__analyze(AlchemyAPI.ENDPOINTS[
'title'][flavor], {}, options)
◆ apikey
dc_processor.alchemyapi.AlchemyAPI.apikey |
◆ BASE_URL
string dc_processor.alchemyapi.AlchemyAPI.BASE_URL = 'http://access.alchemyapi.com/calls' |
|
static |
◆ ENDPOINTS
dictionary dc_processor.alchemyapi.AlchemyAPI.ENDPOINTS = {} |
|
static |
dc_processor.alchemyapi.AlchemyAPI.s = requests.Session() |
|
static |
The documentation for this class was generated from the following file: