예제 #1
0
 def test_context_register_empty(self, make_complex_fact):
     """
     Yields no context_register because the Term in f1 doesn't imply
     the Fact in f_relevant_murder.
     """
     statement = Statement(predicate="$person was a defendant",
                           terms=Entity(name="Alice"))
     complex_statement = make_complex_fact["relevant_murder"]
     gen = statement._context_registers(complex_statement, operator.ge)
     with pytest.raises(StopIteration):
         next(gen)
예제 #2
0
    def test_no_duplicate_context_interchangeable_terms(self):
        left = Statement(
            predicate=Predicate(
                content="$country1 signed a treaty with $country2"),
            terms=(Entity(name="Mexico"), Entity(name="USA")),
        )

        right = Statement(
            predicate=Predicate(
                content="$country3 signed a treaty with $country1"),
            terms=(Entity(name="Germany"), Entity(name="UK")),
        )

        context = ContextRegister.from_lists([Entity(name="USA")],
                                             [Entity(name="UK")])

        gen = left._context_registers(right, operator.ge, context)
        results = list(gen)
        assert len(results) == 1