Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn <jl@hunch.net>2015-01-03 20:17:24 +0300
committerJohn <jl@hunch.net>2015-01-03 20:17:24 +0300
commit682810e23e965e103ccac3db8e3fe3091beb6f6c (patch)
treea45f8fe17aff7e18293bd48abfe176be72743d47
parent487c69681fccc086cf159de0cdf908ccfffd27f3 (diff)
parent82f547432d0bf7589fe4c69c0d64df31269fa3c0 (diff)
Merge pull request #483 from jmorra/master
Fixing Java build
-rw-r--r--.travis.yml2
-rw-r--r--Makefile7
-rw-r--r--java/pom.xml68
-rw-r--r--java/src/main/c++/vw_VWScorer.cc8
-rw-r--r--java/src/test/java/vw/VWScorerTest.java14
-rw-r--r--java/src/test/resources/house.modelbin101 -> 0 bytes
-rw-r--r--java/src/test/resources/house.vw3
7 files changed, 76 insertions, 26 deletions
diff --git a/.travis.yml b/.travis.yml
index 91e3ae9c..df6b7d62 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,5 +7,5 @@ before_install:
- sudo apt-get install maven
install:
- make
-# - cd java; mvn test
+ - cd java; mvn test
script: make test
diff --git a/Makefile b/Makefile
index 0d53bb54..f3ac6ef9 100644
--- a/Makefile
+++ b/Makefile
@@ -20,17 +20,21 @@ UNAME := $(shell uname)
LIBS = -l boost_program_options -l pthread -l z
BOOST_INCLUDE = -I /usr/include
BOOST_LIBRARY = -L /usr/lib
+NPROCS := 1
ifeq ($(UNAME), Linux)
BOOST_LIBRARY += -L /usr/lib/x86_64-linux-gnu
+ NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
endif
ifeq ($(UNAME), FreeBSD)
LIBS = -l boost_program_options -l pthread -l z -l compat
BOOST_INCLUDE = -I /usr/local/include
+ NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
endif
ifeq "CYGWIN" "$(findstring CYGWIN,$(UNAME))"
LIBS = -l boost_program_options-mt -l pthread -l z
BOOST_INCLUDE = -I /usr/include
+ NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
endif
ifeq ($(UNAME), Darwin)
LIBS = -lboost_program_options-mt -lboost_serialization-mt -l pthread -l z
@@ -46,6 +50,7 @@ ifeq ($(UNAME), Darwin)
BOOST_INCLUDE += -I /opt/local/include
BOOST_LIBRARY += -L /opt/local/lib
endif
+ NPROCS:=$(shell sysctl -n hw.ncpu)
endif
#LIBS = -l boost_program_options-gcc34 -l pthread -l z
@@ -84,7 +89,7 @@ spanning_tree:
cd cluster; $(MAKE)
vw:
- cd vowpalwabbit; $(MAKE) -j 8 things
+ cd vowpalwabbit; $(MAKE) -j $(NPROCS) things
active_interactor:
cd vowpalwabbit; $(MAKE)
diff --git a/java/pom.xml b/java/pom.xml
index 5ef652bb..db48a576 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -1,12 +1,11 @@
<?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/xsd/maven-4.0.0.xsd">
+<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>vw</groupId>
<artifactId>vw-jni-${os.version}-${os.arch}</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>Vowpal Wabbit JNI Layer</name>
<properties>
<slf4j.version>1.7.6</slf4j.version>
@@ -28,14 +27,6 @@
</dependencies>
<build>
- <resources>
- <resource>
- <directory>${project.build.directory}</directory>
- <includes>
- <include>vw_jni.lib</include>
- </includes>
- </resource>
- </resources>
<testResources>
<testResource>
<directory>${project.build.directory}</directory>
@@ -68,7 +59,7 @@
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
- <exec executable="make" failonerror="true"/>
+ <exec executable="make" failonerror="true" />
</target>
</configuration>
</execution>
@@ -82,7 +73,7 @@
<exportAntProperties>true</exportAntProperties>
<target>
<exec executable="make" failonerror="true">
- <arg value="clean"/>
+ <arg value="clean" />
</exec>
</target>
</configuration>
@@ -145,6 +136,53 @@
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.7</version>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${project.build.directory}</directory>
+ <includes>
+ <include>vw_jni.lib</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.4.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-provider-gitexe</artifactId>
+ <version>1.3</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>default</id>
+ <goals>
+ <goal>perform</goal>
+ </goals>
+ <configuration>
+ <pomFileName>java/pom.xml</pomFileName>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
-</project> \ No newline at end of file
+</project>
diff --git a/java/src/main/c++/vw_VWScorer.cc b/java/src/main/c++/vw_VWScorer.cc
index 652d722b..dce1869e 100644
--- a/java/src/main/c++/vw_VWScorer.cc
+++ b/java/src/main/c++/vw_VWScorer.cc
@@ -4,13 +4,11 @@
vw* vw;
-JNIEXPORT void JNICALL Java_vw_VWScorer_initialize
- (JNIEnv *env, jobject obj, jstring command) {
+JNIEXPORT void JNICALL Java_vw_VWScorer_initialize (JNIEnv *env, jobject obj, jstring command) {
vw = VW::initialize(env->GetStringUTFChars(command, NULL));
}
-JNIEXPORT jfloat JNICALL Java_vw_VWScorer_getPrediction
- (JNIEnv *env, jobject obj, jstring example_string) {
+JNIEXPORT jfloat JNICALL Java_vw_VWScorer_getPrediction (JNIEnv *env, jobject obj, jstring example_string) {
example *vec2 = VW::read_example(*vw, env->GetStringUTFChars(example_string, NULL));
vw->l->predict(*vec2);
float prediction;
@@ -18,7 +16,7 @@ JNIEXPORT jfloat JNICALL Java_vw_VWScorer_getPrediction
prediction = vec2->pred.scalar;
else
prediction = vec2->pred.multiclass;
- VW::finish_example(*vw, vec2);
+ VW::finish_example(*vw, vec2);
return prediction;
}
diff --git a/java/src/test/java/vw/VWScorerTest.java b/java/src/test/java/vw/VWScorerTest.java
index 740fefce..05b6ae61 100644
--- a/java/src/test/java/vw/VWScorerTest.java
+++ b/java/src/test/java/vw/VWScorerTest.java
@@ -3,6 +3,8 @@ package vw;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.IOException;
+
import static org.junit.Assert.assertEquals;
/**
@@ -12,19 +14,23 @@ public class VWScorerTest {
private static VWScorer scorer;
@BeforeClass
- public static void setup() {
- scorer = new VWScorer("-i src/test/resources/house.model --quiet -t");
+ public static void setup() throws IOException, InterruptedException {
+ // Since we want this test to continue to work between VW changes, we can't store the model
+ // Instead, we'll make a new model for each test
+ String vwModel = "target/house.model";
+ Runtime.getRuntime().exec("../vowpalwabbit/vw -d src/test/resources/house.vw -f " + vwModel).waitFor();
+ scorer = new VWScorer("--quiet -t -i " + vwModel);
}
@Test
public void testBlank() {
float prediction = scorer.getPrediction("| ");
- assertEquals(0.07496, prediction, 0.00001);
+ assertEquals(0.075, prediction, 0.001);
}
@Test
public void testLine() {
float prediction = scorer.getPrediction("| price:0.23 sqft:0.25 age:0.05 2006");
- assertEquals(0.118467, prediction, 0.00001);
+ assertEquals(0.118, prediction, 0.001);
}
}
diff --git a/java/src/test/resources/house.model b/java/src/test/resources/house.model
deleted file mode 100644
index 20a3f310..00000000
--- a/java/src/test/resources/house.model
+++ /dev/null
Binary files differ
diff --git a/java/src/test/resources/house.vw b/java/src/test/resources/house.vw
new file mode 100644
index 00000000..87da95e5
--- /dev/null
+++ b/java/src/test/resources/house.vw
@@ -0,0 +1,3 @@
+0 | price:.23 sqft:.25 age:.05 2006
+1 2 'second_house | price:.18 sqft:.15 age:.35 1976
+0 1 0.5 'third_house | price:.53 sqft:.32 age:.87 1924