面向 Ruby 初学者的商业自然语言
我想知道您会从哪里开始使用 Ruby 进行自然语言处理。我是一名 C# 程序员,尽管我找到了这个 C# 教程: 编写你的第一个领域特定语言,我想借此机会学习Ruby 语言,实现类似以下内容:
- 对于问题 1,如果(问题 1 答案是 C、D),则值为 3.0,否则为 2.0。
- 对于问题 3,如果(问题 1 答案为 B),则值为(问题 1 值 * 0.75)。
- 对于问题 3,如果(问题 1 的答案是 B)并且(问题 2 的答案是 C),则该值为(问题 1 的值 * 0.50)。
- 对于问题 3,默认值为 3.0。
提前致谢。 :)
I would like to know where would you begin for doing natural language processing in Ruby. I am a C# programmer, and although I found this C# tutorial:
Writing Your First Domain Specific Language, I would like to take this opportunity to learn the Ruby language, implementing something similar to:
- For question 1, the value is 3.0 if (question 1 answer is C,D), else 2.0.
- For question 3, the value is (question 1 value * 0.75) if (question 1 answer is B).
- For question 3, the value is (question 1 value * 0.50) if (question 1 answer is B) and (question 2 answer is C).
- For question 3, the default value is 3.0.
Thanks in advance. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你真的想做自然语言处理(你在文中提到),我建议使用 OpenNLP 使用 JRuby。我去年就这么做了,效果很好。
对于 DSL,网络上有大量 Ruby 特定的教程,只需使用您最喜欢的搜索引擎即可找到它们。就书籍而言,我推荐 Russ Olson 的“Eloquent Ruby”和 Paola Perotta 的“Metaprogramming Ruby”。读完这两本书后,您应该了解有关编写 DSL 所需的一切,并且作为副作用也学到了很多非常好的 Ruby。
If you really want to do natural language processing (you mention it in the text), I'd advise using OpenNLP with JRuby. I did that last year and it worked out pretty well.
For DSLs, there are a ton of Ruby-specific tutorials on the web, just use your favorite search engine to find them. Book wise I'd recommend Russ Olson's "Eloquent Ruby" and Paola Perotta's "Metaprogramming Ruby". After those 2 books you should know everything you need to know about writing DSLs and have learned a lot of very good Ruby as a side-effect.
您可能想查看DSL 的实际应用 (http://www.manning.com /ghosh/),虽然它主要涵盖 Scala,但他还讨论了 Groovy、Clojure 和 Ruby 的使用,并举例说明了如何使用每种语言执行 DSL。
他还很好地讨论了您可能决定如何设计/实现 DSL。
You may want to look at DSLs in Action (http://www.manning.com/ghosh/), as, though it is mostly covering Scala, he also discusses using Groovy, Clojure and Ruby, with examples of how to do a DSL in each of these languages.
He also does a great job in talking about how you may decide to approach designing/implementing your DSL.