예제 #1
0
    def resolve_by_time_constraints(candidates, timex_constraints):
        times = list((map(
            lambda ti: TimexHelpers.time_from_timex(ti),
            filter(lambda t: Constants.TIMEX_TYPES_TIME in t.types,
                   timex_constraints))))
        if not any(times):
            return candidates

        resolutions = []

        for timex in list(map(lambda t: Timex(t), candidates)):
            if Constants.TIMEX_TYPES_DATE in timex.types and not (
                    Constants.TIMEX_TYPES_TIME in timex.types):
                for time in times:
                    timex.hour = time.hour
                    timex.minute = time.minute
                    timex.second = time.second
                    resolutions.append(timex.timex_value())
            else:
                resolutions.append(timex.timex_value())

        return TimexRangeResolver.remove_duplicates(resolutions)
def test_datatypes_helpers_timefromtimex():
    timex = Timex(timex='T00:05:00')
    time = TimexHelpers.time_from_timex(timex)

    assert time.get_time() == Time(0, 5, 0).get_time()