@@ -112,7 +112,16 @@ class AlchemyAPI:
112112 ENDPOINTS ['microformats' ] = {}
113113 ENDPOINTS ['microformats' ]['url' ] = '/url/URLGetMicroformatData'
114114 ENDPOINTS ['microformats' ]['html' ] = '/html/HTMLGetMicroformatData'
115-
115+ ENDPOINTS ['combined' ] = {}
116+ ENDPOINTS ['combined' ]['url' ] = '/url/URLGetCombinedData'
117+ ENDPOINTS ['combined' ]['text' ] = '/text/TextGetCombinedData'
118+ ENDPOINTS ['image' ] = {}
119+ ENDPOINTS ['image' ]['url' ] = '/url/URLGetImage'
120+ ENDPOINTS ['taxonomy' ] = {}
121+ ENDPOINTS ['taxonomy' ]['url' ] = '/url/URLGetRankedTaxonomy'
122+ ENDPOINTS ['taxonomy' ]['html' ] = '/html/HTMLGetRankedTaxonomy'
123+ ENDPOINTS ['taxonomy' ]['text' ] = '/text/TextGetRankedTaxonomy'
124+
116125 #The base URL for all endpoints
117126 BASE_URL = 'http://access.alchemyapi.com/calls'
118127
@@ -570,7 +579,144 @@ def microformats(self, flavor, data, options={}):
570579 options [flavor ] = data
571580 return self .__analyze (AlchemyAPI .ENDPOINTS ['microformats' ][flavor ], options )
572581
582+ def imageExtraction (self , flavor , data , options = {}):
583+ """
584+ Extracts main image from a URL
585+
586+ INPUT:
587+ flavor -> which version of the call (url only currently).
588+ data -> URL to analyze
589+ options -> various parameters that can be used to adjust how the API works,
590+ see below for more info on the available options.
591+
592+ Available Options:
593+ extractMode ->
594+ trust-metadata : (less CPU intensive, less accurate)
595+ always-infer : (more CPU intensive, more accurate)
596+ OUTPUT:
597+ The response, already converted from JSON to a Python object.
598+ """
599+ if flavor not in AlchemyAPI .ENDPOINTS ['image' ]:
600+ return { 'status' :'ERROR' , 'statusInfo' :'image extraction for ' + flavor + ' not available' }
601+ options [flavor ] = data
602+ return self .__analyze (AlchemyAPI .ENDPOINTS ['image' ][flavor ], options )
603+
604+ def taxonomy (self , flavor , data , options = {}):
605+ """
606+ Taxonomy classification operations.
607+
608+ INPUT:
609+ flavor -> which version of the call, i.e. url or html.
610+ data -> the data to analyze, either the the url or html code.
611+ options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
612+
613+
614+ Available Options:
615+ showSourceText ->
616+ include the original 'source text' the taxonomy categories were extracted from within the API response
617+ Possible values:
618+ 1 - enabled
619+ 0 - disabled (default)
620+
621+ sourceText ->
622+ where to obtain the text that will be processed by this API call.
623+
624+ AlchemyAPI supports multiple modes of text extraction:
625+ web page cleaning (removes ads, navigation links, etc.), raw text extraction
626+ (processes all web page text, including ads / nav links), visual constraint queries, and XPath queries.
627+
628+ Possible values:
629+ cleaned_or_raw : cleaning enabled, fallback to raw when cleaning produces no text (default)
630+ cleaned : operate on 'cleaned' web page text (web page cleaning enabled)
631+ raw : operate on raw web page text (web page cleaning disabled)
632+ cquery : operate on the results of a visual constraints query
633+ Note: The 'cquery' http argument must also be set to a valid visual constraints query.
634+ xpath : operate on the results of an XPath query
635+ Note: The 'xpath' http argument must also be set to a valid XPath query.
636+
637+ cquery ->
638+ a visual constraints query to apply to the web page.
639+
640+ xpath ->
641+ an XPath query to apply to the web page.
642+
643+ baseUrl ->
644+ rel-tag output base http url (must be uri-argument encoded)
573645
646+ OUTPUT:
647+ The response, already converted from JSON to a Python object.
648+
649+ """
650+ if flavor not in AlchemyAPI .ENDPOINTS ['taxonomy' ]:
651+ return { 'status' :'ERROR' , 'statusInfo' :'taxonomy for ' + flavor + ' not available' }
652+ options [flavor ] = data
653+ return self .__analyze (AlchemyAPI .ENDPOINTS ['taxonomy' ][flavor ], options )
654+
655+ def combined (self , flavor , data , options = {}):
656+ """
657+ Combined call for page-image, entity, keyword, title, author, taxonomy, concept.
658+
659+ INPUT:
660+ flavor -> which version of the call, i.e. url or html.
661+ data -> the data to analyze, either the the url or html code.
662+ options -> various parameters that can be used to adjust how the API works, see below for more info on the available options.
663+
664+ Available Options:
665+ extract ->
666+ Possible values: page-image, entity, keyword, title, author, taxonomy, concept
667+ default : entity, keyword, taxonomy, concept
668+
669+ disambiguate ->
670+ disambiguate detected entities
671+ Possible values:
672+ 1 : enabled (default)
673+ 0 : disabled
674+
675+ linkedData ->
676+ include Linked Data content links with disambiguated entities
677+ Possible values :
678+ 1 : enabled (default)
679+ 0 : disabled
680+
681+ coreference ->
682+ resolve he/she/etc coreferences into detected entities
683+ Possible values:
684+ 1 : enabled (default)
685+ 0 : disabled
686+
687+ quotations ->
688+ enable quotations extraction
689+ Possible values:
690+ 1 : enabled
691+ 0 : disabled (default)
692+
693+ sentiment ->
694+ enable entity-level sentiment analysis
695+ Possible values:
696+ 1 : enabled
697+ 0 : disabled (default)
698+
699+ showSourceText ->
700+ include the original 'source text' the entities were extracted from within the API response
701+ Possible values:
702+ 1 : enabled
703+ 0 : disabled (default)
704+
705+ maxRetrieve ->
706+ maximum number of named entities to extract
707+ default : 50
708+
709+ baseUrl ->
710+ rel-tag output base http url
711+
712+
713+ OUTPUT:
714+ The response, already converted from JSON to a Python object.
715+ """
716+ if flavor not in AlchemyAPI .ENDPOINTS ['combined' ]:
717+ return { 'status' :'ERROR' , 'statusInfo' :'combined for ' + flavor + ' not available' }
718+ options [flavor ] = data
719+ return self .__analyze (AlchemyAPI .ENDPOINTS ['combined' ][flavor ], options )
574720
575721 def __analyze (self , endpoint , params ):
576722 """
0 commit comments