sciq.web.app.services.api_wolfram.waAPI

class web.app.services.api_wolfram.waAPI.Expression(query, results, id_equation=None, dir_plots=None, pods_format='mathml', output_result='default')

Bases: object

compute_full_result(results, output='plaintext')

Extract relevant information from the Wolfram|Alpha API response

Parameters:
  • results (list) – the result list from Wolfram|Alpha API
  • output (str, optional) – the output type to search for into the ‘results’ object. Defaults to “plaintext”.
extract_mathml(pod)

Extract mathml field from subpods

extract_plaintext(pod)

Extract plaintext field from subpods

print_expression()

Print content of the expression.

save_plots(id_equation, dir_plots)

Save image plots in dir_plots

to_json()

Convert expression object to json

exception web.app.services.api_wolfram.waAPI.ExpressionException(value)

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception web.app.services.api_wolfram.waAPI.NoAPIKeyException(value)

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

web.app.services.api_wolfram.waAPI.compute_expression(query, key='V2WJ46-EEXEV95WXG', id_equation=None, dir_plots=None, response_format=None, pods_format='mathml', output_result='default')

Returns an Expression object containing the query results

Parameters:
  • query (str) – expression query
  • key (str, optional) – key to use Wolfram Alpha API
  • id_equation (int, optional) – identifier to rename plot images
  • dir_plots (str, optional) – directory where to save plot images
  • pods_format (str, optional) – output for results: mathml or plaintext
Returns:

object of class Expression, to be

further analyzed

Return type:

expression

web.app.services.api_wolfram.waAPI.raw(text)

Returns a raw string representation of text

web.app.services.api_wolfram.waAPI.to_mathml(text_mml)

Return the correct mathml visualization of the expression returned from wolfram|alpha

class web.app.services.api_wolfram.waAPI.waAPI(key=None)

Bases: object

full_results(response_format=None, key=None, query=None, pods_format='mathml')

Calls the Wolfram|Alpha API and returns a dictionary of the search results

Parameters:
  • response_format (str, optional) – the format that the API uses for its response, includes JSON (.json) and XML. Defaults to ‘.xml’
  • key (str, optional) – the developer key. Defaults to key given when the waAPI class was initialized
  • query (str, optional) – the query string
  • pods_format (str, optional) – format of the result’s pods. It must be one from ‘mathml’ or ‘plaintex’. Defaults to ‘mathml’
Returns:

a json containing the query result from Wolfram|Alpha API

Return type:

result (json)