lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbern...@apache.org
Subject [2/3] lucene-solr:master: SOLR-9252: Feature selection and logistic regression on text
Date Wed, 03 Aug 2016 17:32:28 GMT
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/87938e00/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java
index 63baa01..4ddf4ce 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java
@@ -62,6 +62,8 @@ public class StreamExpressionToExpessionTest extends LuceneTestCase {
                     .withFunctionName("avg", MeanMetric.class)
                     .withFunctionName("daemon", DaemonStream.class)
                     .withFunctionName("topic", TopicStream.class)
+                    .withFunctionName("tlogit", TextLogitStream.class)
+                    .withFunctionName("featuresSelection", FeaturesSelectionStream.class)
                     ;
   }
     
@@ -138,7 +140,6 @@ public class StreamExpressionToExpessionTest extends LuceneTestCase {
     assertTrue(expressionString.contains("checkpointEvery=1000"));
   }
 
-
   @Test
   public void testStatsStream() throws Exception {
 
@@ -342,6 +343,40 @@ public class StreamExpressionToExpessionTest extends LuceneTestCase {
     assertTrue(firstExpressionString.contains("q=\"presentTitles:\\\"chief, executive officer\\\"
AND age:[36 TO *]\""));
     assertTrue(secondExpressionString.contains("q=\"presentTitles:\\\"chief, executive officer\\\"
AND age:[36 TO *]\""));
   }
+
+  @Test
+  public void testFeaturesSelectionStream() throws Exception {
+    String expr = "featuresSelection(collection1, q=\"*:*\", featureSet=\"first\", field=\"tv_text\",
outcome=\"out_i\", numTerms=4, positiveLabel=2)";
+    FeaturesSelectionStream stream = new FeaturesSelectionStream(StreamExpressionParser.parse(expr),
factory);
+    String expressionString = stream.toExpression(factory).toString();
+    assertTrue(expressionString.contains("q=\"*:*\""));
+    assertTrue(expressionString.contains("featureSet=first"));
+    assertTrue(expressionString.contains("field=tv_text"));
+    assertTrue(expressionString.contains("outcome=out_i"));
+    assertTrue(expressionString.contains("numTerms=4"));
+    assertTrue(expressionString.contains("positiveLabel=2"));
+  }
+
+  @Test
+  public void testTextLogitStreamWithFeaturesSelection() throws Exception {
+    String expr = "tlogit(" +
+        "collection1, " +
+        "q=\"*:*\", " +
+        "name=\"model\", " +
+        "featuresSelection(collection1, q=\"*:*\", featureSet=\"first\", field=\"tv_text\",
outcome=\"out_i\", numTerms=4), " +
+        "field=\"tv_text\", " +
+        "outcome=\"out_i\", " +
+        "maxIterations=100)";
+    TextLogitStream logitStream = new TextLogitStream(StreamExpressionParser.parse(expr),
factory);
+    String expressionString = logitStream.toExpression(factory).toString();
+    assertTrue(expressionString.contains("q=\"*:*\""));
+    assertTrue(expressionString.contains("name=model"));
+    assertFalse(expressionString.contains("terms="));
+    assertTrue(expressionString.contains("featuresSelection("));
+    assertTrue(expressionString.contains("field=tv_text"));
+    assertTrue(expressionString.contains("outcome=out_i"));
+    assertTrue(expressionString.contains("maxIterations=100"));
+  }
   
   @Test
   public void testCountMetric() throws Exception {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/87938e00/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExplanationTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExplanationTest.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExplanationTest.java
index f8765c9..91cab3d 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExplanationTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExplanationTest.java
@@ -17,7 +17,6 @@
 package org.apache.solr.client.solrj.io.stream;
 
 import junit.framework.Assert;
-
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.client.solrj.io.ops.GroupOperation;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation;


Mime
View raw message