public class Vertex extends Object
| Modifier and Type | Field and Description |
|---|---|
CoreDictionary.Attribute |
attribute
词的属性,谨慎修改属性内部的数据,因为会影响到字典
如果要修改,应当new一个Attribute |
Vertex |
from
到该节点的最短路径的前驱节点
|
int |
index
在一维顶点数组中的下标,可以视作这个顶点的id
|
String |
realWord
节点对应的真实词,绝对不含##
|
double |
weight
最短路径对应的权重
|
String |
word
节点对应的词或等效词(如未##数)
|
int |
wordID
等效词ID,也是Attribute的下标
|
| Constructor and Description |
|---|
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) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
confirmNature(Nature nature)
将属性的词性锁定为nature
|
boolean |
confirmNature(Nature nature,
boolean updateWord)
将属性的词性锁定为nature,此重载会降低性能
|
Vertex |
copy()
复制自己
|
CoreDictionary.Attribute |
getAttribute()
获取词的属性
|
Vertex |
getFrom() |
Nature |
getNature()
获取该节点的词性,如果词性还未确定,则返回null
|
String |
getRealWord()
获取真实词
|
Nature |
guessNature()
猜测最可能的词性,也就是这个节点的词性中出现频率最大的那一个词性
|
boolean |
hasNature(Nature nature) |
int |
length() |
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)
创建一个音译人名实例
|
void |
setFrom(Vertex from) |
Vertex |
setRealWord(String realWord) |
Vertex |
setWord(String word) |
String |
toString() |
void |
updateFrom(Vertex from) |
public String word
public String realWord
public CoreDictionary.Attribute attribute
public int wordID
public int index
public Vertex from
public double weight
public Vertex(String word, String realWord, CoreDictionary.Attribute attribute)
word - 编译后的词realWord - 真实词attribute - 属性public Vertex(String word, String realWord, CoreDictionary.Attribute attribute, int wordID)
public Vertex(String realWord, CoreDictionary.Attribute attribute)
realWord - attribute - public Vertex(String realWord, CoreDictionary.Attribute attribute, int wordID)
public Vertex(Map.Entry<String,CoreDictionary.Attribute> entry)
entry - public Vertex(String realWord)
realWord - public Vertex(char realWord,
CoreDictionary.Attribute attribute)
public void updateFrom(Vertex from)
public String getRealWord()
public Vertex getFrom()
public void setFrom(Vertex from)
public CoreDictionary.Attribute getAttribute()
public boolean confirmNature(Nature nature)
nature - 词性public boolean confirmNature(Nature nature, boolean updateWord)
nature - 词性updateWord - 是否更新预编译字串public Nature getNature()
public Nature guessNature()
public boolean hasNature(Nature nature)
public Vertex copy()
public static Vertex newNumberInstance(String realWord)
realWord - 数字对应的真实字串public static Vertex newAddressInstance(String realWord)
realWord - 数字对应的真实字串public static Vertex newPunctuationInstance(String realWord)
realWord - 标点符号对应的真实字串public static Vertex newPersonInstance(String realWord)
realWord - public static Vertex newTranslatedPersonInstance(String realWord, int frequency)
realWord - public static Vertex newJapanesePersonInstance(String realWord, int frequency)
realWord - public static Vertex newPersonInstance(String realWord, int frequency)
realWord - frequency - public static Vertex newPlaceInstance(String realWord, int frequency)
realWord - frequency - public static Vertex newOrganizationInstance(String realWord, int frequency)
realWord - frequency - public static Vertex newTimeInstance(String realWord)
realWord - 时间对应的真实字串public static Vertex newB()
public static Vertex newE()
public int length()
Copyright © 2014–2021 码农场. All rights reserved.