True but a bit daunting to get started. 

Here is a translation to Scala. 
https://gist.github.com/pferrel/9cfee8b5723bb2e2a22c

It uses the MahoutDriver and IndexedDataset and is compiled from 
org.apache.mahout.examples, which I created and so you’ll need to add the right 
imports if you do it somewhere else. For a bonus it uses Spark's parallel 
writing to part files and you can add command line parsing quite easily.

article_views.txt:
pat,article1
pat,article2
pat,article3
frank,article3
frank,article4
joe-bob,article10
joe-bob,article11

indicators/part-00000
article2        article1:3.819085009768877 article3:1.046496287529096
article3        article2:1.046496287529096 article4:1.046496287529096 
article1:1.046496287529096
article11       article10:3.819085009768877
article4        article3:1.046496287529096
article10       article11:3.819085009768877
article1        article2:3.819085009768877 article3:1.046496287529096

The search using frank’s history will return article2, article3(filter out), 
article4(filter out), and article 1 as you’d expect. 

Oh, and I was wrong about the bug—works from the current repo.

You still need to get the right jars in the classpath when running from the 
command line

On Sep 12, 2014, at 9:04 AM, Peter Wolf <[email protected]> wrote:

I'm new here, but I just wanted to add that Scala is extremely cool.  I've
moved to Scala wherever possible in my work.  It's really nice, and well
worth effort to learn.  Scala has put the joy back into programming.

Instead of trying to call Scala from Java, perhaps you might enjoy writing
your stuff in Scala.

On Fri, Sep 12, 2014 at 11:53 AM, Pat Ferrel <[email protected]> wrote:

> #1 I’m glad to see someone using this. I haven’t tried calling Scala from
> Java and would expect a fair amount of difficulty with it. Scala constructs
> objects to deal with its new features (anonymous functions, traits,
> implicits) and you have to guess at what those will look like to java.
> Maybe you could try the Scala community.
> 
> Intellij will auto convert java to scala when you paste it into a .scala
> file. For some reason yours doesn’t seem to work but I’ve seen it work
> pretty well.
> 
> I started to convert your code and it pointed out a bug in mine, a bad
> value in the default schema. I’d be interested in helping with this as a
> way to work out the kinks in creating drivers.
> 
> Are you interested in this or are you set on using java? Either way I’ll
> post a gist of your code using the MahoutDriver as the template and
> converted to Scala. It’ll take me a few minutes.
> 
> On Sep 12, 2014, at 6:46 AM, Frank Scholten <[email protected]>
> wrote:
> 
> Hi all,
> 
> Trying out the new spark-itemsimilarity code, but I am new to Scala and
> have hard time calling certain methods from Java.
> 
> Here is a Gist with a Java main that runs the cooccurrence analysis:
> 
> https://gist.github.com/frankscholten/d373c575ad721dd0204e
> 
> When I run this I get an exception:
> 
> Exception in thread "main" java.lang.NoSuchMethodError:
> 
> org.apache.mahout.drivers.TextDelimitedIndexedDatasetReader.readElementsFrom(Ljava/lang/String;Lcom/google/common/collect/BiMap;)Lorg/apache/mahout/drivers/IndexedDataset;
> 
> What do I have to do here to use the Scala readers from Java?
> 
> Cheers,
> 
> Frank
> 
> 

Reply via email to