本文整理汇总了Java中com.hankcs.hanlp.corpus.tag.Nature.nz方法的典型用法代码示例。如果您正苦于以下问题:Java Nature.nz方法的具体用法?Java Nature.nz怎么用?Java Nature.nz使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hankcs.hanlp.corpus.tag.Nature
的用法示例。
在下文中一共展示了Nature.nz方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toVertexList
import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
private static List<Vertex> toVertexList(List<Term> termList, boolean appendStart)
{
ArrayList<Vertex> vertexList = new ArrayList<Vertex>(termList.size() + 1);
if (appendStart) vertexList.add(Vertex.B);
for (Term term : termList)
{
CoreDictionary.Attribute attribute = CoreDictionary.get(term.word);
if (attribute == null)
{
if (term.word.trim().length() == 0) attribute = new CoreDictionary.Attribute(Nature.x);
else attribute = new CoreDictionary.Attribute(Nature.nz);
}
else term.nature = attribute.nature[0];
Vertex vertex = new Vertex(term.word, attribute);
vertexList.add(vertex);
}
return vertexList;
}
示例2: insert
import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
/**
* 往自定义词典中插入一个新词(覆盖模式)<br>
* 动态增删不会持久化到词典文件
*
* @param word 新词 如“裸婚”
* @param natureWithFrequency 词性和其对应的频次,比如“nz 1 v 2”,null时表示“nz 1”。
* @return 是否插入成功(失败的原因可能是natureWithFrequency问题,可以通过调试模式了解原因)
*/
public static boolean insert(String word, String natureWithFrequency)
{
if (word == null) return false;
if (HanLP.Config.Normalization) word = CharTable.convert(word);
CoreDictionary.Attribute att = natureWithFrequency == null ? new CoreDictionary.Attribute(Nature.nz, 1) : CoreDictionary.Attribute.create(natureWithFrequency);
if (att == null) return false;
if (dat.set(word, att)) return true;
if (trie == null) trie = new BinTrie<CoreDictionary.Attribute>();
trie.put(word, att);
return true;
}
示例3: getNature
import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
/**
* 原子的词性
* @return
*/
public Nature getNature()
{
Nature nature = Nature.nz;
switch (nPOS)
{
case Predefine.CT_CHINESE:
break;
case Predefine.CT_INDEX:
case Predefine.CT_NUM:
nature = Nature.m;
sWord = "未##数";
break;
case Predefine.CT_DELIMITER:
nature = Nature.w;
break;
case Predefine.CT_LETTER:
nature = Nature.nx;
sWord = "未##串";
break;
case Predefine.CT_SINGLE://12021-2129-3121
if (Predefine.PATTERN_FLOAT_NUMBER.matcher(sWord).matches())//匹配浮点数
{
nature = Nature.m;
sWord = "未##数";
} else
{
nature = Nature.nx;
sWord = "未##串";
}
break;
default:
break;
}
return nature;
}
示例4: insert
import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
/**
* 往自定义词典中插入一个新词(覆盖模式)
*
* @param word 新词 如“裸婚”
* @param natureWithFrequency 词性和其对应的频次,比如“nz 1 v 2”,null时表示“nz 1”。
* @return 是否插入成功(失败的原因可能是natureWithFrequency问题,可以通过调试模式了解原因)
*/
public static boolean insert(String word, String natureWithFrequency)
{
if (word == null) return false;
if (HanLP.Config.Normalization) word = CharTable.convert(word);
CoreDictionary.Attribute att = natureWithFrequency == null ? new CoreDictionary.Attribute(Nature.nz, 1) : CoreDictionary.Attribute.create(natureWithFrequency);
if (att == null) return false;
if (dat.set(word, att)) return true;
if (trie == null) trie = new BinTrie<CoreDictionary.Attribute>();
trie.put(word, att);
return true;
}