Kimtaro / ve

A linguistic framework that's easy to use.
MIT License
216 stars 25 forks source link

How can I convert a Ruby array of Ve::Word objects into JSON? #24

Closed fasiha closed 9 years ago

fasiha commented 9 years ago

Ruby nub question: how can I convert, e.g., words in words = Ve.in(:en).words('I like melons.') to JSON?

(I need to parse thousands of sentences and I'm hoping using the native Ruby front-end will be faster than going through JavaScript and hitting Sinatra thousands of times. I'm hoping I can just cat file | ruby ve.ruby > results.txt and have each line of results.txt be a complete JSON object.)

fasiha commented 9 years ago

The answer was in sinatra/server.rb: JSON.generate(words.collect { |w| w.as_json(true) }).

Kimtaro commented 9 years ago

:+1: