Re: Interop nightmare
Not the answer, but might have some useful clues in ... here's a snippet to make a tagger from the Stanford library: (ns processor.tagger (:require [clojure.data.xml :as xml] [clojure.string :as string]) (:import (edu.stanford.nlp.tagger.maxent TaggerConfig MaxentTagger))) ;; Configuration information for the Stanford POS tagger (def conf (TaggerConfig. (into-array [-model resources/models/english-caseless-left3words-distsim.tagger -outputFormat xml -outputFormatOptions lemmatize]))) (def tagger (MaxentTagger. resources/models/english-caseless-left3words-distsim.tagger conf)) Jony -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
Hey Sam. I too had great difficulty with clojure interop until I became more familiar with Java. I find that it is quite difficult to use clojure unless one knows Java, which I believe to be a barrier to new comers. So I suggest that you learn some Java and start trying to hack simple interop programs to get the hang of it. On Sunday, September 7, 2014 10:50:31 PM UTC-4, Sam Raker wrote: I'm trying to use the Stanford Parser from Clojure, but I don't know hardly any Java, and this is my first time working with the interop stuff. All I want to do is play around with the class in the REPL. I added `[edu.stanford.nlp/stanford-parser 3.4.1]` to my Lein `project.clj`, and the download seemed to go fine. The documentation is http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/LexicalizedParser.html for those of you playing at home. Basically, my efforts have been a total failure. I can `(import edu.stanford.nlp.parser.lexparser.LexicalizedParser)`, but after that, it's just a nightmare of `no matching ctor`, `no matching field`, `NoSuchFieldException` and `expected static field` errors. I can't even initialize anything -- `(def parser (new LexicalizedParser))` gives me the aforementioned `no matching ctor` error. Like I said before, this is entirely my fault: I don't know Java, I don't know interop, and I Google has failed me. So I turn to you, beloved Clojure community, to correct my ignorance. I'm sure it's not hard, I'm just missing something. Thanks, -sam -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
This worked for me: http://viewer.gorilla-repl.org/view.html?source=gistid=5baef8ac0f42706e4940filename=parser.clj I had to download the parser distribution from the Stanford NLP site and copy the stanford-parser-3.4.1-models.jar file into the root of my Leiningen project, as I couldn't find it on maven. Hope that helps, Jony -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
On Sep 8, 2014, at 10:08 AM, Jacob Goodson submissionfight...@gmx.com wrote: Hey Sam. I too had great difficulty with clojure interop until I became more familiar with Java. Yeah, the interop can be painful, especially with the way some Java libraries are designed - and you can end up with some pretty ugly Clojure when dealing with those libraries (still a lot nicer than the Java you'd have to write!). I find that it is quite difficult to use clojure unless one knows Java, which I believe to be a barrier to new comers. I'm surprised every time I hear this. You can write a lot of Clojure without having to do any interop so you can mostly ignore Java altogether unless you specifically want to work with a Java library. Yes, the stacktraces bleed Java but after the initial OMG! shock, they're generally easy to read - they're just LONG and you have to ignore a lot of the irrelevant parts. Leiningen mostly hides the ugly Java ecosystem as regards library management so, again, you can mostly ignore Java there too. Certainly if you're new to Clojure and don't know Java, you want to avoid doing things that require you to interop with Java libraries until you're more comfortable with Clojure itself. So I suggest that you learn some Java and start trying to hack simple interop programs to get the hang of it. Good advice. Practicing with interop on the Java String class or something else that's relatively simple is a nice way to ease into it. Having had to work with Java's JDBC classes, javax.mail, and Java's SOAP implementation - all from Clojure - all I can say is that some Java interop is easier than others, but most of it is somewhat unpleasant :) Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) signature.asc Description: Message signed with OpenPGP using GPGMail
Re: Interop nightmare
On Monday, September 8, 2014 11:09:50 AM UTC-7, Sean Corfield wrote: I find that it is quite difficult to use clojure unless one knows Java, which I believe to be a barrier to new comers. I'm surprised every time I hear this. You can write a lot of Clojure without having to do any interop so you can mostly ignore Java altogether unless you specifically want to work with a Java library. Yes, the stacktraces bleed Java but after the initial OMG! shock, they're generally easy to read - they're just LONG and you have to ignore a lot of the irrelevant parts. Leiningen mostly hides the ugly Java ecosystem as regards library management so, again, you can mostly ignore Java there too. Coming to clojure with no java experience is pretty brutal, in my experience. You absolutely can't ignore the Java, because of the embrace-the-platform architecture. I suspect this difficulty is surprising to java developers because it's so easy to forget how much one has learned. An error message like no matching ctor is very confusing without Java experience. It takes only a few minutes on google to sort this out, but there are at least hundreds of details like this that bleed through from Java. It adds up quickly. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
For an enterprising clojure hacker, this is a good opportunity to write Clojure for non-Java Hackers and put it up on Pragprog. On Sunday, September 7, 2014 10:50:31 PM UTC-4, Sam Raker wrote: I'm trying to use the Stanford Parser from Clojure, but I don't know hardly any Java, and this is my first time working with the interop stuff. All I want to do is play around with the class in the REPL. I added `[edu.stanford.nlp/stanford-parser 3.4.1]` to my Lein `project.clj`, and the download seemed to go fine. The documentation is http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/LexicalizedParser.html for those of you playing at home. Basically, my efforts have been a total failure. I can `(import edu.stanford.nlp.parser.lexparser.LexicalizedParser)`, but after that, it's just a nightmare of `no matching ctor`, `no matching field`, `NoSuchFieldException` and `expected static field` errors. I can't even initialize anything -- `(def parser (new LexicalizedParser))` gives me the aforementioned `no matching ctor` error. Like I said before, this is entirely my fault: I don't know Java, I don't know interop, and I Google has failed me. So I turn to you, beloved Clojure community, to correct my ignorance. I'm sure it's not hard, I'm just missing something. Thanks, -sam -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
On 9 September 2014 at 00:33:11, Ivan L (ivan.laza...@gmail.com) wrote: For an enterprising clojure hacker, this is a good opportunity to write Clojure for non-Java Hackers and put it up on Pragprog. Sounds more like Just enough Java for Clojure. Which I think would have too small an audience to be worth the effort. -- @michaelklishin, github.com/michaelklishin -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
Thanks for all the help! I knew I could count on you guys. I saw that there were a bunch of params in the constructor, but naively hoped there'd be some kind of default values for them so I didn't have to muck around with anything too much. Disappointed once again. I'll look into exactly what else I have to move around/import/instantiate before I can get the parser to just work. As for the comments about Clojure being difficult to use w/o knowing Java, aside from this unfortunate experience, I've found it pretty easy/not an issue. The automatic upgrading of integers to the appropriate underlying Java (/JVM) types, and the wrappers around Java's regex stuff are two good examples. I'd imagine it'd be much more difficult coming in cold, although TJOC and the other intro to Clojure book I read at least covered numerics and over/underflow pretty thoroughly. The other stuff (typed arrays, e.g.) keep out of your way unless you actively seek them out, so it's not a big deal either. That being said, while Just enough Java for Clojure, as Ivan and Michael discussed, might not be big enough on its own for a book/article, I, for one, would appreciate more on interop than I've seen, which tends to be along the lines of use ClassName/staticThing for static things, use . for everything else, also .. and doto exist. On Monday, September 8, 2014 4:49:12 PM UTC-4, Michael Klishin wrote: On 9 September 2014 at 00:33:11, Ivan L (ivan.l...@gmail.com javascript:) wrote: For an enterprising clojure hacker, this is a good opportunity to write Clojure for non-Java Hackers and put it up on Pragprog. Sounds more like Just enough Java for Clojure. Which I think would have too small an audience to be worth the effort. -- @michaelklishin, github.com/michaelklishin -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
On Sep 8, 2014, at 4:48 PM, Michael Klishin michael.s.klis...@gmail.com wrote: Sounds more like Just enough Java for Clojure. Which I think would have too small an audience to be worth the effort. I'd buy it for sure. I bet that some of my students would too. -Lee -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
On Tue, Sep 9, 2014 at 3:09 AM, Sean Corfield s...@corfield.org wrote: I find that it is quite difficult to use clojure unless one knows Java, which I believe to be a barrier to new comers. I'm surprised every time I hear this. You can write a lot of Clojure without having to do any interop so you can mostly ignore Java altogether unless you specifically want to work with a Java library. I don't think any of my Clojure books mention how to convert a string to a numeric, which is missing in Clojure and hence requires Java interop. That's just one example of a fairly basic thing that would be a barrier to new comers. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
On Sep 8, 2014, at 9:09 PM, Alan Busby thebu...@gmail.com wrote: On Tue, Sep 9, 2014 at 3:09 AM, Sean Corfield s...@corfield.org wrote: I find that it is quite difficult to use clojure unless one knows Java, which I believe to be a barrier to new comers. I'm surprised every time I hear this. You can write a lot of Clojure without having to do any interop so you can mostly ignore Java altogether unless you specifically want to work with a Java library. I don't think any of my Clojure books mention how to convert a string to a numeric, which is missing in Clojure and hence requires Java interop. That's just one example of a fairly basic thing that would be a barrier to new comers. Do you mean this?: = (read-string 1.23) 1.23 I manage to get by with very little Java interop, but I'd love to have more guidance for doing it when I need it. -Lee -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Interop nightmare
I'm trying to use the Stanford Parser from Clojure, but I don't know hardly any Java, and this is my first time working with the interop stuff. All I want to do is play around with the class in the REPL. I added `[edu.stanford.nlp/stanford-parser 3.4.1]` to my Lein `project.clj`, and the download seemed to go fine. The documentation is http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/LexicalizedParser.html for those of you playing at home. Basically, my efforts have been a total failure. I can `(import edu.stanford.nlp.parser.lexparser.LexicalizedParser)`, but after that, it's just a nightmare of `no matching ctor`, `no matching field`, `NoSuchFieldException` and `expected static field` errors. I can't even initialize anything -- `(def parser (new LexicalizedParser))` gives me the aforementioned `no matching ctor` error. Like I said before, this is entirely my fault: I don't know Java, I don't know interop, and I Google has failed me. So I turn to you, beloved Clojure community, to correct my ignorance. I'm sure it's not hard, I'm just missing something. Thanks, -sam -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
I'm not familiar with the stanford parser, or nlp, but the `no matching ctor error` is easily explained: According to the doc http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/LexicalizedParser.html#LexicalizedParser(edu.stanford.nlp.parser.lexparser.Lexicon, edu.stanford.nlp.parser.lexparser.BinaryGrammar, edu.stanford.nlp.parser.lexparser.UnaryGrammar, edu.stanford.nlp.parser.lexparser.DependencyGrammar, edu.stanford.nlp.util.Index, edu.stanford.nlp.util.Index, edu.stanford.nlp.util.Index, edu.stanford.nlp.parser.lexparser.Options), the only Constructor to LexicalizedParser takes 8 arguments, whose types I won't bother to repeat. Assuming you are familiar with the first half of http://clojure.org/java_interop , I recommend that you find a usage example of Stanford Parser and translate it to clojure sytax. That way you only have to bother with one unknown at a time and it will be easier to answer questions. kind regards 2014-09-08 4:50 GMT+02:00 Sam Raker sam.ra...@gmail.com: I'm trying to use the Stanford Parser from Clojure, but I don't know hardly any Java, and this is my first time working with the interop stuff. All I want to do is play around with the class in the REPL. I added `[edu.stanford.nlp/stanford-parser 3.4.1]` to my Lein `project.clj`, and the download seemed to go fine. The documentation is http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/LexicalizedParser.html for those of you playing at home. Basically, my efforts have been a total failure. I can `(import edu.stanford.nlp.parser.lexparser.LexicalizedParser)`, but after that, it's just a nightmare of `no matching ctor`, `no matching field`, `NoSuchFieldException` and `expected static field` errors. I can't even initialize anything -- `(def parser (new LexicalizedParser))` gives me the aforementioned `no matching ctor` error. Like I said before, this is entirely my fault: I don't know Java, I don't know interop, and I Google has failed me. So I turn to you, beloved Clojure community, to correct my ignorance. I'm sure it's not hard, I'm just missing something. Thanks, -sam -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Interop nightmare
On 8 September 2014 at 06:50:38, Sam Raker (sam.ra...@gmail.com) wrote: I can `(import edu.stanford.nlp.parser.lexparser.LexicalizedParser)`, but after that, it's just a nightmare of `no matching ctor`, `no matching field`, `NoSuchFieldException` and `expected static field` errors. I can't even initialize anything -- `(def parser (new LexicalizedParser))` gives me the aforementioned `no matching ctor` error. The only constructor on that class has way more than 0 arguments: http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/LexicalizedParser.html#LexicalizedParser(edu.stanford.nlp.parser.lexparser.Lexicon, edu.stanford.nlp.parser.lexparser.BinaryGrammar, edu.stanford.nlp.parser.lexparser.UnaryGrammar, edu.stanford.nlp.parser.lexparser.DependencyGrammar, edu.stanford.nlp.util.Index, edu.stanford.nlp.util.Index, edu.stanford.nlp.util.Index, edu.stanford.nlp.parser.lexparser.Options) Perhaps you should use a factory method to instantiate it: http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/LexicalizedParser.html#loadModel() See http://clojure-doc.org/articles/language/interop.html, too. -- @michaelklishin, github.com/michaelklishin -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.