com.hankcs.hanlp.seg.common
类 Vertex

java.lang.Object
  继承者 com.hankcs.hanlp.seg.common.Vertex

public class Vertex
extends Object

顶点

作者:
hankcs

字段摘要
 CoreDictionary.Attribute attribute
          词的属性,谨慎修改属性内部的数据,因为会影响到字典
如果要修改,应当new一个Attribute
static Vertex B
          始##始
static Vertex E
          末##末
 Vertex from
          到该节点的最短路径的前驱节点
 int index
          在一维顶点数组中的下标,可以视作这个顶点的id
 String realWord
          节点对应的真实词,绝对不含##
 double weight
          最短路径对应的权重
 String word
          节点对应的词或等效词(如未##数)
 int wordID
          等效词ID,也是Attribute的下标
 
构造方法摘要
Vertex(char realWord, CoreDictionary.Attribute attribute)
           
Vertex(Map.Entry<String,CoreDictionary.Attribute> entry)
          通过一个键值对方便地构造节点
Vertex(String realWord)
          自动构造一个合理的顶点
Vertex(String realWord, CoreDictionary.Attribute attribute)
          真实词与编译词相同时候的构造函数
Vertex(String realWord, CoreDictionary.Attribute attribute, int wordID)
           
Vertex(String word, String realWord, CoreDictionary.Attribute attribute)
          最复杂的构造函数
Vertex(String word, String realWord, CoreDictionary.Attribute attribute, int wordID)
           
 
方法摘要
 boolean confirmNature(Nature nature)
          将属性的词性锁定为nature
 boolean confirmNature(Nature nature, boolean updateWord)
          将属性的词性锁定为nature,此重载会降低性能
 Vertex copy()
          复制自己
 CoreDictionary.Attribute getAttribute()
          获取词的属性
 Nature getNature()
          获取该节点的词性,如果词性还未确定,则返回null
 String getRealWord()
          获取真实词
 Nature guessNature()
          猜测最可能的词性,也就是这个节点的词性中出现频率最大的那一个词性
 boolean hasNature(Nature nature)
           
static Vertex newAddressInstance(String realWord)
          创建一个地名实例
static Vertex newB()
          生成线程安全的起始节点
static Vertex newE()
          生成线程安全的终止节点
static Vertex newJapanesePersonInstance(String realWord, int frequency)
          创建一个日本人名实例
static Vertex newNumberInstance(String realWord)
          创建一个数词实例
static Vertex newOrganizationInstance(String realWord, int frequency)
          创建一个机构名实例
static Vertex newPersonInstance(String realWord)
          创建一个人名实例
static Vertex newPersonInstance(String realWord, int frequency)
          创建一个人名实例
static Vertex newPlaceInstance(String realWord, int frequency)
          创建一个地名实例
static Vertex newPunctuationInstance(String realWord)
          创建一个标点符号实例
static Vertex newTimeInstance(String realWord)
          创建一个时间实例
static Vertex newTranslatedPersonInstance(String realWord, int frequency)
          创建一个音译人名实例
 Vertex setRealWord(String realWord)
           
 Vertex setWord(String word)
           
 String toString()
           
 void updateFrom(Vertex from)
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

word

public String word
节点对应的词或等效词(如未##数)


realWord

public String realWord
节点对应的真实词,绝对不含##


attribute

public CoreDictionary.Attribute attribute
词的属性,谨慎修改属性内部的数据,因为会影响到字典
如果要修改,应当new一个Attribute


wordID

public int wordID
等效词ID,也是Attribute的下标


index

public int index
在一维顶点数组中的下标,可以视作这个顶点的id


B

public static Vertex B
始##始


E

public static Vertex E
末##末


from

public Vertex from
到该节点的最短路径的前驱节点


weight

public double weight
最短路径对应的权重

构造方法详细信息

Vertex

public Vertex(String word,
              String realWord,
              CoreDictionary.Attribute attribute)
最复杂的构造函数

参数:
word - 编译后的词
realWord - 真实词
attribute - 属性

Vertex

public Vertex(String word,
              String realWord,
              CoreDictionary.Attribute attribute,
              int wordID)

Vertex

public Vertex(String realWord,
              CoreDictionary.Attribute attribute)
真实词与编译词相同时候的构造函数

参数:
realWord -
attribute -

Vertex

public Vertex(String realWord,
              CoreDictionary.Attribute attribute,
              int wordID)

Vertex

public Vertex(Map.Entry<String,CoreDictionary.Attribute> entry)
通过一个键值对方便地构造节点

参数:
entry -

Vertex

public Vertex(String realWord)
自动构造一个合理的顶点

参数:
realWord -

Vertex

public Vertex(char realWord,
              CoreDictionary.Attribute attribute)
方法详细信息

updateFrom

public void updateFrom(Vertex from)

getRealWord

public String getRealWord()
获取真实词

返回:

getAttribute

public CoreDictionary.Attribute getAttribute()
获取词的属性

返回:

confirmNature

public boolean confirmNature(Nature nature)
将属性的词性锁定为nature

参数:
nature - 词性
返回:
如果锁定词性在词性列表中,返回真,否则返回假

confirmNature

public boolean confirmNature(Nature nature,
                             boolean updateWord)
将属性的词性锁定为nature,此重载会降低性能

参数:
nature - 词性
updateWord - 是否更新预编译字串
返回:
如果锁定词性在词性列表中,返回真,否则返回假

getNature

public Nature getNature()
获取该节点的词性,如果词性还未确定,则返回null

返回:

guessNature

public Nature guessNature()
猜测最可能的词性,也就是这个节点的词性中出现频率最大的那一个词性

返回:

hasNature

public boolean hasNature(Nature nature)

copy

public Vertex copy()
复制自己

返回:
自己的备份

setWord

public Vertex setWord(String word)

setRealWord

public Vertex setRealWord(String realWord)

newNumberInstance

public static Vertex newNumberInstance(String realWord)
创建一个数词实例

参数:
realWord - 数字对应的真实字串
返回:
数词顶点

newAddressInstance

public static Vertex newAddressInstance(String realWord)
创建一个地名实例

参数:
realWord - 数字对应的真实字串
返回:
地名顶点

newPunctuationInstance

public static Vertex newPunctuationInstance(String realWord)
创建一个标点符号实例

参数:
realWord - 标点符号对应的真实字串
返回:
标点符号顶点

newPersonInstance

public static Vertex newPersonInstance(String realWord)
创建一个人名实例

参数:
realWord -
返回:

newTranslatedPersonInstance

public static Vertex newTranslatedPersonInstance(String realWord,
                                                 int frequency)
创建一个音译人名实例

参数:
realWord -
返回:

newJapanesePersonInstance

public static Vertex newJapanesePersonInstance(String realWord,
                                               int frequency)
创建一个日本人名实例

参数:
realWord -
返回:

newPersonInstance

public static Vertex newPersonInstance(String realWord,
                                       int frequency)
创建一个人名实例

参数:
realWord -
frequency -
返回:

newPlaceInstance

public static Vertex newPlaceInstance(String realWord,
                                      int frequency)
创建一个地名实例

参数:
realWord -
frequency -
返回:

newOrganizationInstance

public static Vertex newOrganizationInstance(String realWord,
                                             int frequency)
创建一个机构名实例

参数:
realWord -
frequency -
返回:

newTimeInstance

public static Vertex newTimeInstance(String realWord)
创建一个时间实例

参数:
realWord - 时间对应的真实字串
返回:
时间顶点

newB

public static Vertex newB()
生成线程安全的起始节点

返回:

newE

public static Vertex newE()
生成线程安全的终止节点

返回:

toString

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


Copyright © 2014–2015 码农场. All rights reserved.