def test_one_match_with_duplicates(context4): tree = NodeTree(context4) current_node = tree.next() while current_node: assert current_node.total_options == 2 current_node = tree.next()
def test_one_match_in_two_steps(context2): tree = NodeTree(context2) len_sentence = len(context2.get_sentence()) node1 = tree.next() assert node1.state == NodeState.CHILD assert node1.segment.word == '......-...-..' assert node1.pos == 0 len_before = node1.pos len_word = len(node1.segment) len_remaining = node1.nb_remaining assert len_before + len_word + len_remaining == len_sentence assert len(node1.options) == 1 # O assert node1.is_done is False node2 = tree.next() assert node2.state == NodeState.CHILD assert node2.segment.word == '---' assert node2.pos == 13 len_before = node2.pos len_word = len(node2.segment) len_remaining = node2.nb_remaining assert len_before + len_word + len_remaining == len_sentence assert len(node2.options) == 0 # no more options assert node2.is_done assert tree.next() is None
def test_single_match_in_one_step(context1): tree = NodeTree(context1) node = tree.next() assert node.state == NodeState.CHILD assert node.segment.word == '......-...-..---' assert node.pos == 0 len_sentence = len(context1.get_sentence()) len_before = node.pos len_word = len(node.segment) len_remaining = node.nb_remaining assert len_before + len_word + len_remaining == len_sentence assert len(node.options) == 0 # no more options assert node.is_done assert tree.next() is None