PassageParser¶
-
class
tupa.parse.PassageParser(passage, *args, **kwargs)[source]¶ Bases:
tupa.parse.AbstractParserParser for a single passage, has a state and optionally an oracle
Attributes Summary
accuracy_strnum_tokensMethods Summary
check_loop()Check if the current state has already occurred, indicating a loop choose(true[, axis, name])correct(axis, label, pred, scores, true, …)evaluate([mode])finish(status[, display, write, accuracies])generate_descending(scores)get_true_actions()get_true_label(node)init()label_node([action])parse([display, write, accuracies])parse_internal()Internal method to parse a single passage. predict(scores, values[, is_valid])Choose action/label based on classifier Usually the best action/label is valid, so max is enough to choose it in O(n) time Otherwise, sorts all the other scores to choose the best valid one in O(n lg n) :return: valid action/label with maximum probability according to classifier verify(guessed, ref)Compare predicted passage to true passage and raise an exception if they differ :param ref: true passage :param guessed: predicted passage to compare Attributes Documentation
-
accuracy_str¶
-
num_tokens¶
Methods Documentation
-
parse_internal()[source]¶ Internal method to parse a single passage. If training, use oracle to train on given passages. Otherwise just parse with classifier.
-
static
predict(scores, values, is_valid=None)[source]¶ Choose action/label based on classifier Usually the best action/label is valid, so max is enough to choose it in O(n) time Otherwise, sorts all the other scores to choose the best valid one in O(n lg n) :return: valid action/label with maximum probability according to classifier
-