mwptoolkit.evaluate.evaluator¶
- class mwptoolkit.evaluate.evaluator.AbstractEvaluator(config)[source]¶
Bases:
object
abstract evaluator
- class mwptoolkit.evaluate.evaluator.InfixEvaluator(config)[source]¶
Bases:
AbstractEvaluator
evaluator for infix equation sequnence.
- result(test_exp, tar_exp)[source]¶
evaluate single equation.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): iist of target expression.
- result_multi(test_exp, tar_exp)[source]¶
evaluate multiple euqations.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- class mwptoolkit.evaluate.evaluator.MultiEncDecEvaluator(config)[source]¶
Bases:
PostfixEvaluator
,PrefixEvaluator
evaluator for deep-learning model MultiE&D.
- postfix_result(test_exp, tar_exp)[source]¶
evaluate single postfix equation.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- postfix_result_multi(test_exp, tar_exp)[source]¶
evaluate multiple postfix euqations.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- prefix_result(test_exp, tar_exp)[source]¶
evaluate single prefix equation.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- prefix_result_multi(test_exp, tar_exp)[source]¶
evaluate multiple prefix euqations.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- result(test_exp, tar_exp)[source]¶
evaluate single equation.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- result_multi(test_exp, tar_exp)[source]¶
evaluate multiple euqations.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- class mwptoolkit.evaluate.evaluator.MultiWayTreeEvaluator(config)[source]¶
Bases:
AbstractEvaluator
- result(test_exp, tar_exp)[source]¶
evaluate single equation.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- result_multi(test_exp, tar_exp)[source]¶
evaluate multiple euqations.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- class mwptoolkit.evaluate.evaluator.PostfixEvaluator(config)[source]¶
Bases:
AbstractEvaluator
evaluator for postfix equation.
- result(test_exp, tar_exp)[source]¶
evaluate single equation.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- result_multi(test_exp, tar_exp)[source]¶
evaluate multiple euqations.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- class mwptoolkit.evaluate.evaluator.PrefixEvaluator(config)[source]¶
Bases:
AbstractEvaluator
evaluator for prefix equation.
- result(test_exp, tar_exp)[source]¶
evaluate single equation.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- result_multi(test_exp, tar_exp)[source]¶
evaluate multiple euqations.
- Parameters
test_exp (list) – list of test expression.
tar_exp (list) – list of target expression.
- Returns
(tuple(bool,bool,list,list))
val_ac (bool): the correctness of test expression answer compared to target expression answer.
equ_ac (bool): the correctness of test expression compared to target expression.
test_exp (list): list of test expression.
tar_exp (list): list of target expression.
- class mwptoolkit.evaluate.evaluator.Solver(func, equations, unk_symbol)[source]¶
Bases:
Thread
time-limited equation-solving mechanism based threading.
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
- mwptoolkit.evaluate.evaluator.get_evaluator(config)[source]¶
build evaluator
- Parameters
config (Config) – An instance object of Config, used to record parameter information.
- Returns
Constructed evaluator.
- Return type
Evaluator
- mwptoolkit.evaluate.evaluator.get_evaluator_module(config: Config) Type[Union[PrefixEvaluator, InfixEvaluator, PostfixEvaluator, MultiWayTreeEvaluator, AbstractEvaluator, MultiEncDecEvaluator]] [source]¶
return a evaluator module according to config
- Parameters
config – An instance object of Config, used to record parameter information.
- Returns
evaluator module