com.hankcs.hanlp.collection.AhoCorasick
类 State

java.lang.Object
  继承者 com.hankcs.hanlp.collection.AhoCorasick.State

public class State
extends Object

一个状态有如下几个功能

根节点稍有不同,根节点没有 failure 功能,它的“failure”指的是按照字符串路径转移到下一个状态。其他节点则都有failure状态。

作者:
Robert Bor

字段摘要
protected  int depth
          模式串的长度,也是这个状态的深度
 
构造方法摘要
State()
          构造深度为0的节点
State(int depth)
          构造深度为depth的节点
 
方法摘要
 void addEmit(Collection<Integer> emits)
          添加一些匹配到的模式串
 void addEmit(int keyword)
          添加一个匹配到的模式串(这个状态对应着这个模式串)
 State addState(Character character)
           
 Collection<Integer> emit()
          获取这个节点代表的模式串(们)
 State failure()
          获取failure状态
 int getDepth()
          获取节点深度
 int getIndex()
           
 Integer getLargestValueId()
          获取最大的值
 Collection<State> getStates()
           
 Map<Character,State> getSuccess()
          获取goto表
 Collection<Character> getTransitions()
           
 boolean isAcceptable()
          是否是终止状态
 State nextState(Character character)
          按照character转移,根节点转移失败会返回自己(永远不会返回null)
 State nextStateIgnoreRootState(Character character)
          按照character转移,任何节点转移失败会返回null
 void setFailure(State failState, int[] fail)
          设置failure状态
 void setIndex(int index)
           
 String toString()
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

depth

protected final int depth
模式串的长度,也是这个状态的深度

构造方法详细信息

State

public State()
构造深度为0的节点


State

public State(int depth)
构造深度为depth的节点

参数:
depth -
方法详细信息

getDepth

public int getDepth()
获取节点深度

返回:

addEmit

public void addEmit(int keyword)
添加一个匹配到的模式串(这个状态对应着这个模式串)

参数:
keyword -

getLargestValueId

public Integer getLargestValueId()
获取最大的值

返回:

addEmit

public void addEmit(Collection<Integer> emits)
添加一些匹配到的模式串

参数:
emits -

emit

public Collection<Integer> emit()
获取这个节点代表的模式串(们)

返回:

isAcceptable

public boolean isAcceptable()
是否是终止状态

返回:

failure

public State failure()
获取failure状态

返回:

setFailure

public void setFailure(State failState,
                       int[] fail)
设置failure状态

参数:
failState -

nextState

public State nextState(Character character)
按照character转移,根节点转移失败会返回自己(永远不会返回null)

参数:
character -
返回:

nextStateIgnoreRootState

public State nextStateIgnoreRootState(Character character)
按照character转移,任何节点转移失败会返回null

参数:
character -
返回:

addState

public State addState(Character character)

getStates

public Collection<State> getStates()

getTransitions

public Collection<Character> getTransitions()

toString

public String toString()
覆盖:
Object 中的 toString

getSuccess

public Map<Character,State> getSuccess()
获取goto表

返回:

getIndex

public int getIndex()

setIndex

public void setIndex(int index)


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