Chronic Class Reference

Collaboration diagram for Chronic:

Collaboration graph
[legend]

List of all members.

Static Public Member Functions

static Span parse (String text, Options options)
static Span parse (String text)

Static Public Attributes

static final String VERSION = "0.3.0"

Static Protected Member Functions

static List< TokenbaseTokenize (String text)
static Span guess (Span span)
static String numericizeNumbers (String text)
static String numericizeOrdinals (String text)
static String preNormalize (String text)

Private Member Functions

 Chronic ()


Constructor & Destructor Documentation

Chronic (  )  [private]


Member Function Documentation

static List<Token> baseTokenize ( String  text  )  [static, protected]

Split the text on spaces and convert each word into a Token

static Span guess ( Span  span  )  [static, protected]

Guess a specific time within the given span

static String numericizeNumbers ( String  text  )  [static, protected]

Convert number words to numbers (three => 3)

static String numericizeOrdinals ( String  text  )  [static, protected]

Convert ordinal words to numeric ordinals (third => 3rd)

static Span parse ( String  text,
Options  options 
) [static]

Parses a string containing a natural language date or time. If the parser can find a date or time, either a Time or Chronic.Span will be returned (depending on the value of :guess). If no date or time can be found, +nil+ will be returned.

Options are:

[:context] :past or :future (defaults to :future)

If your string represents a birthday, you can set :context to :past and if an ambiguous string is given, it will assume it is in the past. Specify :future or omit to set a future context.

[:now] Time (defaults to Time.now)

By setting :now to a Time, all computations will be based off of that time instead of Time.now. If set to null, Chronic will use Time.now.

[:guess] +true+ or +false+ (defaults to +true+)

By default, the parser will guess a single point in time for the given date or time. If you'd rather have the entire time span returned, set :guess to +false+ and a Chronic.Span will be returned.

[:ambiguous_time_range] Integer or :none (defaults to 6 (6am-6pm))

If an Integer is given, ambiguous times (like 5:00) will be assumed to be within the range of that time in the AM to that time in the PM. For example, if you set it to 7, then the parser will look for the time between 7am and 7pm. In the case of 5:00, it would assume that means 5:00pm. If :none is given, no assumption will be made, and the first matching instance of that time will be used.

static Span parse ( String  text  )  [static]

static String preNormalize ( String  text  )  [static, protected]

Clean up the specified input text by stripping unwanted characters, converting idioms to their canonical form, converting number words to numbers (three => 3), and converting ordinal words to numeric ordinals (third => 3rd)


Member Data Documentation

final String VERSION = "0.3.0" [static]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:42:46 2012 for Project Wonder by  doxygen 1.5.8