public abstract class AbstractClassifier extends Object implements IClassifier
| Constructor and Description |
|---|
AbstractClassifier() |
| Modifier and Type | Method and Description |
|---|---|
String |
classify(Document document)
预测最可能的分类
|
String |
classify(String text)
使用一个训练出来的分类器来预测分类
|
IClassifier |
enableProbability(boolean enable)
是否归一化分值为概率
|
int |
label(Document document)
预测最可能的分类
|
Map<String,Double> |
predict(Document document)
预测分类
|
void |
train(Map<String,String[]> trainingDataSet)
训练模型
|
void |
train(String folderPath)
用UTF-8编码的语料训练模型
|
void |
train(String folderPath,
String charsetName)
训练模型
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcategorize, getModel, predict, trainpublic IClassifier enableProbability(boolean enable)
IClassifierenableProbability in interface IClassifierpublic String classify(String text) throws IllegalArgumentException, IllegalStateException
classify in interface IClassifiertext - IllegalArgumentExceptionIllegalStateExceptionpublic String classify(Document document) throws IllegalArgumentException, IllegalStateException
IClassifierclassify in interface IClassifierdocument - 一个结构化的文档(注意!这是一个底层数据结构,请谨慎操作)IllegalArgumentExceptionIllegalStateExceptionpublic void train(String folderPath, String charsetName) throws IOException
IClassifiertrain in interface IClassifierfolderPath - 分类语料的根目录.目录必须满足如下结构:charsetName - 文件编码IOException - 任何可能的IO异常public void train(Map<String,String[]> trainingDataSet) throws IllegalArgumentException
IClassifiertrain in interface IClassifiertrainingDataSet - 训练数据集,用Map储存.键是分类名,值是一个数组,数组中每个元素都是一篇文档的内容.IllegalArgumentExceptionpublic void train(String folderPath) throws IOException
IClassifiertrain in interface IClassifierfolderPath - 用UTF-8编码的分类语料的根目录.目录必须满足如下结构:IOException - 任何可能的IO异常public Map<String,Double> predict(Document document)
IClassifierpredict in interface IClassifierpublic int label(Document document) throws IllegalArgumentException, IllegalStateException
IClassifierlabel in interface IClassifierIllegalArgumentExceptionIllegalStateExceptionCopyright © 2014–2021 码农场. All rights reserved.