mirror of https://github.com/apache/lucene.git
LUCENE-6045 - refactored BPC constructor to be more consistent with others
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1679005 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3111aeab0e
commit
dfede4285c
|
@ -68,18 +68,18 @@ public class BooleanPerceptronClassifier implements Classifier<Boolean> {
|
|||
* Creates a {@link BooleanPerceptronClassifier}
|
||||
*
|
||||
* @param leafReader the reader on the index to be used for classification
|
||||
* @param textFieldName the name of the field used as input for the classifier
|
||||
* @param classFieldName the name of the field used as the output for the classifier
|
||||
* @param analyzer an {@link Analyzer} used to analyze unseen text
|
||||
* @param query a {@link Query} to eventually filter the docs used for training the classifier, or {@code null}
|
||||
* if all the indexed docs should be used
|
||||
* @param batchSize the size of the batch of docs to use for updating the perceptron weights
|
||||
* @param threshold the threshold used for class separation
|
||||
* @param classFieldName the name of the field used as the output for the classifier
|
||||
* @param textFieldName the name of the field used as input for the classifier
|
||||
* @throws IOException if the building of the underlying {@link FST} fails and / or {@link TermsEnum} for the text field
|
||||
* cannot be found
|
||||
*/
|
||||
public BooleanPerceptronClassifier(LeafReader leafReader, String textFieldName, String classFieldName, Analyzer analyzer,
|
||||
Query query, Integer batchSize, Double threshold) throws IOException {
|
||||
public BooleanPerceptronClassifier(LeafReader leafReader, Analyzer analyzer, Query query, Integer batchSize,
|
||||
Double threshold, String classFieldName, String textFieldName) throws IOException {
|
||||
this.textTerms = MultiFields.getTerms(leafReader, textFieldName);
|
||||
|
||||
if (textTerms == null) {
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.lucene.classification;
|
|||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.SlowCompositeReaderWrapper;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.junit.Test;
|
||||
|
@ -34,7 +33,7 @@ public class BooleanPerceptronClassifierTest extends ClassificationTestBase<Bool
|
|||
try {
|
||||
MockAnalyzer analyzer = new MockAnalyzer(random());
|
||||
leafReader = populateSampleIndex(analyzer);
|
||||
checkCorrectClassification(new BooleanPerceptronClassifier(leafReader, textFieldName, booleanFieldName, analyzer, null, 1, null), TECHNOLOGY_INPUT, false);
|
||||
checkCorrectClassification(new BooleanPerceptronClassifier(leafReader, analyzer, null, 1, null, booleanFieldName, textFieldName), TECHNOLOGY_INPUT, false);
|
||||
} finally {
|
||||
if (leafReader != null) {
|
||||
leafReader.close();
|
||||
|
@ -48,7 +47,9 @@ public class BooleanPerceptronClassifierTest extends ClassificationTestBase<Bool
|
|||
try {
|
||||
MockAnalyzer analyzer = new MockAnalyzer(random());
|
||||
leafReader = populateSampleIndex(analyzer);
|
||||
checkCorrectClassification(new BooleanPerceptronClassifier(leafReader, textFieldName, booleanFieldName, analyzer, null, 1, 100d), TECHNOLOGY_INPUT, false);
|
||||
BooleanPerceptronClassifier classifier = new BooleanPerceptronClassifier(leafReader, analyzer, null, 1, 50d, booleanFieldName, textFieldName);
|
||||
checkCorrectClassification(classifier, TECHNOLOGY_INPUT, false);
|
||||
checkCorrectClassification(classifier, POLITICS_INPUT, true);
|
||||
} finally {
|
||||
if (leafReader != null) {
|
||||
leafReader.close();
|
||||
|
@ -63,7 +64,7 @@ public class BooleanPerceptronClassifierTest extends ClassificationTestBase<Bool
|
|||
try {
|
||||
MockAnalyzer analyzer = new MockAnalyzer(random());
|
||||
leafReader = populateSampleIndex(analyzer);
|
||||
checkCorrectClassification(new BooleanPerceptronClassifier(leafReader, textFieldName, booleanFieldName, analyzer, query, 1, null), TECHNOLOGY_INPUT, false);
|
||||
checkCorrectClassification(new BooleanPerceptronClassifier(leafReader, analyzer, query, 1, null, booleanFieldName, textFieldName), TECHNOLOGY_INPUT, false);
|
||||
} finally {
|
||||
if (leafReader != null) {
|
||||
leafReader.close();
|
||||
|
|
Loading…
Reference in New Issue