Business Natural Language for Ruby beginners
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 lear开发者_C百科n 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. :)
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.
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.
精彩评论