normalisation_functions Package¶
date_functions
Module¶
-
ternip.rule_engine.normalisation_functions.date_functions.
convert_to_24_hours
(time, ap)[source]¶ Given a hour and an a/p specifier, then convert the hour into 24 hour clock if need be
-
ternip.rule_engine.normalisation_functions.date_functions.
date_to_dow
(y, m, d)[source]¶ Gets the integer day of week for a date. Sunday is 0.
-
ternip.rule_engine.normalisation_functions.date_functions.
date_to_iso
(string)[source]¶ A translation of GUTime’s Date2ISO function. Given some date/time string representing an absolute date, then return a date string in the basic ISO format.
-
ternip.rule_engine.normalisation_functions.date_functions.
date_to_week
(y, m, d)[source]¶ Convert a date into a week number string, with year
-
ternip.rule_engine.normalisation_functions.date_functions.
easter_date
(y)[source]¶ Return the date of Easter for that year as a string
-
ternip.rule_engine.normalisation_functions.date_functions.
extract_timezone
(string)[source]¶ Given some string, try and extract the timezone it refers to. Returns a string.
relative_date_functions
Module¶
-
ternip.rule_engine.normalisation_functions.relative_date_functions.
compute_offset_base
(ref_date, expression, current_direction)[source]¶ Given a reference date, some simple expression (yesterday/tomorrow or a day of week) and the direction of the relative expression, the base date with which to compute the offset from as a date string
-
ternip.rule_engine.normalisation_functions.relative_date_functions.
offset_from_date
(v, offset, gran='D', exact=False)[source]¶ Given a date string and some numeric offset, as well as a unit, then compute the offset from that value by offset gran’s. Gran defaults to D. If exact is set to true, then the exact date is figured out, otherwise the level of granuality given by gran is used. Returns a date string.
string_conversions
Module¶
Functions which convert strings to some number index
-
ternip.rule_engine.normalisation_functions.string_conversions.
build_duration_value
(num, unit)[source]¶
-
ternip.rule_engine.normalisation_functions.string_conversions.
day_to_num
(day)[source]¶ Given the name of a day, the number of that day. Sunday is 0. Invalid data gets 7. All returned as integers.
-
ternip.rule_engine.normalisation_functions.string_conversions.
decade_nums
(dec)[source]¶ Given the decade component (less the ty suffix) of a year, the number of that year as an integer.
-
ternip.rule_engine.normalisation_functions.string_conversions.
fixed_holiday_date
(hol)[source]¶ Get the date string MMDD of a holiday
-
ternip.rule_engine.normalisation_functions.string_conversions.
month_to_num
(m)[source]¶ Given a name of a month, get the number of that month. Invalid data gets 0. Returned as an integer.
-
ternip.rule_engine.normalisation_functions.string_conversions.
nth_dow_holiday_date
(hol)[source]¶ Given the name of a holiday which always occur on the Nth X of some month, where X is day of week, returns tuples of the form (month, dow, n) representing the information about that holiday.
-
ternip.rule_engine.normalisation_functions.string_conversions.
season
(s)[source]¶ Transforms a season name into an identifer from TIDES. Invalid data gets returned as is