nlcalc package

class nlcalc.NLCalculator[source]

Bases: object

Natural Language Mathematical Calculator.

This class can be used to parse mathematical statements in natural language.

strict_mode_enabled
calculate(text)[source]

Calculate the output after parsing input.

Parameters:text (str) – A string value which should be parsed
Returns:The final result
Return type:int or float
Raises:ValueError – If the text cannot be succesfully parsed and evaluated to get a result.
strict_mode_enabled

Whether strict mode is enabled for the calculator instance.