ctparse package

Submodules

ctparse.corpus module

class ctparse.corpus.TimeParseEntry(text, ts, gold)

Bases: tuple

gold

Alias for field number 2

text

Alias for field number 0

ts

Alias for field number 1

ctparse.corpus.load_timeparse_corpus(fname: str) → Sequence[ctparse.corpus.TimeParseEntry][source]

Load a corpus from disk.

For more information about the format of the time parse corpus, refer to the documentation.

ctparse.corpus.make_partial_rule_dataset(entries: Sequence[ctparse.corpus.TimeParseEntry], scorer: ctparse.scorer.Scorer, timeout: Union[float, int], max_stack_depth: int, relative_match_len: float = 1.0, progress: bool = False) → Iterable[Tuple[List[str], bool]][source]

Build a data set from an iterable of TimeParseEntry.

The text is run through ctparse and all parses (within the specified timeout, max_stack_depth and scorer) are obtained. Each parse contains a sequence of rules (see CTParse.rules) used to produce that parse.

A dataset is generated by taking every possible partial rule and assigning to it a boolean indicating if that partial sequence did lead to a successful parse.

If progress is True, display a progress bar.

Example:

rule sequence: [r1, r2, r3] parse_is_correct: True

[r1] -> True [r1, r2] -> True [r1, r2, r3] -> True

ctparse.corpus.parse_nb_string(gold_parse: str) → Union[ctparse.types.Time, ctparse.types.Interval, ctparse.types.Duration][source]

Parse a Time, Interval or Duration from their no-bound string representation.

The no-bound string representations are generated from Artifact.nb_str.

ctparse.corpus.run_corpus(corpus: Sequence[Tuple[str, str, Sequence[str]]]) → Tuple[List[List[str]], List[bool]][source]

Load the corpus (currently hard coded), run it through ctparse with no timeout and no limit on the stack depth.

The corpus passes if ctparse generates the desired solution for each test at least once. Otherwise it fails.

While testing this, a labeled data set (X, y) is generated based on all productions. Given a final production p, based on initial regular expression matches r_0, …, r_n, which are then subsequently transformed using production rules p_0, …, p_m, will result in the samples

[r_0, …, r_n, p_0, ‘step_0’] [r_0, …, r_n, p_0, p_1, ‘step_1’] … [r_0, …, r_n, p_0, …, p_m, ‘step_m’]

All samples from one production are given the same label which indicates if the production was correct.

To build a similar datasets without the strict checking, use make_partial_rule_dataset

ctparse.corpus.run_single_test(target: str, ts: str, test: str) → None[source]

Run a single test case and raise an exception if the target was never produced.

Below max_stack_depth might be increased if tests fail.

Parameters:
  • target (str) – Target to produce
  • ts (str) – Reference time as string
  • test (str) – Test case

ctparse.count_vectorizer module

class ctparse.count_vectorizer.CountVectorizer(ngram_range: Tuple[int, int])[source]

Bases: object

fit(documents: Sequence[Sequence[str]]) → ctparse.count_vectorizer.CountVectorizer[source]

Learn a vocabulary dictionary of all tokens in the raw documents.

Parameters:documents (Sequence[Sequence[str]]) – Sequence of documents, each as a sequence of tokens
Returns:The updated vectorizer, i.e. this updates the internal vocabulary
Return type:CountVectorizer
fit_transform(documents: Sequence[Sequence[str]]) → Sequence[Dict[int, int]][source]

Learn the vocabulary dictionary and return a term-document matrix. Updates the internal vocabulary state of the vectorizer.

Parameters:documents (Sequence[Sequence[str]) – Sequence of documents, each as a sequence of tokens
Returns:Document-term matrix.
Return type:Sequence[Dict[int, int]]
transform(documents: Sequence[Sequence[str]]) → Sequence[Dict[int, int]][source]

Create term-document matrix based on pre-generated vocabulary. Does not update the internal state of the vocabulary.

Parameters:documents (Sequence[Sequence[str]]) – Sequence of documents, each as a sequence of tokens
Returns:Document-term matrix.
Return type:Sequence[Dict[int, int]]

ctparse.ctparse module

class ctparse.ctparse.CTParse(resolution: ctparse.types.Artifact, production: Tuple[Union[int, str], ...], score: float)[source]

Bases: object

ctparse.ctparse.ctparse(txt: str, ts: Optional[datetime.datetime] = None, timeout: Union[int, float] = 1.0, debug: bool = False, relative_match_len: float = 1.0, max_stack_depth: int = 10, scorer: Optional[ctparse.scorer.Scorer] = None, latent_time: bool = True) → Optional[ctparse.ctparse.CTParse][source]

Parse a string txt into a time expression

Parameters:
  • ts (datetime.datetime) – reference time
  • timeout (float) – timeout for parsing in seconds; timeout=0 indicates no timeout
  • debug – if True do return iterator over all resolution, else return highest scoring one (default=False)
  • relative_match_len (float) – relative minimum share of characters an initial regex match sequence must cover compared to the longest such sequence found to be considered for productions (default=1.0)
  • max_stack_depth (int) – limit the maximal number of highest scored candidate productions considered for future productions (default=10); set to 0 to not limit
  • latent_time – if True, resolve expressions that contain only a time (e.g. 8:00 pm) to be the next matching time after reference time ts
Returns:

Optional[CTParse]

ctparse.ctparse.ctparse_gen(txt: str, ts: Optional[datetime.datetime] = None, timeout: Union[int, float] = 1.0, relative_match_len: float = 1.0, max_stack_depth: int = 10, scorer: Optional[ctparse.scorer.Scorer] = None, latent_time: bool = True) → Iterator[Optional[ctparse.ctparse.CTParse]][source]

Generate parses for the string txt.

This function is equivalent to ctparse, with the exception that it returns an iterator over the matches as soon as they are produced.

ctparse.loader module

Utility to load default model in ctparse

ctparse.loader.load_default_scorer() → ctparse.scorer.Scorer[source]

Load the scorer shipped with ctparse.

If the scorer is not found, the scorer defaults to DummyScorer.

ctparse.nb_estimator module

class ctparse.nb_estimator.MultinomialNaiveBayes(alpha: float = 1.0)[source]

Bases: object

Implements a multinomial naive Bayes classifier. For background information (and what has inspired this, see e.g. https://scikit-learn.org/stable/

…modules/generated/sklearn.naive_bayes.MultinomialNB.html)
fit(X: Sequence[Dict[int, int]], y: Sequence[int]) → ctparse.nb_estimator.MultinomialNaiveBayes[source]

Fit a naive Bayes model from a count of feature matrix

Parameters:
  • X (Sequence[Dict[int, int]]) – Sequence of sparse {feature_index: count} dictionaries
  • y (Sequence[int]) – Labels +1/-1
Returns:

The fitted model

Return type:

MultinomialNaiveBayes

predict_log_probability(X: Sequence[Dict[int, int]]) → Sequence[Tuple[float, float]][source]

Calculate the posterior log probability of new sample X

Parameters:X (Sequence[Dict[int, int]]) – Sequence of data to predict on as sparse {feature_index: count} dictionarie
Returns:Tuple of (negative-class, positive-class) log likelihoods
Return type:Sequence[Tuple[float, float]]

ctparse.nb_scorer module

This module cointains the implementation of the scorer based on naive bayes.

class ctparse.nb_scorer.NaiveBayesScorer(nb_model: ctparse.pipeline.CTParsePipeline)[source]

Bases: ctparse.scorer.Scorer

classmethod from_model_file(fname: str) → ctparse.nb_scorer.NaiveBayesScorer[source]
score(txt: str, ts: datetime.datetime, partial_parse: ctparse.partial_parse.PartialParse) → float[source]

Produce a score for a partial production.

Parameters:
  • txt – the text that is being parsed
  • ts – the reference time
  • partial_parse – the partial parse that needs to be scored
score_final(txt: str, ts: datetime.datetime, partial_parse: ctparse.partial_parse.PartialParse, prod: ctparse.types.Artifact) → float[source]

Produce the final score for a production.

Parameters:
  • txt – the text that is being parsed
  • ts – the reference time
  • partial_parse – the PartialParse object that generated the production
  • prod – the production
ctparse.nb_scorer.save_naive_bayes(model: ctparse.pipeline.CTParsePipeline, fname: str) → None[source]

Save a naive bayes model for NaiveBayesScorer

ctparse.nb_scorer.train_naive_bayes(X: Sequence[Sequence[str]], y: Sequence[bool]) → ctparse.pipeline.CTParsePipeline[source]

Train a naive bayes model for NaiveBayesScorer

ctparse.partial_parse module

class ctparse.partial_parse.PartialParse(prod: Tuple[ctparse.types.Artifact, ...], rules: Tuple[Union[int, str], ...])[source]

Bases: object

apply_rule(ts: datetime.datetime, rule: Callable[[...], Optional[ctparse.types.Artifact]], rule_name: Union[str, int], match: Tuple[int, int]) → Optional[ctparse.partial_parse.PartialParse][source]

Check whether the production in rule can be applied to this stack element.

If yes, return a copy where this update is incorporated in the production, the record of applied rules and the score.

Parameters:
  • ts – reference time
  • rule – a tuple where the first element is the production rule to apply
  • rule_name – the name of the rule
  • match – the start and end index of the parameters that the rule needs.
classmethod from_regex_matches(regex_matches: Tuple[ctparse.types.RegexMatch, ...]) → ctparse.partial_parse.PartialParse[source]

Create partial production from a series of RegexMatch

This usually is called when no production rules (with the exception of regex matches) have been applied.

ctparse.pipeline module

class ctparse.pipeline.CTParsePipeline(transformer: ctparse.count_vectorizer.CountVectorizer, estimator: ctparse.nb_estimator.MultinomialNaiveBayes)[source]

Bases: object

fit(X: Sequence[Sequence[str]], y: Sequence[int]) → ctparse.pipeline.CTParsePipeline[source]

Fit the transformer and then fit the Naive Bayes model on the transformed data

Returns:Returns the fitted pipeline
Return type:CTParsePipeline
predict_log_proba(X: Sequence[Sequence[str]]) → Sequence[Tuple[float, float]][source]

Apply the transforms and get probability predictions from the estimator

Parameters:X (Sequence[Sequence[str]]) – Sequence of documents, each as sequence of tokens. In ctparse case there are just the names of the regex matches and rules applied
Returns:For each document the tuple of negative/positive log probability from the naive bayes model
Return type:Sequence[Tuple[float, float]]

ctparse.rule module

ctparse.rule.dimension(dim: Type[ctparse.types.Artifact]) → Callable[[ctparse.types.Artifact], bool][source]
ctparse.rule.predicate(pred: str) → Callable[[ctparse.types.Artifact], bool][source]
ctparse.rule.regex_match(r_id: int) → Callable[[ctparse.types.Artifact], bool][source]
ctparse.rule.rule(*patterns) → Callable[[Any], Callable[[...], Optional[ctparse.types.Artifact]]][source]
ctparse.rule.ruleAbsorbFromInterval(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleAbsorbOnTime(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleAfterTime(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleAfterTomorrow(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleAtDOW(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleBeforeTime(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleBeforeYesterday(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDDMM(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDDMMYYYY(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOM1(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOM2(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOMDate(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOMMonth(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOMMonth2(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOWDOM(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOWDate(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOWNextWeek(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOWPOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOYDate(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDOYYear(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDateDOM(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDateDOW(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDateDOWInterval(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDateDate(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDateInterval(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDatePOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDateTOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDateTimeDateTime(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDigitDuration(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDurationAndDuration(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDurationDuration(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDurationHalf(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleDurationInterval(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleEOM(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleEOY(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleEarlyLatePOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleHHMM(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleHHMMmilitary(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleHHOClock(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleHalfAfterHH(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleHalfBeforeHH(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleIntervalConjDuration(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleIntervalDuration(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleLatentDOM(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleLatentDOW(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleLatentDOY(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleLatentPOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleMMDD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleMidnight(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleMonthDOM(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleMonthOrdinal(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleMonthYear(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleNamedDOW(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleNamedHour(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleNamedMonth(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleNamedNumberDuration(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleNextDOW(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleNow(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.rulePOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.rulePODDate(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.rulePODInterval(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.rulePODPOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.rulePODTOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleQuarterAfterHH(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleQuarterBeforeHH(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleTODDate(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleTODPOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleTODTOD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleThisDOW(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleTimeDuration(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleToday(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleTomorrow(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleYYYYMMDD(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleYear(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]
ctparse.rule.ruleYesterday(ts: datetime.datetime, *args) → Optional[ctparse.types.Artifact]

ctparse.scorer module

This module contains the Scorer abstraction that can be used to implement scoring strategies for ctparse.

class ctparse.scorer.DummyScorer[source]

Bases: ctparse.scorer.Scorer

A scorer that always return a 0.0 score.

score(txt: str, ts: datetime.datetime, partial_parse: ctparse.partial_parse.PartialParse) → float[source]

Produce a score for a partial production.

Parameters:
  • txt – the text that is being parsed
  • ts – the reference time
  • partial_parse – the partial parse that needs to be scored
score_final(txt: str, ts: datetime.datetime, partial_parse: ctparse.partial_parse.PartialParse, prod: ctparse.types.Artifact) → float[source]

Produce the final score for a production.

Parameters:
  • txt – the text that is being parsed
  • ts – the reference time
  • partial_parse – the PartialParse object that generated the production
  • prod – the production
class ctparse.scorer.RandomScorer(rng: Optional[random.Random] = None)[source]

Bases: ctparse.scorer.Scorer

score(txt: str, ts: datetime.datetime, partial_parse: ctparse.partial_parse.PartialParse) → float[source]

Produce a score for a partial production.

Parameters:
  • txt – the text that is being parsed
  • ts – the reference time
  • partial_parse – the partial parse that needs to be scored
score_final(txt: str, ts: datetime.datetime, partial_parse: ctparse.partial_parse.PartialParse, prod: ctparse.types.Artifact) → float[source]

Produce the final score for a production.

Parameters:
  • txt – the text that is being parsed
  • ts – the reference time
  • partial_parse – the PartialParse object that generated the production
  • prod – the production
class ctparse.scorer.Scorer[source]

Bases: object

Interface for scoring parses generated by ctparse

score(txt: str, ts: datetime.datetime, partial_parse: ctparse.partial_parse.PartialParse) → float[source]

Produce a score for a partial production.

Parameters:
  • txt – the text that is being parsed
  • ts – the reference time
  • partial_parse – the partial parse that needs to be scored
score_final(txt: str, ts: datetime.datetime, partial_parse: ctparse.partial_parse.PartialParse, prod: ctparse.types.Artifact) → float[source]

Produce the final score for a production.

Parameters:
  • txt – the text that is being parsed
  • ts – the reference time
  • partial_parse – the PartialParse object that generated the production
  • prod – the production

ctparse.timers module

Utilities for tracking time spent in functions.

Although this module is not part of the public API, it is used in various parts of the ctparse package.

exception ctparse.timers.CTParseTimeoutError[source]

Bases: Exception

Exception raised by the timeout function.

ctparse.timers.timeit(f: Callable[[...], T]) → Callable[[...], Tuple[T, float]][source]

Wrapper to time a function.

The wrapped function is modified so that it returns a tuple (f(args), t) where t the time in seconds the function call took to run.

Example

def fun(x):
return x * x

result, exec_time = timeit(fun)(3)

ctparse.timers.timeout(timeout: Union[float, int]) → Callable[[], None][source]

Generate a functions that raises an exceptions if a timeout has passed.

Example

sentinel = timeout(1.0) time.sleep(0.5) sentinel() # Do nothing time.sleep(0.6) sentinel() # Raises CTParseTimeoutException

Parameters:timeout – time in seconds. If it is equal to zero, it means to never raise an exception.
Returns:A function that raises a CTParseTimeoutException if timeout seconds have expired.

ctparse.types module

class ctparse.types.Artifact[source]

Bases: object

nb_str() → str[source]

Return a string representation without the bounds information.

update_span(*args) → T[source]
class ctparse.types.Duration(value: int, unit: ctparse.types.DurationUnit)[source]

Bases: ctparse.types.Artifact

classmethod from_str(text: str) → ctparse.types.Duration[source]
class ctparse.types.DurationUnit[source]

Bases: enum.Enum

An enumeration.

DAYS = 'days'
HOURS = 'hours'
MINUTES = 'minutes'
MONTHS = 'months'
NIGHTS = 'nights'
WEEKS = 'weeks'
class ctparse.types.Interval(t_from: Optional[ctparse.types.Time] = None, t_to: Optional[ctparse.types.Time] = None)[source]

Bases: ctparse.types.Artifact

end
classmethod from_str(text: str) → ctparse.types.Interval[source]
isDateInterval
isTimeInterval
start
class ctparse.types.RegexMatch(id: int, m: regex.regex.compile)[source]

Bases: ctparse.types.Artifact

class ctparse.types.Time(year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, minute: Optional[int] = None, DOW: Optional[int] = None, POD: Optional[str] = None)[source]

Bases: ctparse.types.Artifact

dt
end
classmethod from_str(text: str) → ctparse.types.Time[source]
hasDOW

at least a day of week

hasDOY

at least a day of year

hasDate

at least a date

hasPOD

at least a part of day

hasTime

at least a time to the hour

isDOM

isDayOfMonth <=> a dd but no month

isDOW

isDayOfWeek <=> DOW is the 0=Monday index; fragile test, as the DOW could be accompanied by e.g. a full date etc.; in practice, however, the production rules do not do that.

isDOY

isDayOfYear <=> a dd.mm but not year

isDate

isDate - only a date, not time

isDateTime

a date and a time

isHour

only has an hour

isMonth
isPOD

isPartOfDay <=> morning, etc.; fragile, tests only that there is a POD and neither a full date nor a full time

isTOD

isTimeOfDay - only a time, not date

isYear

just a year

start

Module contents

ctparse - parse time expressions in strings