lzell / nickel Goto Github PK
View Code? Open in Web Editor NEWNickel extracts date, time, and message information from naturally worded text.
License: MIT License
Nickel extracts date, time, and message information from naturally worded text.
License: MIT License
Hello,
The following date is not parsed correctly "April 29 5-8PM"
I'm having trouble finding where in the code this can be remedied. Would appreciate a patch or any tips.
Here's a test case if that helps:
def test__april_29_5_to_8_pm
now = Time.local(2008, 11, 30)
assert_nlp NLP.new("April 29, 5-8pm", now),
[Occurrence.new(
:type => :single,
:start_date => ZDate.new("20080429"),
:start_time => ZTime.new("5", :pm),
:end_time => ZTime.new("8", :pm))]
end
"tomorrow anytime" raises
NoMethodError: undefined method `firm' for nil:NilClass
I'm still seeing regex warnings like "warning: nested repeat operator + and ? was replaced with '*'" though i see there was a commit a year ago to fix some. has the gem not been updated?
Email from Mike S:
If you do not specify a day then I expected it to default to "today" but it appears to just swallow the time and return only the message.
For instance, the query "Do some stuff at 1300" returns:
<?xml version="1.0" encoding="UTF-8"?>
<naturalinputsResponse>
<message>Do some stuff</message>
</naturalinputsResponse>
But I expected something like this:
<?xml version="1.0" encoding="UTF-8"?>
<naturalinputsResponse>
<message>Do some stuff</message>
<occurrence>
<type>single</type>
<start_date>20110321</start_date>
<start_time>13:00:00</start_time>
</occurrence>
</naturalinputsResponse>
Email from Joel B:
Lunch every Monday at 12pm until January 4th
Note: both of these work (the second one gets me the extra lunch date I wanted on 1/2/2012):
This is with nickel version 0.0.5.
ruby-1.9.2-p180 :001 > require 'nickel'
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: warning: nested repeat operator + and ? was replaced with '*': /\bany(?:\s+)?day\b/
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: warning: nested repeat operator + and ? was replaced with '*': /([0-9])(?:\s+)?a\b/
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: warning: nested repeat operator + and ? was replaced with '*': /([0-9])(?:\s+)?p\b/
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: warning: nested repeat operator + and ? was replaced with '*': /this(?:\s+)?morning/
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: warning: nested repeat operator + and ? was replaced with '*': /^(?:\s+)?(?:right\s+)?now(?:\s+)?$/
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: warning: nested repeat operator + and ? was replaced with '*': /^(?:\s+)?(?:right\s+)?now(?:\s+)?$/
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: warning: nested repeat operator + and ? was replaced with '*'
=> true
Nice work on this gem, it handles everything I've thrown at it well. If I have time I'll submit a pull request.
Example 1:
@sciencemagazine is stuck in the 19th century, when it made sense to reject 95% of submissions" - @plos cofounder @mbeisen cc #wcsj2013
wrongly extracts to 19th of July 2013
SUTime is correct:
the 19th century 19XX <TIMEX3 tid="t1" value="19XX" type="DATE">the 19th century</TIMEX3>
2013 2013 <TIMEX3 tid="t2" value="2013" type="DATE">2013</TIMEX3>
Example 2:
Withings commercially launches Pulse, its first activity tracker http://t.co/bbKAf37veT
wrongly extracts to 1st of July 2013
SUTime is correct:
No temporal expressions.
Example 3:
excellent RT @nickbarnes: Gave 1st talk at SoundSoftware 2013: "10 Reasons you must publish your code". Pulled no punches. #openscience
wrongly extracts to 1st of July 2013
SUTime is correct:
2013 2013 <TIMEX3 tid="t1" value="2013" type="DATE">2013</TIMEX3>
Example 4:
Been listening to the Vampires of the Modern City album for the past few weeks, and it's absolutely fantastic. #vampireweekend
wrongly extracts to 30th of June 2013
SUTime is correct:
the past few weeks PXW <TIMEX3 tid="t1" value="PXW" type="DURATION">the past few weeks</TIMEX3>
I'll soon be in a position to provide a database of these wrong classifications, would that be helpful?
I notice that the following string parses as a start date instead of ending date: "Ending on 12/15/2014"
require "rubygems"
require "nickel.rb"
string = "Ending on 12/15/2014"
results = Nickel.parse(string, Time.now)
puts results.inspect
Results in: message: "", occurrences: [#<Occurrence type: single, start_date: 20141215>]
If you have an apostrophe in your event, it gets stripped out and makes the word it was attached to lower case. For example, I entered:
2/10 1pm Archie's Birthday Party
and the title of the event turned into:
archies Birthday Party
Example:
Nickel.parse "job search - apply at virgin intergalactic"
Returns:
message: "job search apply at virgin intergalactic", occurrences: [#<Occurrence type: daily, start_date: "20110428", interval: 1>]
I would expect without any date information, it should return an empty array for occurrences.
Additionally, Nickel.parse "-" by itself results in NoMethodError: undefined method `interpret_date' for nil:NilClass
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.