Skip to content

Instantly share code, notes, and snippets.

@louismullie
Created February 6, 2012 00:41
Show Gist options
  • Save louismullie/1748600 to your computer and use it in GitHub Desktop.
Save louismullie/1748600 to your computer and use it in GitHub Desktop.
Treat - Date and Time Extraction With Graph Colorization
require 'date'
Treat.sweeten!
s = Section "2011/12/23 \n - Obama and Sarkozy met on January 1st to investigate the possibility of a new rescue plan. President Sarkozy is to meet Merkel next Tuesday in Berlin."
s.do(
:chunk, :segment, :parse, :time, :date,
:visualize => [
:dot, {
:file => 'test-date-time-extraction.dot',
:colors => {
:red => lambda do |entity|
entity.has?(:time) and
entity.time.start < DateTime.now
end,
:blue => lambda do |entity|
entity.has?(:time) and
entity.time.start > DateTime.now
end,
:green => lambda { |x| x.has?(:date) }
}
}
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment