com.hankcs.hanlp.model.crf
类 CRFModel

java.lang.Object
  继承者 com.hankcs.hanlp.model.crf.CRFModel
所有已实现的接口:
ICacheAble
直接已知子类:
CRFSegmentModel

public class CRFModel
extends Object
implements ICacheAble

作者:
hankcs

字段摘要
protected  String[] id2tag
          id转标签
protected  double[][] matrix
          tag的二元转移矩阵,适用于BiGram Feature
 
构造方法摘要
CRFModel()
           
CRFModel(ITrie<FeatureFunction> featureFunctionTrie)
          以指定的trie树结构储存内部特征函数
 
方法摘要
protected static double computeScore(LinkedList<double[]> scoreList, int tag)
          给一系列特征函数结合tag打分
protected  LinkedList<double[]> computeScoreList(Table table, int current)
          根据特征函数计算输出
 Integer getTagId(String tag)
          获取某个tag的ID
 boolean load(ByteArray byteArray)
          载入
static CRFModel load(String path)
          加载CRF++模型
如果存在缓存的话,优先读取缓存,否则读取txt,并且建立缓存
static CRFModel loadBin(String path)
          加载Bin形式的CRF++模型
static CRFModel loadTxt(String path)
          加载Txt形式的CRF++模型
同时生成path.bin模型缓存
static CRFModel loadTxt(String path, CRFModel instance)
          加载Txt形式的CRF++模型
protected  void onLoadTxtFinished()
           
 void save(DataOutputStream out)
          写入
 void tag(Table table)
          维特比后向算法标注
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

id2tag

protected String[] id2tag
id转标签


matrix

protected double[][] matrix
tag的二元转移矩阵,适用于BiGram Feature

构造方法详细信息

CRFModel

public CRFModel()

CRFModel

public CRFModel(ITrie<FeatureFunction> featureFunctionTrie)
以指定的trie树结构储存内部特征函数

参数:
featureFunctionTrie -
方法详细信息

onLoadTxtFinished

protected void onLoadTxtFinished()

loadTxt

public static CRFModel loadTxt(String path,
                               CRFModel instance)
加载Txt形式的CRF++模型

参数:
path - 模型路径
instance - 模型的实例(这里允许用户构造不同的CRFModel来储存最终读取的结果)
返回:
该模型

tag

public void tag(Table table)
维特比后向算法标注

参数:
table -

computeScoreList

protected LinkedList<double[]> computeScoreList(Table table,
                                                int current)
根据特征函数计算输出

参数:
table -
current -
返回:

computeScore

protected static double computeScore(LinkedList<double[]> scoreList,
                                     int tag)
给一系列特征函数结合tag打分

参数:
scoreList -
tag -
返回:

save

public void save(DataOutputStream out)
          throws Exception
从接口 ICacheAble 复制的描述
写入

指定者:
接口 ICacheAble 中的 save
抛出:
Exception

load

public boolean load(ByteArray byteArray)
从接口 ICacheAble 复制的描述
载入

指定者:
接口 ICacheAble 中的 load
返回:

loadTxt

public static CRFModel loadTxt(String path)
加载Txt形式的CRF++模型
同时生成path.bin模型缓存

参数:
path - 模型路径
返回:
该模型

load

public static CRFModel load(String path)
加载CRF++模型
如果存在缓存的话,优先读取缓存,否则读取txt,并且建立缓存

参数:
path - txt的路径,即使不存在.txt,只存在.bin,也应传入txt的路径,方法内部会自动加.bin后缀
返回:

loadBin

public static CRFModel loadBin(String path)
加载Bin形式的CRF++模型

参数:
path -
返回:

getTagId

public Integer getTagId(String tag)
获取某个tag的ID

参数:
tag -
返回:


Copyright © 2014–2015 鐮佸啘鍦�/a>. All rights reserved.