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! |
Latest version: | 0.0.2 |
SHA1 sum: | 9a041531389db2cd43e0f107ffdf401ae5086511 |
Author: | Michael Hendricks <michael@ndrix.org> |
Maintainer: | Michael Hendricks <michael@ndrix.org> |
Packager: | Michael Hendricks <michael@ndrix.org> |
Home page: | http://packs.ndrix.com/julian_lang_en/index.html |
Download URL: | http://packs.ndrix.com/julian_lang_en/julian_lang_en-0.0.2.tgz |
No reviews. Create the first review!.
Version | SHA1 | #Downloads | URL |
---|---|---|---|
0.0.1 | 5f8dd381421612c521ad42ab9542c093735d7ac8 | 1 | http://packs.ndrix.com/julian_lang_en/julian_lang_en-0.0.1.tgz |
0.0.2 | 9a041531389db2cd43e0f107ffdf401ae5086511 | 49 | http://packs.ndrix.com/julian_lang_en/julian_lang_en-0.0.2.tgz |
?- 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:
?- pack_install(julian_lang_en).
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.