public class KNearestFuzzyClassifier extends Object implements Classifier<BytesRef>
NearestFuzzyQuery
.Constructor and Description |
---|
KNearestFuzzyClassifier(IndexReader indexReader,
Similarity similarity,
Analyzer analyzer,
Query query,
int k,
String classFieldName,
String... textFieldNames)
Creates a
KNearestFuzzyClassifier . |
Modifier and Type | Method and Description |
---|---|
ClassificationResult<BytesRef> |
assignClass(String text)
Assign a class (with score) to the given text String
|
List<ClassificationResult<BytesRef>> |
getClasses(String text)
Get all the classes (sorted by score, descending) assigned to the given text String.
|
List<ClassificationResult<BytesRef>> |
getClasses(String text,
int max)
Get the first
max classes (sorted by score, descending) assigned to the given text String. |
String |
toString() |
public KNearestFuzzyClassifier(IndexReader indexReader, Similarity similarity, Analyzer analyzer, Query query, int k, String classFieldName, String... textFieldNames)
KNearestFuzzyClassifier
.indexReader
- the reader on the index to be used for classificationanalyzer
- an Analyzer
used to analyze unseen textsimilarity
- the Similarity
to be used by the underlying IndexSearcher
or null
(defaults to BM25Similarity
)query
- a Query
to eventually filter the docs used for training the classifier, or null
if all the indexed docs should be usedk
- the no. of docs to select in the MLT results to find the nearest neighborclassFieldName
- the name of the field used as the output for the classifiertextFieldNames
- the name of the fields used as the inputs for the classifier, they can contain boosting indication e.g. title^10public ClassificationResult<BytesRef> assignClass(String text) throws IOException
assignClass
in interface Classifier<BytesRef>
text
- a String containing text to be classifiedClassificationResult
holding assigned class of type T
and scoreIOException
- If there is a low-level I/O error.public List<ClassificationResult<BytesRef>> getClasses(String text) throws IOException
getClasses
in interface Classifier<BytesRef>
text
- a String containing text to be classifiedClassificationResult
, the classes and scores. Returns null
if the classifier can't make lists.IOException
- If there is a low-level I/O error.public List<ClassificationResult<BytesRef>> getClasses(String text, int max) throws IOException
max
classes (sorted by score, descending) assigned to the given text String.getClasses
in interface Classifier<BytesRef>
text
- a String containing text to be classifiedmax
- the number of return list elementsClassificationResult
, the classes and scores. Cut for "max" number of elements. Returns null
if the classifier can't make lists.IOException
- If there is a low-level I/O error.Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.