ruby / rails的自然语言日期解析器 [英] Natural language date parser for ruby/rails

查看:97
本文介绍了ruby / rails的自然语言日期解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道与Ruby中的 Date.js 类似的内容?可以从以下类似的东西返回日期对象的东西:从今天开始的两个星期。记住,牛奶webapp将此功能集成到他们的系统中,它非常容易使用。



我将使用Date.js库本身,但因为它在客户端它有其局限性。如果用户没有启用javascript功能将丢失。这将影响最理想的使用我们的系统通过短信(sms)的手机用户。



我很乐意使用已经在那里的解决方案将此代码移植到Ruby中有多难?我真的不太了解自然语言解释,但似乎需要一些时间。



谢谢。

解决方案

不要忘记,一切都是Ruby中的一个对象,你已经有一些非常可读的语言本身:

  2.weeks.from_now.utc 

将是等效的



然而,对于真正的自然语言,可能 chronic 可能是 ruby​​forge 更专业的图书馆。

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆