ruby / rails的自然语言日期解析器 [英] Natural language date parser for ruby/rails
问题描述
我将使用Date.js库本身,但因为它在客户端它有其局限性。如果用户没有启用javascript功能将丢失。这将影响最理想的使用我们的系统通过短信(sms)的手机用户。
我很乐意使用已经在那里的解决方案将此代码移植到Ruby中有多难?我真的不太了解自然语言解释,但似乎需要一些时间。
谢谢。
不要忘记,一切都是Ruby中的一个对象,你已经有一些非常可读的语言本身:
2.weeks.from_now.utc
将是等效的
然而,对于真正的自然语言,可能 chronic 可能是 rubyforge 更专业的图书馆。
Chronic.parse('this tuesday 5:00')
#=>星期二8月29日17:00:00 PDT 2006
Does anybody know of something similar to Date.js in Ruby? Something that would be able to return a date object from something like: "two weeks from today". The Remember the Milk webapp incorporates this feature into their system and it is incredibly easy to use.
I would use the Date.js library itself but because it is on the client side it has its limitations. If the user doesn't have javascript enabled the functionality would be lost. This would affect mobile phone users who would, ideally, use our system via text message (sms).
I would love to use a solution that's already out there but if not how hard would it be to port this code into Ruby? I really don't know much about natural language interpretation but it seems like it would take some time.
Thanks.
Do not forget that everything being an object in Ruby, you have already some pretty readable statement from the language itself:
2.weeks.from_now.utc
would be the equivalent of "two weeks from today".
However, for real natural language, may be chronic might be a more specialized library at rubyforge.
Chronic.parse('this tuesday 5:00')
#=> Tue Aug 29 17:00:00 PDT 2006
这篇关于ruby / rails的自然语言日期解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!