def test_atis_helper_methods(self):  # pylint: disable=no-self-use
        world = AtisWorld([("what is the earliest flight in morning "
                            "1993 june fourth from boston to pittsburgh")])
        assert world.dates == [datetime(1993, 6, 4, 0, 0)]
        assert world._get_numeric_database_values('time_range_end') == [
            '800', '1200'
        ]  # pylint: disable=protected-access
        assert world._get_sequence_with_spacing(world.grammar, # pylint: disable=protected-access
                                                [world.grammar['col_ref'],
                                                 Literal('BETWEEN'),
                                                 world.grammar['time_range_start'],
                                                 Literal(f'AND'),
                                                 world.grammar['time_range_end']]) == \
                                                Sequence(world.grammar['col_ref'],
                                                         world.grammar['ws'],
                                                         Literal('BETWEEN'),
                                                         world.grammar['ws'],
                                                         world.grammar['time_range_start'],
                                                         world.grammar['ws'],
                                                         Literal(f'AND'),
                                                         world.grammar['ws'],
                                                         world.grammar['time_range_end'],
                                                         world.grammar['ws'])

        world = AtisWorld(['i plan to travel on the tenth of 1993 july'])
        assert world.dates == [datetime(1993, 7, 10, 0, 0)]
Пример #2
0
    def test_atis_helper_methods(self):
        world = AtisWorld(
            [
                (
                    "what is the earliest flight in morning "
                    "1993 june fourth from boston to pittsburgh"
                )
            ]
        )
        assert world.dates == [datetime(1993, 6, 4, 0, 0)]
        assert world._get_numeric_database_values("time_range_end") == ["800", "1200"]
        assert world._get_sequence_with_spacing(
            world.grammar,
            [
                world.grammar["col_ref"],
                Literal("BETWEEN"),
                world.grammar["time_range_start"],
                Literal(f"AND"),
                world.grammar["time_range_end"],
            ],
        ) == Sequence(
            world.grammar["col_ref"],
            world.grammar["ws"],
            Literal("BETWEEN"),
            world.grammar["ws"],
            world.grammar["time_range_start"],
            world.grammar["ws"],
            Literal(f"AND"),
            world.grammar["ws"],
            world.grammar["time_range_end"],
            world.grammar["ws"],
        )

        world = AtisWorld(["i plan to travel on the tenth of 1993 july"])
        assert world.dates == [datetime(1993, 7, 10, 0, 0)]
Пример #3
0
    def test_atis_helper_methods(self): # pylint: disable=no-self-use
        world = AtisWorld([("what is the earliest flight in morning "
                            "1993 june fourth from boston to pittsburgh")])
        assert world.dates == [datetime(1993, 6, 4, 0, 0)]
        assert world._get_numeric_database_values('time_range_end') == ['800', '1200'] # pylint: disable=protected-access
        assert world._get_sequence_with_spacing(world.grammar, # pylint: disable=protected-access
                                                [world.grammar['col_ref'],
                                                 Literal('BETWEEN'),
                                                 world.grammar['time_range_start'],
                                                 Literal(f'AND'),
                                                 world.grammar['time_range_end']]) == \
                                                Sequence(world.grammar['col_ref'],
                                                         world.grammar['ws'],
                                                         Literal('BETWEEN'),
                                                         world.grammar['ws'],
                                                         world.grammar['time_range_start'],
                                                         world.grammar['ws'],
                                                         Literal(f'AND'),
                                                         world.grammar['ws'],
                                                         world.grammar['time_range_end'],
                                                         world.grammar['ws'])

        world = AtisWorld(['i plan to travel on the tenth of 1993 july'])
        assert world.dates == [datetime(1993, 7, 10, 0, 0)]