예제 #1
0
    def testGt(self):
        model = Model([
            ModelEntry(
                Close("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 1, 3, CL),
                                 Interval(CL, 1, 3, CL), CL)),
        ])
        result = inference(
            model,
            AndR(Not(overlaps(stub_model.Close("figure", "landmark"))),
                 [equals],
                 Tense([greaterThan], stub_model.Close("figure", "landmark"))))

        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(OP, Interval(OP, NINF, 1.0, OP),
                                 Interval(OP, NINF, 1.0, CL), OP),
                SpanningInterval(CL, Interval(OP, NINF, 1.0, OP),
                                 Interval(OP, NINF, 1.0, CL), OP),
                SpanningInterval(OP, Interval(OP, NINF, 1.0, OP),
                                 Interval(OP, NINF, 1.0, OP), CL),
                SpanningInterval(CL, Interval(OP, NINF, 1.0, OP),
                                 Interval(OP, NINF, 1.0, OP), CL)
            ]))
예제 #2
0
    def testIMeets(self):
        model = Model([
            ModelEntry(
                Close("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 1, 3, CL),
                                 Interval(CL, 1, 3, CL), CL)),
        ])
        result = inference(
            model, Tense([iMeets], stub_model.Close("figure", "landmark")))

        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(OP, Interval(OP, NINF, 3.0, OP),
                                 Interval(CL, 1.0, 3.0, CL), OP),
                SpanningInterval(CL, Interval(OP, NINF, 3.0, OP),
                                 Interval(CL, 1.0, 3.0, CL), OP)
            ]))

        result = inference(
            model, Tense([meets], stub_model.Close("figure", "landmark")))
        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(OP, Interval(CL, 1.0, 3.0, CL),
                                 Interval(OP, 1.0, PINF, OP), OP),
                SpanningInterval(OP, Interval(CL, 1.0, 3.0, CL),
                                 Interval(OP, 1.0, PINF, OP), CL)
            ]))
예제 #3
0
    def testInferenceBase(self):

        model = Model([
            ModelEntry(
                Visible("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 0, 0, CL),
                                 Interval(CL, 1, 1, CL), CL))
        ])

        result = inference(model, stub_model.Visible("figure", "landmark"))
        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(CL, Interval(CL, 0, 0, CL),
                                 Interval(CL, 1, 1, CL), CL)
            ]))

        result = inference(model, stub_model.Close("figure", "landmark"))
        self.assertEqual(result, emptySpanningIntervalSet)

        result = inference(model, Not(stub_model.Close("figure", "landmark")))
        self.assertEqual(result, allIntervals)

        result = inference(model,
                           overlaps(stub_model.Close("figure", "landmark")))
        self.assertEqual(result, emptySpanningIntervalSet)

        result = inference(
            model, Not(overlaps(stub_model.Close("figure", "landmark"))))
        self.assertEqual(result, allIntervals)
예제 #4
0
    def testTenseAndStarts(self):

        model = Model([
            ModelEntry(
                Close("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 1, 3, CL),
                                 Interval(CL, 1, 3, CL), CL)),
        ])

        result = inference(
            model, Tense([starts], stub_model.Close("figure", "landmark")))
        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(CL, Interval(CL, 1.0, 3.0, CL),
                                 Interval(OP, 1.0, PINF, OP), OP),
                SpanningInterval(CL, Interval(CL, 1.0, 3.0, CL),
                                 Interval(OP, 1.0, PINF, OP), CL)
            ]))

        result = inference(
            model, Tense([iStarts], stub_model.Close("figure", "landmark")))
        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(CL, Interval(CL, 1.0, 3.0, OP),
                                 Interval(OP, 1.0, 3.0, CL), OP),
                SpanningInterval(CL, Interval(CL, 1.0, 3.0, OP),
                                 Interval(CL, 1.0, 3.0, OP), CL)
            ]))

        result = inference(
            model,
            Tense([starts, iStarts], stub_model.Close("figure", "landmark")))
        self.assertEqual(
            result.condensed(),
            SpanningIntervalSet([
                SpanningInterval(CL, Interval(CL, 1.0, 3.0, CL),
                                 Interval(OP, 1.0, PINF, OP), OP),
                SpanningInterval(CL, Interval(CL, 1.0, 3.0, CL),
                                 Interval(CL, 1.0, PINF, OP), CL)
            ]))
예제 #5
0
    def testInferenceAnd(self):
        model = Model([
            ModelEntry(
                Visible("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 1, 3, CL),
                                 Interval(CL, 1, 3, CL), CL)),
            ModelEntry(
                Close("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 2, 3, CL),
                                 Interval(CL, 2, 3, CL), CL)),
            ModelEntry(
                Following("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 1, 3, CL),
                                 Interval(CL, 1, 3, CL), CL))
        ])

        result = inference(
            model,
            AndR(stub_model.Visible("figure", "landmark"),
                 [allenRelations.finishes],
                 stub_model.Close("figure", "landmark")))

        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(CL, Interval(CL, 2.0, 3.0, CL),
                                 Interval(CL, 2.0, 3.0, CL), CL)
            ]))

        result = inference(
            model,
            AndR(stub_model.Close("figure", "landmark"),
                 [allenRelations.finishes],
                 stub_model.Visible("figure", "landmark")))

        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(CL, Interval(CL, 1.0, 3.0, CL),
                                 Interval(CL, 2.0, 3.0, CL), CL)
            ]))
예제 #6
0
    def testNoApproach(self):
        model = Model([
            ModelEntry(
                Close("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 0, 3, CL),
                                 Interval(CL, 0, 3, CL), CL)),
        ])
        result = inference(
            model,
            AndR(Not(overlaps(stub_model.Close("figure", "landmark"))),
                 [equals],
                 Tense([iMeets], stub_model.Close("figure", "landmark"))))

        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(CL, Interval(OP, NINF, 0, OP),
                                 Interval(CL, 0, 0, CL), OP),
                SpanningInterval(OP, Interval(OP, NINF, 0, OP),
                                 Interval(CL, 0, 0, CL), OP)
            ]))

        self.assertEqual(result.snappedToMin(0), emptySpanningIntervalSet)
예제 #7
0
    def testInferenceOr(self):

        model = Model([
            ModelEntry(
                Visible("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 1, 3, CL),
                                 Interval(CL, 1, 3, CL), CL)),
            ModelEntry(
                Close("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 2, 3, CL),
                                 Interval(CL, 2, 3, CL), CL)),
            ModelEntry(
                Following("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 1, 3, CL),
                                 Interval(CL, 1, 3, CL), CL))
        ])

        result = inference(model, stub_model.Visible("figure", "landmark"))
        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(True, Interval(True, 1.0, 3.0, True),
                                 Interval(True, 1.0, 3.0, True), True)
            ]))

        result = inference(
            model,
            Or(stub_model.Visible("figure", "landmark"),
               stub_model.Following("figure", "landmark")))
        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(True, Interval(True, 1.0, 3.0, True),
                                 Interval(True, 1.0, 3.0, True), True)
            ]))

        result = inference(
            model,
            Or(stub_model.Close("figure", "landmark"),
               stub_model.Following("figure", "landmark")))

        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(CL, Interval(CL, 1.0, 3.0, CL),
                                 Interval(CL, 1.0, 3.0, CL), CL)
            ]))
예제 #8
0
    def testOverlaps(self):

        model = Model([
            ModelEntry(
                Close("figure", "landmark"),
                SpanningInterval(CL, Interval(CL, 1, 3, CL),
                                 Interval(CL, 1, 3, CL), CL)),
        ])

        result = inference(
            model, Not(overlaps(stub_model.Visible("figure", "landmark"))))

        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(OP, Interval(OP, NINF, PINF, OP),
                                 Interval(OP, NINF, PINF, OP), OP),
                SpanningInterval(OP, Interval(OP, NINF, PINF, OP),
                                 Interval(OP, NINF, PINF, OP), CL),
                SpanningInterval(CL, Interval(OP, NINF, PINF, OP),
                                 Interval(OP, NINF, PINF, OP), OP),
                SpanningInterval(CL, Interval(OP, NINF, PINF, OP),
                                 Interval(OP, NINF, PINF, OP), CL)
            ]))

        result = inference(model,
                           overlaps(stub_model.Close("figure", "landmark")))
        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(OP, Interval(OP, NINF, 3.0, OP),
                                 Interval(OP, 1.0, PINF, OP), OP),
                SpanningInterval(OP, Interval(OP, NINF, 3.0, OP),
                                 Interval(CL, 1.0, PINF, OP), CL),
                SpanningInterval(CL, Interval(OP, NINF, 3.0, CL),
                                 Interval(OP, 1.0, PINF, OP), OP),
                SpanningInterval(CL, Interval(OP, NINF, 3.0, CL),
                                 Interval(CL, 1.0, PINF, OP), CL)
            ]))

        result = inference(
            model, Not(overlaps(stub_model.Close("figure", "landmark"))))

        self.assertEqual(
            result,
            SpanningIntervalSet([
                SpanningInterval(OP, Interval(OP, NINF, 1.0, OP),
                                 Interval(OP, NINF, 1.0, CL), OP),
                SpanningInterval(OP, Interval(CL, 3.0, PINF, OP),
                                 Interval(OP, 3.0, PINF, OP), OP),
                SpanningInterval(CL, Interval(OP, NINF, 1.0, OP),
                                 Interval(OP, NINF, 1.0, CL), OP),
                SpanningInterval(CL, Interval(OP, 3.0, PINF, OP),
                                 Interval(OP, 3.0, PINF, OP), OP),
                SpanningInterval(OP, Interval(OP, NINF, 1.0, OP),
                                 Interval(OP, NINF, 1.0, OP), CL),
                SpanningInterval(OP, Interval(CL, 3.0, PINF, OP),
                                 Interval(OP, 3.0, PINF, OP), CL),
                SpanningInterval(CL, Interval(OP, NINF, 1.0, OP),
                                 Interval(OP, NINF, 1.0, OP), CL),
                SpanningInterval(CL, Interval(OP, 3.0, PINF, OP),
                                 Interval(OP, 3.0, PINF, OP), CL)
            ]))