Ok I investigated a bit further and I found some seriously weird stuff...I'm gonna need the help of a java expert here:

(pprint (.getMethods (.getClass opennlp-pos))) ;;notice that the method I'm trying to call *doesn't exist according to this*!!!!!!!!

[#<Method public static opennlp.tools.postag.POSModel opennlp.tools.postag.POSTaggerME.train(java.lang.String,opennlp.tools.util.ObjectStream,opennlp.tools.util.model.ModelType,opennlp.tools.postag.POSDictionary,opennlp.tools.dictionary.Dictionary,int,int) throws java.io.IOException>,
 #<Method public void opennlp.tools.postag.POSTaggerME.probs(double[])>,
 #<Method public double[] opennlp.tools.postag.POSTaggerME.probs()>,
 #<Method public int opennlp.tools.postag.POSTaggerME.getNumTags()>,
#<Method public java.lang.String[] opennlp.tools.postag.POSTaggerME.getOrderedTags(java.util.List,java.util.List,int)>, #<Method public java.lang.String[] opennlp.tools.postag.POSTaggerME.getOrderedTags(java.util.List,java.util.List,int,double[])>, #<Method public opennlp.tools.util.Sequence[] opennlp.tools.postag.POSTaggerME.topKSequences(java.util.List)>, #<Method public opennlp.tools.util.Sequence[] opennlp.tools.postag.POSTaggerME.topKSequences(java.lang.String[])>, *#<Method public java.lang.String[] opennlp.tools.postag.POSTaggerME.tag(java.lang.String[])>,** ** #<Method public java.lang.String opennlp.tools.postag.POSTaggerME.tag(java.lang.String)>,** ** #<Method public java.util.List opennlp.tools.postag.POSTaggerME.tag(java.util.List)>,** ** #<Method public java.lang.String[][] opennlp.tools.postag.POSTaggerME.tag(int,java.lang.String[])>,* #<Method public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException>, #<Method public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException>, #<Method public final void java.lang.Object.wait() throws java.lang.InterruptedException>,
 #<Method public boolean java.lang.Object.equals(java.lang.Object)>,
 #<Method public java.lang.String java.lang.Object.toString()>,
 #<Method public native int java.lang.Object.hashCode()>,
 #<Method public final native java.lang.Class java.lang.Object.getClass()>,
 #<Method public final native void java.lang.Object.notify()>,
 #<Method public final native void java.lang.Object.notifyAll()>]
nil

but then this seems very strange so I went and decompiled the class file (actually the entire jar) and the method that takes 2 arrays as args does exist both in the interface and the concrete implementation (POSTagger & POSTaggerME respectively)....

how on earth can that be? any ideas anyone? this seems utterly odd to me!

Jim


On 12/03/13 13:26, Jim - FooBar(); wrote:
Hi all,

I came back to a project of mine after a week or so and I'm facing a problem which I have no idea where it came from! This is the first time I'm seeing it on this project - everything worked just fine a week ago! The problem is this:

Consider some java class (opennlp-POS-tagger) with 3 .tag() overloads...signatures and bodies follow:

public *String[] tag(String[] sentence)* {
return this.tag(sentence, null); //this is essentially what I'm trying in my code
  }

  public *String[] tag(String[] sentence, Object[] additionaContext) *{
    bestSequence = beam.bestSequence(sentence, additionaContext);
    List<String> t = bestSequence.getOutcomes();
    return t.toArray(new String[t.size()]);
  }


  public *String[][] tag(int numTaggings, String[] sentence) *{
Sequence[] bestSequences = beam.bestSequences(numTaggings, sentence,null);
    String[][] tags = new String[bestSequences.length][];
    for (int si=0;si<tags.length;si++) {
      List<String> t = bestSequences[si].getOutcomes();
      tags[si] = t.toArray(new String[t.size()]);
    }


Now, from my code I'm trying to do:

(.tag opennlp-pos (into-array ["New-York" "(NY)" "is" "the" "city" "that" "never" "sleeps" "."]) nil)

which gives me a IllegalArgumentException Unexpected param type, expected: int, given: [Ljava.lang.String; clojure.lang.Reflector.boxArg (Reflector.java:432) Basically, it's trying to invoke the last overload ,whereas I'm trying to invoke the second one!!!

If I omit the 'nil' at the end , the correct method is invoked (the first which calls the second)...why can't Clojure find the second overload and goes for the 3rd?

any ideas?

Jim



--
--
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/groups/opt_out.


Reply via email to