You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by ka...@apache.org on 2008/08/14 21:17:45 UTC

svn commit: r685998 [1/3] - in /lucene/mahout/trunk: ./ core/ core/src/main/examples/ examples/ examples/src/ examples/src/main/ examples/src/main/java/ examples/src/main/java/org/ examples/src/main/java/org/apache/ examples/src/main/java/org/apache/ma...

Author: kalle
Date: Thu Aug 14 12:17:43 2008
New Revision: 685998

URL: http://svn.apache.org/viewvc?rev=685998&view=rev
Log:
MAHOUT-72
Separate out Examples from Core

Added:
    lucene/mahout/trunk/build.xml
    lucene/mahout/trunk/examples/
    lucene/mahout/trunk/examples/build.properties
    lucene/mahout/trunk/examples/build.xml
    lucene/mahout/trunk/examples/pom.xml
    lucene/mahout/trunk/examples/src/
    lucene/mahout/trunk/examples/src/main/
    lucene/mahout/trunk/examples/src/main/java/
    lucene/mahout/trunk/examples/src/main/java/org/
    lucene/mahout/trunk/examples/src/main/java/org/apache/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBHome.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocalHome.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/ejb-jar.xml
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/mapping.xml
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/webservices.xml
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderBuilder.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderEvaluatorRunner.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/Movie.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputDriver.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/Job.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputDriver.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputMapper.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/kmeans/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/kmeans/Job.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/kmeans/OutputDriver.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/kmeans/OutputMapper.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/InputDriver.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/InputMapper.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/Job.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/OutputDriver.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/meanshift/OutputMapper.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDCrossover.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDFactory.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDFitness.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDFitnessEvaluator.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDGA.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDMutation.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDRule.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataLine.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/DataSet.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/Rule.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMahoutEvaluator.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDReducer.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/BruteForceTravellingSalesman.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/DistanceLookup.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/EuropeanDistanceLookup.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/EvolutionaryTravellingSalesman.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/ExecutionPanel.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/ItineraryPanel.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/ProgressListener.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/RouteEvaluator.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/StrategyPanel.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/TravellingSalesman.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/TravellingSalesmanStrategy.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/package-info.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/travellingsalesman/readme.txt
    lucene/mahout/trunk/examples/src/main/resources/
Removed:
    lucene/mahout/trunk/core/src/main/examples/
Modified:
    lucene/mahout/trunk/core/build.xml
    lucene/mahout/trunk/core/pom.xml
    lucene/mahout/trunk/pom.xml

Added: lucene/mahout/trunk/build.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/build.xml?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/build.xml (added)
+++ lucene/mahout/trunk/build.xml Thu Aug 14 12:17:43 2008
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="mahout" default="dist" basedir=".">
+
+  <target name="dist">
+    <ant dir="core" antfile="build.xml" target="dist-jar"/>
+    <ant dir="examples" antfile="build.xml" target="dist-jar"/>
+  </target>
+
+</project>
+
+  
\ No newline at end of file

Modified: lucene/mahout/trunk/core/build.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/build.xml?rev=685998&r1=685997&r2=685998&view=diff
==============================================================================
--- lucene/mahout/trunk/core/build.xml (original)
+++ lucene/mahout/trunk/core/build.xml Thu Aug 14 12:17:43 2008
@@ -17,7 +17,7 @@
     limitations under the License.
  -->
 
-<project name="mahout" default="dist-jar" basedir=".">
+<project name="mahout-core" default="dist-jar" basedir=".">
   <property file="build.properties" />
   <property name="Name" value="Mahout" />
 
@@ -282,7 +282,7 @@
   </target>
 
 
-  <target name="compile-examples-test" depends="compile-examples, compile-test">
+  <target name="compile-examples-test" depends="compile-test">
     <mahout-javac
       destdir="${dest}/examples-test-classes/" classpathref="examples-test.classpath">
       <src path="${src}/test/examples"/>
@@ -451,71 +451,4 @@
      </manifest>
   </target>
 
-  <!-- EXAMPLES -->
-
-  <target name="compile-examples"
-          description="Compile the examples source code."
-          depends="compile"
-          >
-    <mahout-javac destdir="${dest}/examples"
-                  classpathref="examples.classpath">
-      <!--src path="${src}/main/examples/bayes"/-->
-      <!-- Add other example sources here -->
-      <src path="${src}/main/examples"/>
-    </mahout-javac>
-  </target>
-
-  <path id="examples.classpath">
-    <path refid="compile.classpath"/>
-    <pathelement location="${dest}/classes"/>
-  </path>
-  <path id="examples.run.classpath">
-    <path refid="examples.classpath"/>
-    <pathelement location="${dest}/examples"/>
-  </path>
-
-  <property name="working.dir" value="work"/>
-  <target name="check-files">
-    <available file="temp/20news-18828.tar.gz" property="20news-18828.exists"/>
-    <available file="${working.dir}/20news-18828" property="20news-18828.expanded"/>
-
-  </target>
-
-  <target name="get-20news-18828" unless="20news-18828.exists">
-    <get src="http://people.csail.mit.edu/jrennie/20Newsgroups/20news-18828.tar.gz"
-         dest="temp/20news-18828.tar.gz"/>
-
-  </target>
-  <target name="expand-20news-18828" unless="20news-18828.expanded">
-    <gunzip src="temp/20news-18828.tar.gz" dest="temp"/>
-    <untar src="temp/20news-18828.tar" dest="${working.dir}"/>
-  </target>
-
-  <target name="extract-20news-18828" depends="check-files, compile-examples" unless="reuters.extracted">
-    <mkdir dir="${working.dir}/20news-18828-collapse"/>
-    <java classname="org.apache.mahout.classifiers.bayes.ExtractTwentyNewsgroups" maxmemory="1024M" fork="true">
-      <classpath refid="examples.run.classpath"/>
-      <!--
-      Input format is:
-      inputDir outputDir label Analyzer character set
-      -->
-      <arg line="-p ${working.dir}/20news-18828/ -o ${working.dir}/20news-18828-collapse -a org.apache.lucene.analysis.standard.StandardAnalyzer -c UTF-8"/>
-    </java>
-  </target>
-
-  <target name="get-files" depends="check-files">
-    <mkdir dir="temp"/>
-    <antcall target="get-20news-18828"/>
-    <antcall target="expand-20news-18828"/>
-    <!--<antcall target="extract-20news-18828"/>-->
-  </target>
-  <target name="examples-job" depends="compile,compile-examples" description="Build example Job jar">
-    <jar jarfile="${dest}/${fullnamever}-ex.jar">
-      <zipfileset dir="${dest}/classes"/>
-      <zipfileset dir="${dest}/examples"/>
-      <zipfileset dir="${lib}" prefix="lib"
-                  includes="**/*.jar" excludes="hadoop-*.jar"/>
-    </jar>
-  </target>
-
 </project>

Modified: lucene/mahout/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/pom.xml?rev=685998&r1=685997&r2=685998&view=diff
==============================================================================
--- lucene/mahout/trunk/core/pom.xml (original)
+++ lucene/mahout/trunk/core/pom.xml Thu Aug 14 12:17:43 2008
@@ -12,7 +12,7 @@
 
   <groupId>org.apache.lucene.mahout</groupId>
   <artifactId>core</artifactId>
-  <version>0.1-SNAPSHOT</version>
+  <version>${parent.version}</version>
   <name>Mahout core</name>
   <description>Scalable machine learning libraries</description>
 

Added: lucene/mahout/trunk/examples/build.properties
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/build.properties?rev=685998&view=auto
==============================================================================
    (empty)

Added: lucene/mahout/trunk/examples/build.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/build.xml?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/build.xml (added)
+++ lucene/mahout/trunk/examples/build.xml Thu Aug 14 12:17:43 2008
@@ -0,0 +1,462 @@
+<?xml version="1.0"?>
+
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ -->
+
+<project name="mahout-examples" default="dist-jar" basedir=".">
+  <property file="build.properties" />
+  <property name="Name" value="Examples" />
+
+  <tstamp>
+    <format property="year" pattern="yyyy"/>
+    <format property="DSTAMP" pattern="yyyy-MM-dd"/>
+    <format property="TSTAMP" pattern="HH:mm:ss"/>
+    <!-- datetime format that is safe to treat as part of a dotted version -->
+    <format property="dateversion" pattern="yyyy.MM.dd.HH.mm.ss" />
+  </tstamp>
+
+  <!-- Java Version we are compatible with -->
+  <property name="java.compat.version" value="1.5" />
+
+  <!-- Mahout Implementation Version -->
+  <!--
+       This can be any string value that does not include spaces
+       This will be used when creating build artifact file names.
+
+       By default, this should be set to "X.Y.N-dev" where X.Y.N is
+       "1 greater" then the last version released (on this branch).
+    -->
+  <property name="version" value="0.1-dev" />
+
+  <!-- 3rd party libraries for compilation -->
+  <property name="lib" value="../core/lib" />
+
+  <!-- mahout source files -->
+  <property name="src" value="src" />
+
+  <!-- Destination for compiled classes and binaries -->
+  <property name="dest" value="build" />
+
+  <!-- Destination for distribution files (demo WAR, src distro, etc.) -->
+  <property name="dist" value="dist" />
+
+  <!-- Type of checksum to compute for distribution files -->
+  <property name="checksum.algorithm" value="md5" />
+
+  <property name="fullname" value="apache-${ant.project.name}"/>
+  <property name="fullnamever" value="apache-${ant.project.name}-${version}"/>
+
+  <!-- Mahout Specification Version -->
+  <!--
+       This will be used in the Manifest file, and therefore must
+       match the pattern "digit+{.digit+}*"
+
+       By default, this should be set to "X.Y.M.${dateversion}"
+       where X.Y.M is the last version released (on this branch).
+    -->
+  <property name="specversion" value="1.2.${dateversion}" />
+
+  <!-- Javadoc properties -->
+  <property name="javadoc.years" value="2006 - ${year}" />
+  <property name="build.docs" value="${dest}/docs"/>
+  <property name="build.javadoc" value="${build.docs}/api"/>
+  <property name="javadoc.access" value="protected"/>
+  <property name="javadoc.link.java"
+            value="http://java.sun.com/j2se/1.5.0/docs/api/"/>
+  <property name="javadoc.link.junit"
+            value="http://junit.sourceforge.net/javadoc/"/>
+  <property name="javadoc.link.lucene"
+            value="http://lucene.apache.org/java/docs/api/"/>
+  <property name="javadoc.packages" value="org.apache.mahout.*"/>
+
+  <!-- JUnit properties -->
+  <property name="junit.output.dir" location="${dest}/test-results"/>
+  <property name="junit.reports" location="${dest}/test-results/reports"/>
+  <property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
+  <property name="tests.verbose" value="false"/>
+
+  <property name="junit.jar" value="junit-3.8.2.jar"/>
+  <property name="junit-location.jar" value="${lib}/${junit.jar}"/>
+  <path id="junit-path">
+    <pathelement location="${junit-location.jar}"/>
+  </path>
+
+
+  <!-- The compilation classpath -->
+  <path id="compile.classpath">
+    <fileset dir="${lib}">
+      <include name="*.jar" />
+      <exclude name="junit*.jar"/>
+    </fileset>
+    <filelist files="../core/dist/apache-mahout-core-${version}.jar"/>
+  </path>
+  <path id="test.classpath">
+    <path refid="junit-path"/>
+    <path refid="compile.classpath"/>
+    <pathelement location="${dest}/test-classes"/>
+    <pathelement location="${dest}/classes"/>
+  </path>
+
+
+  <path id="junit.classpath">
+    <path refid="junit-path"/>
+    <pathelement location="${dest}/test-classes"/>
+    <pathelement location="${dest}/classes"/>
+    <path refid="compile.classpath"/>
+    <pathelement path="${java.class.path}"/>
+  </path>
+
+
+  <!-- Macro for compilation -->
+  <macrodef name="mahout-javac">
+    <attribute name="destdir" />
+    <attribute name="classpathref" />
+    <element name="nested" optional="true" implicit="true" />
+    <sequential>
+      <mkdir dir="@{destdir}" />
+      <javac destdir="@{destdir}"
+             target="${java.compat.version}"
+             source="${java.compat.version}"
+             debug="on"
+             encoding="utf8"
+             sourcepath=""
+             classpathref="@{classpathref}">
+         <nested />
+      </javac>
+    </sequential>
+  </macrodef>
+
+  <!-- Macro for building Jars -->
+  <macrodef name="mahout-jar">
+    <attribute name="destfile" />
+    <attribute name="basedir" />
+    <attribute name="includes" default="org/apache/**" />
+    <attribute name="manifest" default="${dest}/META-INF/MANIFEST.MF" />
+    <element name="nested" optional="true" implicit="true" />
+    <sequential>
+      <jar destfile="@{destfile}"
+           basedir="@{basedir}"
+           includes="@{includes}"
+           filesetmanifest="skip"
+           manifest="@{manifest}">
+        <metainf dir="${basedir}" includes="LICENSE.txt,NOTICE.txt"/>
+        <nested />
+      </jar>
+    </sequential>
+  </macrodef>
+
+  <!-- Macro for building checksum files
+       This is only needed until the "format" option is supported
+       by ant's built in checksum task
+   -->
+  <macrodef name="mahout-checksum">
+    <attribute name="file"/>
+    <!-- NOTE: we use the value of @{file} in the names any properties
+         set because macro's don't have variables, and otherwise we
+         wouldn't be able to checksum more then one file per build
+      -->
+    <sequential>
+     <checksum file="@{file}"
+               property="@{file}.sum"
+               algorithm="${checksum.algorithm}" />
+     <basename file="@{file}" property="@{file}.base" />
+     <concat destfile="@{file}.${checksum.algorithm}"
+             force="yes"
+             append="false"
+             fixlastline="yes">
+       <header trimleading="yes">${@{file}.sum}  </header>
+       <!-- empty fileset to trick concat -->
+       <fileset dir="." excludes="**" />
+       <footer trimleading="yes">${@{file}.base}
+       </footer>
+     </concat>
+    </sequential>
+  </macrodef>
+
+  <!-- Default target: usage.  Prints out instructions. -->
+  <target name="usage"
+          description="Prints out instructions">
+    <echo message="Welcome to the Mahout project!" />
+    <!--<echo message="Use 'ant example' to create a runnable example configuration." />-->
+    <echo message="And for developers:"/>
+    <echo message="Use 'ant clean' to clean compiled files." />
+    <echo message="Use 'ant compile' to compile the source code." />
+    <!--<echo message="Use 'ant dist' to build the project WAR and JAR files." />
+    <echo message="Use 'ant package' to build a .zip and .tgz for distribution." />-->
+    <echo message="Use 'ant test' to run unit tests." />
+  </target>
+
+  <!-- Clean: cleans compiled files and other temporary artifacts. -->
+  <target name="clean"
+          description="Cleans compiled files and other temporary artifacts.">
+    <delete dir="${dest}" />
+    <delete dir="${dist}" />
+  </target>
+
+
+  <!-- ========================================================================= -->
+  <!-- ===================== COMPILATION-RELATED TASKS ========================= -->
+  <!-- ========================================================================= -->
+
+  <!-- Compile the project. -->
+  <target name="compile"
+          description="Compile the source code."
+          >
+    <mahout-javac destdir="${dest}/classes"
+                classpathref="compile.classpath">
+      <src path="${src}/main/java" />
+    </mahout-javac>
+  </target>
+
+  <target name="javadoc" depends="compile"
+          description="Generates javadoc documentation.">
+
+    <mkdir dir="${build.javadoc}"/>
+
+    <path id="javadoc.classpath">
+       <path refid="compile.classpath"/>
+    </path>
+
+    <javadoc
+      destdir="${build.javadoc}"
+      author="true"
+      version="true"
+      failonerror="true"
+      use="true"
+      encoding="utf8"
+      access="${javadoc.access}"
+      windowtitle="${Name} ${version} API"
+      doctitle="${Name} ${version} API (${specversion})"
+      bottom="Copyright &amp;copy; ${javadoc.years} The Apache Software Foundation"
+      >
+        <packageset dir="${src}/main/java"/>
+        <link href="${javadoc.link.java}"/>
+        <link href="${javadoc.link.junit}"/>
+        <classpath refid="javadoc.classpath"/>
+    </javadoc>
+  </target>
+
+  <target name="compile-test" depends="compile">
+    <mahout-javac
+
+      destdir="${dest}/test-classes/" classpathref="test.classpath">
+      <src path="${src}/test/java"/>
+      </mahout-javac>
+
+    <!-- Copy any data files present to the classpath -->
+    <copy todir="${dest}/test-classes">
+      <fileset dir="src/test/java" excludes="**/*.java"/>
+    </copy>
+
+    <!-- Copy any data files present to the classpath -->
+    <copy todir="${dest}/test-classes">
+      <fileset dir="src/test/resources"/>
+    </copy>
+
+  </target>
+
+  <target name="test" depends="compile-test, dist-jar" description="Runs unit tests">
+    <mkdir dir="${junit.output.dir}"/>
+    <junit printsummary="off" haltonfailure="no"
+      errorProperty="tests.failed" failureProperty="tests.failed" maxmemory="256m">
+      <classpath refid="junit.classpath"/>
+      <assertions>
+        <enable package="org.apache.mahout"/>
+      </assertions>
+
+      <!-- allow tests to control debug prints -->
+      <sysproperty key="tests.verbose" value="${tests.verbose}"/>
+
+      <!-- TODO: create propertyset for test properties, so each project can have its own set -->
+      <sysproperty key="dataDir" file="src/test"/>
+      <sysproperty key="tempDir" file="${dest}/test"/>
+      <sysproperty key="java.io.tmpdir" file="${dest}/test"/>
+
+
+      <formatter type="xml"/>
+      <formatter type="brief" usefile="false"/>
+      <batchtest fork="yes" todir="${junit.output.dir}" unless="testcase">
+        <fileset dir="${src}/test/java" includes="${junit.includes}" excludes="${junit.excludes}"/>
+      </batchtest>
+      <batchtest fork="yes" todir="${junit.output.dir}" if="testcase">
+        <fileset dir="${src}/test/java" includes="**/${testcase}.java"/>
+      </batchtest>
+    </junit>
+    <junitreport todir="${junit.output.dir}">
+      <fileset dir="${junit.output.dir}">
+        <include name="TEST-*.xml"/>
+      </fileset>
+      <report format="frames" todir="${junit.output.dir}/html"/>
+    </junitreport>
+
+    <!-- create this file, then if we don't fail, delete it -->
+    <!-- this meme makes it easy to tell if contribs have failed later -->
+    <echo file="${dest}/junitfailed.flag">MAYBE</echo>
+    <fail if="tests.failed">Tests failed!</fail>
+    <!-- life would be easier if echo had an 'if' attribute like fail -->
+    <delete file="${dest}/junitfailed.flag" />
+
+  </target>
+
+  <target name="examples-test" depends="compile-test, dist-jar" description="Runs unit tests for the examples">
+    <mkdir dir="${junit.output.dir}/examples"/>
+    <junit printsummary="off" haltonfailure="no"
+      errorProperty="tests.failed" failureProperty="tests.failed" maxmemory="256m">
+      <classpath refid="junit.classpath"/>
+      <assertions>
+        <enable package="org.apache.mahout"/>
+      </assertions>
+
+      <!-- allow tests to control debug prints -->
+      <sysproperty key="tests.verbose" value="${tests.verbose}"/>
+
+      <!-- TODO: create propertyset for test properties, so each project can have its own set -->
+      <sysproperty key="dataDir" file="src/test"/>
+      <sysproperty key="tempDir" file="${dest}/test"/>
+      <sysproperty key="java.io.tmpdir" file="${dest}/test"/>
+
+      <formatter type="xml"/>
+      <formatter type="brief" usefile="false"/>
+      <batchtest fork="yes" todir="${junit.output.dir}/examples" unless="testcase">
+        <fileset dir="${src}/test/examples" includes="${junit.includes}" excludes="${junit.excludes}"/>
+      </batchtest>
+      <batchtest fork="yes" todir="${junit.output.dir}/examples" if="testcase">
+        <fileset dir="${src}/test/examples" includes="**/${testcase}.java"/>
+      </batchtest>
+    </junit>
+    <junitreport todir="${junit.output.dir}/examples">
+      <fileset dir="${junit.output.dir}/examples">
+        <include name="TEST-*.xml"/>
+      </fileset>
+      <report format="frames" todir="${junit.output.dir}/examples/html"/>
+    </junitreport>
+
+    <fail if="tests.failed">Tests failed!</fail>
+  </target>
+
+  <target name="job" depends="compile">
+    <jar jarfile="${dest}/${fullnamever}.job">
+      <zipfileset dir="${dest}/classes"/>
+      <zipfileset dir="${lib}" prefix="lib"
+                  includes="**/*.jar" excludes="hadoop-*.jar"/>
+    </jar>
+  </target>
+
+
+  <target name="dist-jar"
+          description="Creates the Mahout JAR Distribution file."
+          depends="compile, make-manifest">
+    <mkdir dir="${dist}" />
+    <mahout-jar
+         destfile="${dist}/${fullnamever}.jar"
+         basedir="${dest}/classes" />
+
+  </target>
+
+  <target name="make-manifest" >
+     <!-- If possible, include the svnversion -->
+     <exec dir="." executable="svnversion" outputproperty="svnversion" failifexecutionfails="false">
+      <arg line="."/>
+     </exec>
+
+     <!-- no description, don't advertise -->
+     <mkdir dir="${dest}/META-INF/" />
+     <manifest mode="replace" file="${dest}/META-INF/MANIFEST.MF">
+        <!--
+        http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#JAR%20Manifest
+        http://java.sun.com/j2se/1.5.0/docs/guide/versioning/spec/versioning2.html
+        http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Package.html
+        http://java.sun.com/j2se/1.5.0/docs/api/java/util/jar/package-summary.html
+        http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html
+        -->
+        <!-- Don't set 'Manifest-Version' it identifies the version of the
+             manifest file format, and should allways be 1.0 (the default)
+
+             Don't set 'Created-by' attribute, it's purpose is
+             to identify the version of java used to build the jar,
+             which ant will do by default.
+
+             Ant will happily override these with bogus strings if you
+             tell it to, so don't.
+
+             NOTE: we don't use section info because all of our manifest data
+             applies to the entire jar/war ... no package specific info.
+        -->
+        <attribute name="Extension-Name"
+                   value="org.apache.mahout"/>
+        <attribute name="Specification-Title"
+                   value="Apache Mahout Machine Learning"/>
+        <!-- spec version must match "digit+{.digit+}*" -->
+        <attribute name="Specification-Version"
+                   value="${specversion}"/>
+        <attribute name="Specification-Vendor"
+                   value="The Apache Software Foundation"/>
+        <attribute name="Implementation-Title"
+                   value="org.apache.mahout"/>
+        <!-- impl version can be any string -->
+        <attribute name="Implementation-Version"
+                   value="${version} ${svnversion} - ${user.name} - ${DSTAMP} ${TSTAMP}"/>
+        <attribute name="Implementation-Vendor"
+                   value="The Apache Software Foundation"/>
+        <attribute name="X-Compile-Source-JDK"
+                   value="${java.compat.version}"/>
+        <attribute name="X-Compile-Target-JDK"
+                   value="${java.compat.version}"/>
+     </manifest>
+  </target>
+
+  <!-- EXAMPLES -->
+
+
+
+  <property name="working.dir" value="work"/>
+  <target name="check-files">
+    <available file="temp/20news-18828.tar.gz" property="20news-18828.exists"/>
+    <available file="${working.dir}/20news-18828" property="20news-18828.expanded"/>
+
+  </target>
+
+  <target name="get-20news-18828" unless="20news-18828.exists">
+    <get src="http://people.csail.mit.edu/jrennie/20Newsgroups/20news-18828.tar.gz"
+         dest="temp/20news-18828.tar.gz"/>
+
+  </target>
+  <target name="expand-20news-18828" unless="20news-18828.expanded">
+    <gunzip src="temp/20news-18828.tar.gz" dest="temp"/>
+    <untar src="temp/20news-18828.tar" dest="${working.dir}"/>
+  </target>
+
+  <target name="extract-20news-18828" depends="check-files, compile" unless="reuters.extracted">
+    <mkdir dir="${working.dir}/20news-18828-collapse"/>
+    <java classname="org.apache.mahout.classifiers.bayes.ExtractTwentyNewsgroups" maxmemory="1024M" fork="true">
+      <classpath refid="compile.classpath"/>
+      <!--
+      Input format is:
+      inputDir outputDir label Analyzer character set
+      -->
+      <arg line="-p ${working.dir}/20news-18828/ -o ${working.dir}/20news-18828-collapse -a org.apache.lucene.analysis.standard.StandardAnalyzer -c UTF-8"/>
+    </java>
+  </target>
+
+  <target name="get-files" depends="check-files">
+    <mkdir dir="temp"/>
+    <antcall target="get-20news-18828"/>
+    <antcall target="expand-20news-18828"/>
+    <!--<antcall target="extract-20news-18828"/>-->
+  </target>
+
+</project>

Added: lucene/mahout/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/pom.xml?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/pom.xml (added)
+++ lucene/mahout/trunk/examples/pom.xml Thu Aug 14 12:17:43 2008
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.lucene.mahout</groupId>
+    <artifactId>mahout</artifactId>
+    <version>0.1-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.lucene.mahout</groupId>
+  <artifactId>examples</artifactId>
+  <version>${parent.version}</version>
+  <name>Mahout examples</name>
+  <description>Scalable machine learning library examples</description>
+
+  <packaging>jar</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <encoding>UTF-8</encoding>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-install-plugin</artifactId>
+
+        <!-- Copy dependencies with no official Maven artifacts from libs to local Maven repository -->
+
+        <executions>
+          <execution>
+            <id>create-javaee-api-artifact</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>install-file</goal>
+            </goals>
+            <configuration>
+              <file>../core/lib/javaee-api-5.0-1.jar</file>
+              <groupId>javax.ejb</groupId>
+              <artifactId>javaee-api</artifactId>
+              <packaging>jar</packaging>
+              <version>5.0.1</version>
+              <generatePom>true</generatePom>
+              <createChecksum>true</createChecksum>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
+  </build>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.lucene.mahout</groupId>
+      <artifactId>core</artifactId>
+      <version>${parent.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.ejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>5.0.1</version>
+    </dependency>
+
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+
+</project>

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJB.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.ejb;
+
+import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.Refreshable;
+import org.apache.mahout.cf.taste.model.Item;
+import org.apache.mahout.cf.taste.recommender.Rescorer;
+
+import javax.ejb.EJBObject;
+import java.rmi.RemoteException;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * <p>Recommender EJB component interface.</p>
+ *
+ * @see RecommenderEJBLocal
+ * @see org.apache.mahout.cf.taste.recommender.Recommender
+ */
+public interface RecommenderEJB extends EJBObject {
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Object, int)
+   */
+  List<Item> recommend(Object userID, int howMany) throws TasteException, RemoteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Object, int, Rescorer)
+   */
+  List<Item> recommend(Object userID, int howMany, Rescorer<Item> rescorer) throws TasteException, RemoteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#estimatePreference(Object, Object)
+   */
+  double estimatePreference(Object userID, Object itemID) throws TasteException, RemoteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#setPreference(Object, Object, double)
+   */
+  void setPreference(Object userID, Object itemID, double value)
+          throws TasteException, RemoteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#removePreference(Object, Object)
+   */
+  void removePreference(Object userID, Object itemID) throws TasteException, RemoteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#refresh(Collection<Refreshable>)
+   */
+  void refresh(Collection<Refreshable> alreadyRefreshed);
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBBean.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.ejb;
+
+import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.Refreshable;
+import org.apache.mahout.cf.taste.model.Item;
+import org.apache.mahout.cf.taste.recommender.RecommendedItem;
+import org.apache.mahout.cf.taste.recommender.Recommender;
+import org.apache.mahout.cf.taste.recommender.Rescorer;
+
+import javax.ejb.CreateException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * <p>Recommender EJB bean implementation.</p>
+ *
+ * <p>This class exposes a subset of the {@link Recommender} API. In particular it
+ * does not support {@link Recommender#getDataModel()}
+ * since it doesn't make sense to access this via an EJB component.</p>
+ */
+public class RecommenderEJBBean implements SessionBean {
+
+  private Recommender recommender;
+
+  public List<RecommendedItem> recommend(Object userID, int howMany) throws TasteException {
+    return recommender.recommend(userID, howMany);
+  }
+
+  public List<RecommendedItem> recommend(Object userID, int howMany, Rescorer<Item> rescorer)
+          throws TasteException {
+    return recommender.recommend(userID, howMany, rescorer);
+  }
+
+
+  public double estimatePreference(Object userID, Object itemID) throws TasteException {
+    return recommender.estimatePreference(userID, itemID);
+  }
+
+  public void setPreference(Object userID, Object itemID, double value) throws TasteException {
+    recommender.setPreference(userID, itemID, value);
+  }
+
+  public void removePreference(Object userID, Object itemID) throws TasteException {
+    recommender.removePreference(userID, itemID);
+  }
+
+  public void refresh(Collection<Refreshable> alreadyRefreshed) {
+    recommender.refresh(alreadyRefreshed);
+  }
+
+  public void setSessionContext(SessionContext sessionContext) {
+    // Do nothing
+  }
+
+  public void ejbCreate() throws CreateException {
+    Context ctx = null;
+    try {
+
+      ctx = new InitialContext();
+      String recommenderClassName = (String) ctx.lookup("java:comp/env/recommender-class");
+      if (recommenderClassName == null) {
+        String recommenderJNDIName = (String) ctx.lookup("java:comp/env/recommender-jndi-name");
+        if (recommenderJNDIName == null) {
+          throw new CreateException("recommender-class and recommender-jndi-name env-entry not defined");
+        }
+        recommender = (Recommender) ctx.lookup("java:comp/env/" + recommenderJNDIName);
+      } else {
+        recommender = Class.forName(recommenderClassName).asSubclass(Recommender.class).newInstance();
+      }
+
+    } catch (NamingException ne) {
+      throw new CreateException(ne.toString());
+    } catch (ClassNotFoundException cnfe) {
+      throw new CreateException(cnfe.toString());
+    } catch (InstantiationException ie) {
+      throw new CreateException(ie.toString());
+    } catch (IllegalAccessException iae) {
+      throw new CreateException(iae.toString());
+    } finally {
+      if (ctx != null) {
+        try {
+          ctx.close();
+        } catch (NamingException ne) {
+          throw new CreateException(ne.toString());
+        }
+      }
+    }
+  }
+
+  public void ejbRemove() {
+    // Do nothing
+  }
+
+  public void ejbActivate() {
+    // Do nothing: stateless session beans are not passivated/activated
+  }
+
+  public void ejbPassivate() {
+    // Do nothing: stateless session beans are not passivated/activated
+  }
+
+  @Override
+  public String toString() {
+    return "RecommenderEJBBean[recommender:" + recommender + ']';
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBHome.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBHome.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBHome.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBHome.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+import java.rmi.RemoteException;
+
+/**
+ * <p>Recommender EJB home interface.</p>
+ *
+ * @see RecommenderEJBLocalHome
+ */
+public interface RecommenderEJBHome extends EJBHome {
+
+  RecommenderEJB create() throws RemoteException, CreateException;
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocal.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.ejb;
+
+import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.Refreshable;
+import org.apache.mahout.cf.taste.model.Item;
+import org.apache.mahout.cf.taste.recommender.Rescorer;
+
+import javax.ejb.EJBLocalObject;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * <p>Recommender EJB local component interface.</p>
+ *
+ * @see RecommenderEJB
+ * @see org.apache.mahout.cf.taste.recommender.Recommender
+ */
+public interface RecommenderEJBLocal extends EJBLocalObject {
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Object, int)
+   */
+  List<Item> recommend(Object userID, int howMany) throws TasteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#recommend(Object, int, Rescorer)
+   */
+  List<Item> recommend(Object userID, int howMany, Rescorer<Item> rescorer) throws TasteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#estimatePreference(Object, Object)
+   */
+  double estimatePreference(Object userID, Object itemID) throws TasteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#setPreference(Object, Object, double)
+   */
+  void setPreference(Object userID, Object itemID, double value) throws TasteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#removePreference(Object, Object)
+   */
+  void removePreference(Object userID, Object itemID) throws TasteException;
+
+  /**
+   * @see org.apache.mahout.cf.taste.recommender.Recommender#refresh(Collection<Refreshable>)
+   */
+  void refresh(Collection<Refreshable> alreadyRefreshed);
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocalHome.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocalHome.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocalHome.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/RecommenderEJBLocalHome.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.ejb;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+/**
+ * <p>Recommender EJB local home interface.</p>
+ *
+ * @see RecommenderEJBHome
+ */
+public interface RecommenderEJBLocalHome extends EJBLocalHome {
+
+  RecommenderEJBLocal create() throws CreateException;
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/ejb-jar.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/ejb-jar.xml?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/ejb-jar.xml (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/ejb-jar.xml Thu Aug 14 12:17:43 2008
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
+         version="2.1">
+  <enterprise-beans>
+    <session>
+      <ejb-name>RecommenderEJB</ejb-name>
+      <home>org.apache.mahout.cf.taste.ejb.RecommenderEJBHome</home>
+      <remote>org.apache.mahout.cf.taste.ejb.RecommenderEJB</remote>
+      <local-home>org.apache.mahout.cf.taste.ejb.RecommenderEJBLocalHome</local-home>
+      <local>org.apache.mahout.cf.taste.ejb.RecommenderEJBLocal</local>
+      <ejb-class>org.apache.mahout.cf.taste.ejb.RecommenderEJBBean</ejb-class>
+      <session-type>Stateless</session-type>
+      <transaction-type>Container</transaction-type>
+      <env-entry>
+        <env-entry-name>recommender-class</env-entry-name>
+        <env-entry-type>java.lang.String</env-entry-type>
+        <env-entry-value>@RECOMMENDER_CLASS@</env-entry-value>
+      </env-entry>
+      <!-- ...or give the JNDI name where an implementation can be found,
+           relative to java:comp/env -->
+      <!--
+         <env-entry>
+           <env-entry-name>recommender-jndi-name</env-entry-name>
+           <env-entry-type>java.lang.String</env-entry-type>
+           <env-entry-value>foo/YourRecommender</env-entry-value>
+         </env-entry>
+         -->
+    </session>
+  </enterprise-beans>
+  <assembly-descriptor>
+    <container-transaction>
+      <method>
+        <ejb-name>RecommenderEJB</ejb-name>
+        <method-name>*</method-name>
+      </method>
+      <trans-attribute>Supports</trans-attribute>
+    </container-transaction>
+  </assembly-descriptor>
+</ejb-jar>

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/mapping.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/mapping.xml?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/mapping.xml (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/mapping.xml Thu Aug 14 12:17:43 2008
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<java-wsdl-mapping xmlns="http://java.sun.com/xml/ns/j2ee"
+                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd"
+                   version="1.1">
+  <package-mapping>
+    <package-type>org.apache.mahout.cf.taste.ejb</package-type>
+    <namespaceURI>urn:org.apache.mahout.cf.taste.ejb.RecommenderWS</namespaceURI>
+  </package-mapping>
+</java-wsdl-mapping>

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/webservices.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/webservices.xml?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/webservices.xml (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/ejb/webservices.xml Thu Aug 14 12:17:43 2008
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<webservices xmlns="http://java.sun.com/xml/ns/j2ee"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"
+             version="1.1">
+  <webservice-description>
+    <webservice-description-name>RecommenderWS</webservice-description-name>
+    <wsdl-file>META-INF/RecommenderWS.wsdl</wsdl-file>
+    <jaxrpc-mapping-file>META-INF/mapping.xml</jaxrpc-mapping-file>
+    <port-component>
+      <port-component-name>RecommenderServicePort</port-component-name>
+      <wsdl-port>
+        <namespaceURI>urn:org.apache.mahout.cf.taste.ejb.RecommenderWS</namespaceURI>
+        <localpart>RecommenderServicePort</localpart>
+      </wsdl-port>
+      <service-endpoint-interface>org.apache.mahout.cf.taste.ejb.RecommenderWS</service-endpoint-interface>
+      <service-impl-bean>
+        <ejb-link>RecommenderEJB</ejb-link>
+      </service-impl-bean>
+    </port-component>
+  </webservice-description>
+</webservices>
\ No newline at end of file

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensDataModel.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.example.grouplens;
+
+import org.apache.mahout.cf.taste.impl.common.FastMap;
+import org.apache.mahout.cf.taste.impl.common.IOUtils;
+import org.apache.mahout.cf.taste.impl.common.FileLineIterable;
+import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
+import org.apache.mahout.cf.taste.model.Item;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+public final class GroupLensDataModel extends FileDataModel {
+
+  private final Map<String, Movie> movieMap;
+
+  GroupLensDataModel() throws IOException {
+    this(readResourceToTempFile("/org/apache/mahout/cf//taste/example/grouplens/ratings.dat"),
+         readResourceToTempFile("/org/apache/mahout/cf//taste/example/grouplens/movies.dat"));
+  }
+
+  /**
+   * @param ratingsFile GroupLens ratings.dat file in its native format
+   * @param moviesFile GroupLens movies.dat file in its native format
+   * @throws IOException if an error occurs while reading or writing files
+   */
+  public GroupLensDataModel(File ratingsFile, File moviesFile) throws IOException {
+    super(convertGLFile(ratingsFile, true));
+    File convertedMoviesFile = convertGLFile(moviesFile, false);
+    movieMap = new FastMap<String, Movie>(5001);
+    for (String line : new FileLineIterable(convertedMoviesFile)) {
+      String[] tokens = line.split(",");
+      String id = tokens[0];
+      movieMap.put(id, new Movie(id, tokens[1], tokens[2]));
+    }
+  }
+
+  @Override
+  protected Item buildItem(String id) {
+    Item item = movieMap.get(id);
+    if (item == null) {
+      throw new NoSuchElementException();
+    }
+    return item;
+  }
+
+  private static File convertGLFile(File originalFile, boolean ratings) throws IOException {
+    // Now translate the file; remove commas, then convert "::" delimiter to comma
+    File resultFile = new File(new File(System.getProperty("java.io.tmpdir")),
+                                     "taste." + (ratings ? "ratings" : "movies") + ".txt");
+    if (!resultFile.exists()) {
+      PrintWriter writer = null;
+      try {
+        writer = new PrintWriter(new FileWriter(resultFile));
+        for (String line : new FileLineIterable(originalFile)) {
+          String convertedLine;
+          if (ratings) {
+            // toss the last column of data, which is a timestamp we don't want
+            convertedLine = line.substring(0, line.lastIndexOf("::")).replace("::", ",");
+          } else {
+            convertedLine = line.replace(",", "").replace("::", ",");
+          }
+          writer.println(convertedLine);
+        }
+        writer.flush();
+      } catch (IOException ioe) {
+        resultFile.delete();
+        throw ioe;
+      } finally {
+        IOUtils.quietClose(writer);
+      }
+    }
+    return resultFile;
+  }
+
+  private static File readResourceToTempFile(String resourceName) throws IOException {
+    InputStream is = GroupLensRecommender.class.getResourceAsStream(resourceName);
+    if (is == null) {
+      is = new FileInputStream("src/example" + resourceName);
+    }
+    try {
+      File tempFile = File.createTempFile("taste", null);
+      tempFile.deleteOnExit();
+      OutputStream os = new FileOutputStream(tempFile);
+      try {
+        int bytesRead;
+        for (byte[] buffer = new byte[32768]; (bytesRead = is.read(buffer)) > 0;) {
+          os.write(buffer, 0, bytesRead);
+        }
+        os.flush();
+        return tempFile;
+      } finally {
+        IOUtils.quietClose(os);
+      }
+    } finally {
+      IOUtils.quietClose(is);
+    }
+  }
+
+
+  @Override
+  public String toString() {
+    return "GroupLensDataModel";
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommender.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.example.grouplens;
+
+import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.common.Refreshable;
+import org.apache.mahout.cf.taste.impl.recommender.CachingRecommender;
+import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender;
+import org.apache.mahout.cf.taste.model.DataModel;
+import org.apache.mahout.cf.taste.model.Item;
+import org.apache.mahout.cf.taste.recommender.RecommendedItem;
+import org.apache.mahout.cf.taste.recommender.Recommender;
+import org.apache.mahout.cf.taste.recommender.Rescorer;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * A simple {@link Recommender} implemented for the GroupLens demo.
+ */
+public final class GroupLensRecommender implements Recommender {
+
+  private final Recommender recommender;
+
+  /**
+   * @throws IOException if an error occurs while creating the {@link GroupLensDataModel}
+   * @throws TasteException if an error occurs while initializing this {@link GroupLensRecommender}
+   */
+  public GroupLensRecommender() throws IOException, TasteException {
+    this(new GroupLensDataModel());
+  }
+
+  /**
+   * <p>Alternate constructor that takes a {@link DataModel} argument, which allows this {@link Recommender}
+   * to be used with the {@link org.apache.mahout.cf.taste.eval.RecommenderEvaluator} framework.</p>
+   *
+   * @param dataModel data model
+   * @throws TasteException if an error occurs while initializing this {@link GroupLensRecommender}
+   */
+  public GroupLensRecommender(DataModel dataModel) throws TasteException {
+    recommender = new CachingRecommender(new SlopeOneRecommender(dataModel));
+  }
+
+  public List<RecommendedItem> recommend(Object userID, int howMany) throws TasteException {
+    return recommender.recommend(userID, howMany);
+  }
+
+  public List<RecommendedItem> recommend(Object userID, int howMany, Rescorer<Item> rescorer)
+          throws TasteException {
+    return recommender.recommend(userID, howMany, rescorer);
+  }
+
+  public double estimatePreference(Object userID, Object itemID) throws TasteException {
+    return recommender.estimatePreference(userID, itemID);
+  }
+
+  public void setPreference(Object userID, Object itemID, double value) throws TasteException {
+    recommender.setPreference(userID, itemID, value);
+  }
+
+  public void removePreference(Object userID, Object itemID) throws TasteException {
+    recommender.removePreference(userID, itemID);
+  }
+
+  public DataModel getDataModel() {
+    return recommender.getDataModel();
+  }
+
+  public void refresh(Collection<Refreshable> alreadyRefreshed) {
+    recommender.refresh(alreadyRefreshed);
+  }
+
+  @Override
+  public String toString() {
+    return "GroupLensRecommender[recommender:" + recommender + ']';
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderBuilder.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderBuilder.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderBuilder.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderBuilder.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.example.grouplens;
+
+import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.eval.RecommenderBuilder;
+import org.apache.mahout.cf.taste.model.DataModel;
+import org.apache.mahout.cf.taste.recommender.Recommender;
+
+final class GroupLensRecommenderBuilder implements RecommenderBuilder {
+
+  public Recommender buildRecommender(DataModel dataModel) throws TasteException {
+    return new GroupLensRecommender(dataModel);
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderEvaluatorRunner.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderEvaluatorRunner.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderEvaluatorRunner.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/GroupLensRecommenderEvaluatorRunner.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.example.grouplens;
+
+import org.apache.mahout.cf.taste.common.TasteException;
+import org.apache.mahout.cf.taste.eval.RecommenderEvaluator;
+import org.apache.mahout.cf.taste.impl.eval.AverageAbsoluteDifferenceRecommenderEvaluator;
+
+import java.io.IOException;
+
+/**
+ * <p>A simple example "runner" class which will evaluate the performance of the current
+ * implementation of {@link GroupLensRecommender}.</p>
+ */
+public final class GroupLensRecommenderEvaluatorRunner {
+
+  private GroupLensRecommenderEvaluatorRunner() {
+    // do nothing
+  }
+
+  public static void main(String... args) throws IOException, TasteException {
+    RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecommenderEvaluator();
+    double evaluation = evaluator.evaluate(new GroupLensRecommenderBuilder(),
+                                                 new GroupLensDataModel(),
+                                                 0.9,
+                                                 0.1);
+    System.out.println(evaluation);
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/Movie.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/Movie.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/Movie.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/cf/taste/example/grouplens/Movie.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.cf.taste.example.grouplens;
+
+import org.apache.mahout.cf.taste.impl.model.GenericItem;
+
+final class Movie extends GenericItem<String> {
+
+  private final String movieTitle;
+  private final String genres;
+
+  Movie(String id, String movieTitle, String genres) {
+    super(id);
+    this.movieTitle = movieTitle;
+    this.genres = genres;
+  }
+
+  @Override
+  public String toString() {
+    return getID().toString() + '\t' + movieTitle + '\t' + genres;
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputDriver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputDriver.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputDriver.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputDriver.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,55 @@
+package org.apache.mahout.clustering.syntheticcontrol.canopy;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.FileInputFormat;
+import org.apache.hadoop.mapred.FileOutputFormat;
+import org.apache.hadoop.mapred.JobClient;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.Reducer;
+import org.apache.mahout.matrix.Vector;
+
+import java.io.IOException;
+
+public class InputDriver {
+
+  public static void main(String[] args) throws Exception {
+    runJob(args[0], args[1]);
+  }
+
+  public static void runJob(String input, String output) throws IOException {
+    JobClient client = new JobClient();
+    JobConf conf = new JobConf(InputDriver.class);
+
+    conf.setOutputKeyClass(Text.class);
+    conf.setOutputValueClass(Vector.class);
+
+    FileInputFormat.setInputPaths(conf, new Path(input));
+    FileOutputFormat.setOutputPath(conf, new Path(output));
+
+    conf.setMapperClass(InputMapper.class);
+
+    conf.setReducerClass(Reducer.class);
+    conf.setNumReduceTasks(0);
+
+    client.setConf(conf);
+    JobClient.runJob(conf);
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/InputMapper.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,52 @@
+package org.apache.mahout.clustering.syntheticcontrol.canopy;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.MapReduceBase;
+import org.apache.hadoop.mapred.Mapper;
+import org.apache.hadoop.mapred.OutputCollector;
+import org.apache.hadoop.mapred.Reporter;
+import org.apache.mahout.matrix.DenseVector;
+import org.apache.mahout.matrix.Vector;
+
+public class InputMapper extends MapReduceBase implements
+    Mapper<LongWritable, Text, Text, Text> {
+
+  public void map(LongWritable key, Text values,
+      OutputCollector<Text, Text> output, Reporter reporter) throws IOException {
+    String[] numbers = values.toString().split(" ");
+    // sometimes there are multiple separator spaces
+    List<Double> doubles = new ArrayList<Double>();
+    for (int i = 0; i < numbers.length; i++) {
+      String value = numbers[i];
+      if (value.length() > 0)
+        doubles.add(new Double(value));
+    }
+    Vector result = new DenseVector(doubles.size());
+    int index = 0;
+    for (Double d : doubles)
+      result.set(index++, d);
+    output.collect(null, new Text(result.asFormatString()));
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/Job.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/Job.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/Job.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/Job.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,77 @@
+package org.apache.mahout.clustering.syntheticcontrol.canopy;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapred.JobClient;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.mahout.clustering.canopy.CanopyClusteringJob;
+
+import java.io.IOException;
+
+public class Job {
+
+  public static void main(String[] args) throws Exception {
+    if (args.length == 5) {
+      String input = args[0];
+      String output = args[1];
+      String measureClassName = args[2];
+      double t1 = Double.parseDouble(args[3]);
+      double t2 = Double.parseDouble(args[4]);
+      runJob(input, output, measureClassName, t1, t2);
+    } else
+      runJob("testdata", "output",
+          "org.apache.mahout.utils.EuclideanDistanceMeasure", 80, 55);
+  }
+
+  /**
+   * Run the canopy clustering job on an input dataset using the given distance
+   * measure, t1 and t2 parameters. All output data will be written to the
+   * output directory, which will be initially deleted if it exists. The
+   * clustered points will reside in the path <output>/clustered-points. By
+   * default, the job expects the a file containing synthetic_control.data as
+   * obtained from
+   * http://archive.ics.uci.edu/ml/datasets/Synthetic+Control+Chart+Time+Series
+   * resides in a directory named "testdata", and writes output to a directory
+   * named "output".
+   * 
+   * @param input the String denoting the input directory path
+   * @param output the String denoting the output directory path
+   * @param measureClassName the String class name of the DistanceMeasure to use
+   * @param t1 the canopy T1 threshold
+   * @param t2 the canopy T2 threshold
+   */
+  private static void runJob(String input, String output,
+      String measureClassName, double t1, double t2) throws IOException {
+    JobClient client = new JobClient();
+    JobConf conf = new JobConf(Job.class);
+
+    Path outPath = new Path(output);
+    client.setConf(conf);
+    FileSystem dfs = FileSystem.get(conf);
+    if (dfs.exists(outPath))
+      dfs.delete(outPath, true);
+    InputDriver.runJob(input, output + "/data");
+    CanopyClusteringJob.runJob(output + "/data", output, measureClassName,
+        t1, t2);
+    OutputDriver.runJob(output + "/clusters", output + "/clustered-points");
+
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputDriver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputDriver.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputDriver.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputDriver.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,56 @@
+package org.apache.mahout.clustering.syntheticcontrol.canopy;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.FileInputFormat;
+import org.apache.hadoop.mapred.FileOutputFormat;
+import org.apache.hadoop.mapred.JobClient;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.Reducer;
+
+import java.io.IOException;
+
+public class OutputDriver {
+
+  public static void main(String[] args) throws Exception {
+    runJob(args[0], args[1]);
+  }
+
+  public static void runJob(String input, String output) throws IOException {
+    JobClient client = new JobClient();
+    JobConf conf = new JobConf(OutputDriver.class);
+
+    conf.setOutputKeyClass(Text.class);
+    conf.setOutputValueClass(IntWritable.class);
+
+    FileInputFormat.setInputPaths(conf, new Path(input));
+    FileOutputFormat.setOutputPath(conf, new Path(output));
+
+    conf.setMapperClass(OutputMapper.class);
+
+    conf.setReducerClass(Reducer.class);
+    conf.setNumReduceTasks(0);
+
+    client.setConf(conf);
+    JobClient.runJob(conf);
+  }
+
+}

Added: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputMapper.java?rev=685998&view=auto
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputMapper.java (added)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/clustering/syntheticcontrol/canopy/OutputMapper.java Thu Aug 14 12:17:43 2008
@@ -0,0 +1,45 @@
+package org.apache.mahout.clustering.syntheticcontrol.canopy;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.MapReduceBase;
+import org.apache.hadoop.mapred.Mapper;
+import org.apache.hadoop.mapred.OutputCollector;
+import org.apache.hadoop.mapred.Reporter;
+import org.apache.mahout.clustering.canopy.Canopy;
+import org.apache.mahout.matrix.AbstractVector;
+import org.apache.mahout.matrix.Vector;
+
+public class OutputMapper extends MapReduceBase implements
+    Mapper<LongWritable, Text, Text, Text> {
+
+  public void map(LongWritable key, Text values,
+      OutputCollector<Text, Text> output, Reporter reporter) throws IOException {
+    String foo = values.toString();
+    int ix = foo.indexOf(']');
+    Canopy canopy = Canopy.decodeCanopy(foo.substring(0, ix + 1));
+    Vector point = AbstractVector.decodeVector(foo.substring(ix + 3));
+    output.collect(new Text(canopy.getIdentifier()), new Text(point
+        .asFormatString()));
+  }
+
+}