|Did you know ...||Search Documentation:|
|Packs (add-ons) for SWI-Prolog|
|Title:||Parse English language phrases into library(julian) constraints|
|Rating:||Not rated. Create the first rating!|
|Author:||Michael Hendricks <email@example.com>|
|Maintainer:||Michael Hendricks <firstname.lastname@example.org>|
|Packager:||Michael Hendricks <email@example.com>|
No reviews. Create the first review!.
?- use_module(library(julian)). ?- use_module(library(julian/lang/en)). % parse English into Julian constraints ?- phrase(english_form(Form), "Tuesday in April"). Form = [month(april), dow(tuesday)]. % iterate dates matching an English description ?- form_time(english("weekday in August 2013"), Dt), form_time(Y-M-D, Dt), date(T). Y = 2013, M = 8, D = 1 ; Y = 2013, M = 8, D = 2 ; Y = 2013, M = 8, D = 5 ; Y = 2013, M = 8, D = 6 ; ...
This module allows one to parse English language descriptions of date and time constraints. For example, the phrase "monday or tuesday" describes any date which falls on a Monday or Tuesday in some week. As a
library(julian) constraint that's
dow([monday,tuesday]). This module converts between the two representations.
The following phrases are supported.
$phrase represents any other phrase the module supports (in other words, a recursive application of the parsing rules).
Rules can be combined to support fairly complex date constraints. For example, "first Monday of April in even years" correctly recognizes April 7, 2014 and April 4, 2016 with no matching date in 2015.
The rules for "second Wednesday" and "final Thursday", etc. can be a somewhat fragile. They work great for recognizing whether a given date matches the pattern, but sometimes loop forever when trying to iterate all matching days. This is considered a mistake and should be fixed.
Using SWI-Prolog 6.3 or later:
This module uses semantic versioning.
Source code available and pull requests accepted at http://github.com/mndrix/julian_lang_en
Pack contains 4 files holding a total of 9.2K bytes.