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:
authorJon Morra <jmorra@eharmony.com>2015-01-03 01:22:30 +0300
committerJon Morra <jmorra@eharmony.com>2015-01-03 01:22:30 +0300
commit08a83933773ae82e7d09200a75b8e2060936cf7c (patch)
treebb67d7576ae34f4467e9fe0e738bcda626da39b0
parent3e5b900b9af92a38147cda35f138c349b790ea90 (diff)
Merging latest changes into repo and making Java tests pass. Also fixed a bug where the vw native library wasn't properly packaged into the jar file.
-rw-r--r--.travis.yml2
-rw-r--r--java/pom.xml28
-rw-r--r--java/src/main/c++/vw_VWScorer.cc8
-rw-r--r--java/src/test/java/vw/VWScorerTest.java10
-rw-r--r--java/src/test/resources/house.modelbin101 -> 0 bytes
-rw-r--r--java/src/test/resources/house.vw3
6 files changed, 16 insertions, 35 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/java/pom.xml b/java/pom.xml
index 628535b2..db48a576 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -4,35 +4,9 @@
<groupId>vw</groupId>
<artifactId>vw-jni-${os.version}-${os.arch}</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<name>Vowpal Wabbit JNI Layer</name>
- <scm>
- <connection>scm:git:git@github.com:elevatedcareers/vowpal_wabbit.git</connection>
- <url>git@github.com:elevatedcareers/vowpal_wabbit.git</url>
- <developerConnection>scm:git:git@github.com:elevatedcareers/vowpal_wabbit.git</developerConnection>
- <tag>HEAD</tag>
- </scm>
-
- <distributionManagement>
- <!-- use the following if you're not using a snapshot version. -->
- <repository>
- <uniqueVersion>false</uniqueVersion>
- <id>releases</id>
- <name>Internal Releases</name>
- <url>http://nexus.elevatedcareers.com:8081/nexus/content/repositories/releases</url>
- <layout>default</layout>
- </repository>
-
- <!-- use the following if you ARE using a snapshot version. -->
- <snapshotRepository>
- <id>snapshots</id>
- <name>Internal Snapshots</name>
- <url>http://nexus.elevatedcareers.com:8081/nexus/content/repositories/snapshots</url>
- <layout>default</layout>
- </snapshotRepository>
- </distributionManagement>
-
<properties>
<slf4j.version>1.7.6</slf4j.version>
<junit.version>4.11</junit.version>
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..887e3062 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,8 +14,12 @@ 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
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