我可以使用什么库来解析 Java 中的单词?
我试图发现适合许多类别的单词类型(日期、年份、时间、名称、标点符号、电子邮件等)。我正在编写自己的代码来检测这一点(并且有效),但我发现了像 ANTLR 和 JavaCC 这样的库。
我想做的是这些图书馆的任务?如果是,我应该使用什么,如果不是,我可以用什么东西吗?
有哪些建议? JavaCC、ANTRL,还有更多吗?我看到 JavaCC 生成了一些类,但有些事情我不希望它做,比如标记化。
I'm trying to discover the type of words fitting they in a lot of categories (date, year, time, names, punctuation, email, etc). I was making my own code to detect this (and worked), but I found libraries like ANTLR and JavaCC.
What I want to do is a taks for these libraries? If yes, what I should use, if not, there is something I can use for this?
What are the recomendations? JavaCC, ANTRL, there is some more? I see that JavaCC generate some classes, but there are things that I don't want it does like tokenization.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取决于您需要多强大的解析器。如果您需要非常强大的东西(例如 JavaCC 或 ANTLR),请使用它们,并且不要花费太多时间尝试制作自己的东西。
如果您需要简单的东西,那么您可以构建一个简单的字典查找解析器,只需 常规Java 中的表达式 甚至可能是 StringTokenizer (如果你的例子非常简单)。
Depends on how powerful a parser you need. If you need something very powerful (such as JavaCC or ANTLR) go with them and don't spend too much time trying to make your own.
If you need something simple, then you can build a simple dictionary lookup parser with little more than regular expressions in Java or maybe even StringTokenizer (if your example is very simplistic).