Thanks again Marc, I made a note of it on the StackOverflow thread. On Jan 25, 2:41 pm, Marc Downie <m...@openendedgroup.com> wrote: > On Mon, Jan 25, 2010 at 5:34 PM, rob <r.p.l...@gmail.com> wrote: > > Thank you for these good ideas! I'm going to try it. My goal is to > > use the Natural Language Toolkit in Clojure. I also posted the same > > question here: > >http://stackoverflow.com/questions/2129253/clojure-jython-interop > > Since NLTK is variously just bunch functions, or classes without any java > interface counterpart (because it's a pure Python library, it doesn't know > anything about Java), I'm afraid you really are looking at the kind of > things that I wrote in my first email. (The leading answer on stackoverflow > seems technically correct, but misses the Py.java2py and .__tojava__ > convenience calls, and has a go at to recoding part of them in Clojure). > > have fun (and do let me know when you come up with something tighter than > what I wrote). > > best, > > Marc. > > > > > Rob > > > On Jan 24, 7:08 pm, Eric Lavigne <lavigne.e...@gmail.com> wrote: > > > > I was wondering if anyone has tried somehow calling Jython functions > > > > from within Clojure, and how you went about doing this if so. I have > > > > not used Jython, but I would imagine the Jython interpreter can be > > > > invoked in the same way as any other java code, and Python programs > > > > can be run within it. However I wonder if it would be possible to > > > > somehow call individual python functions from Clojure. Like I said, I > > > > have not tried this yet, so it might actually be straightforward and > > > > obvious. I'm just wondering if anyone has tried doing this. > > > > I haven't tried it, but the strategies for executing Jython code from > > > Java should work at least as well from Clojure. There are two > > > approaches. > > > > One approach is to compile the Jython code into a class file. This > > > requires some work on the Python side (similar to using gen-class in > > > Clojure so that Clojure code can be called from Java), and the Python > > > class of interest can't use multiple-inheritance. This approach is > > > discussed in the section called "How to create Jython classes callable > > > from Java programs" athttp://www.seanet.com/~bugbee/python/jython4.html > > > > Another approach is to invoke the Jython interpreter as you suggested, > > > load a Python script, and ask the interpreter to evaluate a function > > > for you. An example can be found in this page: > >http://bytes.com/topic/python/answers/22390-executing-jython-function... > > > > Additional discussion about the second approach can be found in the > > > section called "How to run Python programs from Java" athttp:// > >www.seanet.com/~bugbee/python/jython4.html > > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > >http://groups.google.com/group/clojure?hl=en
-- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en