Didier, thanks for the reply!

   1. I created a wrapper function like this:  (defn -score [data context] 
   (score data context))
   2. I tried your suggestion but got an error.  Here's the current state:

The JS calling code:

function genFixture () {
  return new Array(12).fill(parseFloat(Math.random().toFixed(2)));
}

console.log("Generating fixtures...");
var data = genFixture();
var contex = new Array(10).fill(1);
context.forEach((d,i) => { context[i] = genFixture(); });

// This produces, for example, the following fixtures:
// data: [ 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 0.89, 
0.89, 0.89 ]
// context: [
//   [ 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 0.35, 
0.35 ],
//   [ 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 
0.85 ],
//   ...
//   [ 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 0.31, 
0.31 ]]

const java = require('java');
java.classpath.push("./java/alto.score-0.2.0-standalone.jar");
console.log("Importing class ...");
var score = java.import('alto.score');

console.log("Attempting to run score.scoreSync(data, context)");
try {
  var s = score.scoreSync(data, context);
} catch (e) {
  console.log("Got an error:", e);
}


The resulting output looks like this:

Generating fixtures...
Importing class ...
Attempting to run score.scoreSync(data, context)
Got an error: Error: Could not find method "score([Ljava.lang.Double;, 
[Ljava.lang.Object;)" on class "class alto.score". Possible matches:
  public static java.util.List 
alto.score.score(java.util.List,java.util.List)


An error like this was how I came up with the original signature (that 
didn't work).

In reading more of the node-java docs, I saw an example that reads:

var list1 = 
java.newInstanceSync("java.util.ArrayList");console.log(list1.sizeSync()); // 
0list1.addSync('item1');console.log(list1.sizeSync()); // 1

Which leads me to the idea that I may need to create the java.lang.List 
object you recommended in the JS side, populate it, then pass that as the 
argument into the scoring function.  I'm working on that now, but don't 
have anything to report yet.

Thanks again,

-Sir





On Sunday, August 6, 2017 at 4:49:25 PM UTC-4, Didier wrote:
>
> Can you try:
>
> :methods [#^{:static true} [score [java.util.List java.util.List] 
> java.util.List]]
>
> This says your score function takes two List arguments and returns a list.
>
>

-- 
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.

Reply via email to