本文整理汇总了Java中com.hankcs.hanlp.corpus.tag.Nature.n方法的典型用法代码示例。如果您正苦于以下问题:Java Nature.n方法的具体用法?Java Nature.n怎么用?Java Nature.n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hankcs.hanlp.corpus.tag.Nature
的用法示例。
在下文中一共展示了Nature.n方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
/**
* 添加顶点,由原子分词顶点添加
*
* @param line
* @param atomSegment
*/
public void add(int line, List<AtomNode> atomSegment)
{
// 将原子部分存入m_segGraph
int offset = 0;
for (AtomNode atomNode : atomSegment)//Init the cost array
{
String sWord = atomNode.sWord;//init the word
Nature nature = Nature.n;
int id = -1;
switch (atomNode.nPOS)
{
case Predefine.CT_CHINESE:
break;
case Predefine.CT_INDEX:
case Predefine.CT_NUM:
nature = Nature.m;
sWord = "未##数";
id = CoreDictionary.M_WORD_ID;
break;
case Predefine.CT_DELIMITER:
case Predefine.CT_OTHER:
nature = Nature.w;
break;
case Predefine.CT_SINGLE://12021-2129-3121
nature = Nature.nx;
sWord = "未##串";
id = CoreDictionary.X_WORD_ID;
break;
default:
break;
}
// 这些通用符的量级都在10万左右
add(line + offset, new Vertex(sWord, atomNode.sWord, new CoreDictionary.Attribute(nature, 10000), id));
offset += atomNode.sWord.length();
}
}
示例2: convert
import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
public static Vertex convert(String word, int type)
{
String name = word;
Nature nature = Nature.n;
int dValue = 1;
switch (type)
{
case Predefine.CT_CHINESE:
break;
case Predefine.CT_INDEX:
case Predefine.CT_NUM:
nature = Nature.m;
word = "未##数";
break;
case Predefine.CT_DELIMITER:
nature = Nature.w;
break;
case Predefine.CT_LETTER:
nature = Nature.nx;
word = "未##串";
break;
case Predefine.CT_SINGLE://12021-2129-3121
// if (Pattern.compile("^(-?\\d+)(\\.\\d+)?$").matcher(word).matches())//匹配浮点数
// {
// nature = Nature.m;
// word = "未##数";
// } else
// {
nature = Nature.nx;
word = "未##串";
// }
break;
default:
break;
}
return new Vertex(word, name, new CoreDictionary.Attribute(nature, dValue));
}
示例3: add
import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
/**
* 添加顶点,由原子分词顶点添加
*
* @param line
* @param atomSegment
*/
public void add(int line, List<AtomNode> atomSegment)
{
// 将原子部分存入m_segGraph
int offset = 0;
for (AtomNode atomNode : atomSegment)//Init the cost array
{
String sWord = atomNode.sWord;//init the word
Nature nature = Nature.n;
switch (atomNode.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
nature = Nature.nx;
sWord = "未##串";
break;
default:
break;
}
add(line + offset, new Vertex(sWord, atomNode.sWord, new CoreDictionary.Attribute(nature, 1)));
offset += atomNode.sWord.length();
}
}