Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "julian_lang_en"

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

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.0.15f8dd381421612c521ad42ab9542c093735d7ac81http://packs.ndrix.com/julian_lang_en/julian_lang_en-0.0.1.tgz
0.0.29a041531389db2cd43e0f107ffdf401ae508651149http://packs.ndrix.com/julian_lang_en/julian_lang_en-0.0.2.tgz

Synopsis

?- 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 ;
...

Description

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).

  • "each day" - matches all dates
  • "weekday" - matches Monday through Friday, inclusive
  • "Monday" - matches that day of the week (case insensitive)
  • "January" - matches days in that month (case insensitive)
  • "June 2014" - matches days in that month and year
  • "May 3rd" - matches a specific day without reference to year
  • "first Tuesday" - matches an ordinal day within its month
  • "final Thursday" - matches the final named day within its month
  • "even years" - years evenly divisible by 2
  • "odd years" - years not evenly divisible by 2
  • "$phrase and $phrase" - list of day names or month names (supports "or" and "," too)
  • "$phrase in $phrase" - apply both constraints (supports "of" and "during" too)

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.

Caution

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.

Changes in this Version

  • Fix a packaging error

Installation

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

author
- Michael Hendricks <michael@ndrix.org>
license
- BSD

Contents of pack "julian_lang_en"

Pack contains 4 files holding a total of 9.2K bytes.