自然语言时间解析器 [英] Natural language time parser

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

问题描述

我正在尝试将包含(自然语言)时间的字符串解析为 hh:mm 时间对象?例如:

I'm trying to parse strings containing (natural language) times to hh:mm time objects? For example:

"ten past five"
"quarter to three"
"half past noon"
"15 past 3"
"13:35"
"ten fourteen am"

我已经研究了慢性用于Ruby和

I've looked into Chronic for Ruby and Natty for Java (as well as some other libraries) but both seem to focus on parsing dates. Strings like "ten past five" are not parsed correctly by either.

有人知道适合我需要的图书馆吗?还是我应该开始使用自己的解析器?

Does anyone know of a library which suit my needs? Or should I maybe start working on my own parser?

推荐答案

我不想延长解析时间,所以我决定使用 pyPEG (一种用于Python的解析器解释器框架),用于编写专用的时间解析器.对于感兴趣的人,第一个基本版本现在已经完成,可以很好地解析荷兰时间字符串.

I didn't feel like extending parsedatetime, so I decided to use pyPEG, a parser interpreter framework for Python, to write a dedicated time parser. For whoever's interested, the first basic version is now finished, and nicely parses Dutch time strings.

这篇关于自然语言时间解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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