AIR Equation Scoring Engine Python API¶
Module airscore¶
The airscore module is the primary Python entry point for the AIR Equation Scoring Engine. It provides two functions. The function process_mathml_data() accepts inputs in the MathML format, and returns an equivalent expression in a form that can be parsed by the Sympy symbolic mathematics library. The function isEquivalent() Uses Sympy to determine if two sets of expressions, equations, or inequalities are mathematically equivalent.
In order to compare a test answer, expressed in MathML, with a rubric, also expressed in MathML, the two functions are used in conjunction, like this:
answer_txt = unicode( process_mathml_data( answer_mathml ) )
rubric_txt = unicode( process_mathml_data( rubric_mathml ) )
is_correct = isEquivalent( answer_txt, rubric_txt )
- airscore.isEquivalent(response, rubric, allowChangeOfVariable=False, allowSimplify=True, trigIdentities=False, logIdentities=False, forceAssumptions=False)¶
True if Sympy is able to determine that the two expressions are equivalent.
This function requires two parameters: a test answer and a rubric. Each of these is a string. Each string defines an equality, an inequality, or an expression in a form that can be parsed by the Sympy symbolic mathematics library. Alternatively, the answer or rubric may be a list of such equations, inequalities or expressions, enclosed in square brackets and separated by commas.
Additional optional parameters control the manipulations that Sympy will make when attempting to determine the equivalence of the response and the rubric
Parameters:
- airscore.process_mathml_data(mathml_string, encoding=None)¶
Convert MathML into a form that can be understood by Sympy
The provided string must either contain a <mathml:math> element as the root, or it must contain a <response> element (no namespace), which contains zero or more <mathml:math> elements as children.
Parameters: Returns: A MathExpressionList object equivalent to the MathML original. This object’s __unicode__() method returns a string that can be passed to Sympy
Module airscore.mathmlsympy.math_expression¶
Most of the classes and methods in airscore.mathmlsympy.math_expression are mainly of interested to those who intend to extend the MathML parsing engine to understand a wider selection of MathML elements. Two classes may be of interest to ordinary users of these libraries, however. These are the MathExpressionList class that is returned by airscore.process_mathml_data(), and the MathExpression objects that it contains.
- class airscore.mathmlsympy.math_expression.MathExpression(math_node)¶
The representation of a MathML expression, equality, or inequality that has been returned by the parser.
- math_node¶
airscore.mathmlsympy.mathml_containser.MathmlMath - The XML element tree (see xml.etree.ElementTree) that was returned by the parser. Elements within the tree will be represented by subclasses of airscore.mathmlsympy.base_mathml_element.BaseMathmlElement, which in turn subclasses xml.etree.ElementTree.Element
- sympy_response¶
list of str - A list of strings representing equations, inequalities or expressions. This is the result of parsing the XML represented by math_node. The list will consist of more than one element if the math_node contains more than one equality or inequality operator. Specifically, if the MathML represents something like:
A = B = C < D
then the list will contain three entries, corresponding to:
A = B B = C C < D
- class airscore.mathmlsympy.math_expression.MathExpressionList¶
A container for multiple MathExpression elements.
The __str__() and __unicode__() methods have been overridden to return strings that will be useful to Sympy.