本文整理汇总了Java中com.hankcs.hanlp.utility.Predefine.TAG_NUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java Predefine.TAG_NUMBER属性的具体用法?Java Predefine.TAG_NUMBER怎么用?Java Predefine.TAG_NUMBER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.hankcs.hanlp.utility.Predefine
的用法示例。
在下文中一共展示了Predefine.TAG_NUMBER属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: confirmNature
/**
* 将属性的词性锁定为nature,此重载会降低性能
*
* @param nature
* 词性
* @param updateWord
* 是否更新预编译字串
* @return 如果锁定词性在词性列表中,返回真,否则返回假
*/
public boolean confirmNature(Nature nature, boolean updateWord) {
switch (nature) {
case m:
word = Predefine.TAG_NUMBER;
break;
case t:
word = Predefine.TAG_TIME;
break;
default:
logger.warning("没有与" + nature + "对应的case");
break;
}
return confirmNature(nature);
}
示例2: confirmNature
/**
* 将属性的词性锁定为nature,此重载会降低性能
*
* @param nature 词性
* @param updateWord 是否更新预编译字串
* @return 如果锁定词性在词性列表中,返回真,否则返回假
*/
public boolean confirmNature(Nature nature, boolean updateWord)
{
switch (nature)
{
case m:
word = Predefine.TAG_NUMBER;
break;
case t:
word = Predefine.TAG_TIME;
break;
default:
logger.warning("没有与" + nature + "对应的case");
break;
}
return confirmNature(nature);
}
示例3: compile
/**
* 编译,比如将词性为数词的转为##数##
* @param tag 标签
* @param name 原词
* @return 编译后的等效词
*/
public static String compile(String tag, String name)
{
if (tag.startsWith("m")) return Predefine.TAG_NUMBER;
else if (tag.startsWith("nr")) return Predefine.TAG_PEOPLE;
else if (tag.startsWith("ns")) return Predefine.TAG_PLACE;
else if (tag.startsWith("nt")) return Predefine.TAG_GROUP;
else if (tag.startsWith("t")) return Predefine.TAG_TIME;
else if (tag.equals("x")) return Predefine.TAG_CLUSTER;
else if (tag.equals("nx")) return Predefine.TAG_PROPER;
else if (tag.equals("xx")) return Predefine.TAG_OTHER;
// switch (tag)
// {
// case "m":
// case "mq":
// return Predefine.TAG_NUMBER;
// case "nr":
// case "nr1":
// case "nr2":
// case "nrf":
// case "nrj":
// return Predefine.TAG_PEOPLE;
// case "ns":
// case "nsf":
// return Predefine.TAG_PLACE;
// case "nt":
// return Predefine.TAG_TIME;
// case "x":
// return Predefine.TAG_CLUSTER;
// case "nx":
// return Predefine.TAG_PROPER;
// }
return name;
}
示例4: mergeNumberQuantifier
/**
* 合并数字
* @param termList
*/
protected void mergeNumberQuantifier(List<Vertex> termList, WordNet wordNetAll, Config config)
{
if (termList.size() < 4) return;
StringBuilder sbQuantifier = new StringBuilder();
ListIterator<Vertex> iterator = termList.listIterator();
iterator.next();
int line = 1;
while (iterator.hasNext())
{
Vertex pre = iterator.next();
if (pre.hasNature(Nature.m))
{
sbQuantifier.append(pre.realWord);
Vertex cur = null;
while (iterator.hasNext() && (cur = iterator.next()).hasNature(Nature.m))
{
sbQuantifier.append(cur.realWord);
iterator.remove();
removeFromWordNet(cur, wordNetAll, line, sbQuantifier.length());
}
if (cur != null)
{
if ((cur.hasNature(Nature.q) || cur.hasNature(Nature.qv) || cur.hasNature(Nature.qt)))
{
if (config.indexMode)
{
wordNetAll.add(line, new Vertex(sbQuantifier.toString(), new CoreDictionary.Attribute(Nature.m)));
}
sbQuantifier.append(cur.realWord);
iterator.remove();
removeFromWordNet(cur, wordNetAll, line, sbQuantifier.length());
}
else
{
line += cur.realWord.length(); // (cur = iterator.next()).hasNature(Nature.m) 最后一个next可能不含q词性
}
}
if (sbQuantifier.length() != pre.realWord.length())
{
pre.realWord = sbQuantifier.toString();
pre.word = Predefine.TAG_NUMBER;
pre.attribute = new CoreDictionary.Attribute(Nature.mq);
pre.wordID = CoreDictionary.M_WORD_ID;
sbQuantifier.setLength(0);
}
}
sbQuantifier.setLength(0);
line += pre.realWord.length();
}
// System.out.println(wordNetAll);
}
示例5: compileRealWord
/**
* 将原词转为等效词串
*
* @param realWord
* 原来的词
* @param attribute
* 等效词串
* @return
*/
private String compileRealWord(String realWord,
CoreDictionary.Attribute attribute) {
if (attribute.nature.length == 1) {
switch (attribute.nature[0]) {
case nr:
case nr1:
case nr2:
case nrf:
case nrj: {
wordID = CoreDictionary.NR_WORD_ID;
// this.attribute =
// CoreDictionary.get(CoreDictionary.NR_WORD_ID);
return Predefine.TAG_PEOPLE;
}
case ns:
case nsf: {
wordID = CoreDictionary.NS_WORD_ID;
// 在地名识别的时候,希望类似"河镇"的词语保持自己的词性,而不是未##地的词性
// this.attribute =
// CoreDictionary.get(CoreDictionary.NS_WORD_ID);
return Predefine.TAG_PLACE;
}
// case nz:
case nx: {
wordID = CoreDictionary.NX_WORD_ID;
this.attribute = CoreDictionary.get(CoreDictionary.NX_WORD_ID);
return Predefine.TAG_PROPER;
}
case nt:
case ntc:
case ntcf:
case ntcb:
case ntch:
case nto:
case ntu:
case nts:
case nth:
case nit: {
wordID = CoreDictionary.NT_WORD_ID;
// this.attribute =
// CoreDictionary.get(CoreDictionary.NT_WORD_ID);
return Predefine.TAG_GROUP;
}
case m:
case mq: {
wordID = CoreDictionary.M_WORD_ID;
this.attribute = CoreDictionary.get(CoreDictionary.M_WORD_ID);
return Predefine.TAG_NUMBER;
}
case x: {
wordID = CoreDictionary.X_WORD_ID;
this.attribute = CoreDictionary.get(CoreDictionary.X_WORD_ID);
return Predefine.TAG_CLUSTER;
}
// case xx:
// case w:
// {
// word= Predefine.TAG_OTHER;
// }
// break;
case t: {
wordID = CoreDictionary.T_WORD_ID;
this.attribute = CoreDictionary.get(CoreDictionary.T_WORD_ID);
return Predefine.TAG_TIME;
}
}
}
return realWord;
}
示例6: compileRealWord
/**
* 将原词转为等效词串
* @param realWord 原来的词
* @param attribute 等效词串
* @return
*/
private String compileRealWord(String realWord, CoreDictionary.Attribute attribute)
{
if (attribute.nature.length == 1)
{
switch (attribute.nature[0])
{
case nr:
case nr1:
case nr2:
case nrf:
case nrj:
{
wordID = CoreDictionary.NR_WORD_ID;
return Predefine.TAG_PEOPLE;
}
case ns:
case nsf:
{
wordID = CoreDictionary.NS_WORD_ID;
return Predefine.TAG_PLACE;
}
// case nz:
case nx:
{
wordID = CoreDictionary.NX_WORD_ID;
return Predefine.TAG_PROPER;
}
case nt:
case ntc:
case ntcf:
case ntcb:
case ntch:
case nto:
case ntu:
case nts:
case nth:
case nit:
{
wordID = CoreDictionary.NT_WORD_ID;
return Predefine.TAG_GROUP;
}
case m:
case mq:
{
wordID = CoreDictionary.M_WORD_ID;
return Predefine.TAG_NUMBER;
}
case x:
{
wordID = CoreDictionary.X_WORD_ID;
return Predefine.TAG_CLUSTER;
}
// case xx:
// case w:
// {
// word= Predefine.TAG_OTHER;
// }
// break;
case t:
{
wordID = CoreDictionary.T_WORD_ID;
return Predefine.TAG_TIME;
}
}
}
return realWord;
}
示例7: newNumberInstance
/**
* 创建一个数词实例
*
* @param realWord
* 数字对应的真实字串
* @return 数词顶点
*/
public static Vertex newNumberInstance(String realWord) {
return new Vertex(Predefine.TAG_NUMBER, realWord,
new CoreDictionary.Attribute(Nature.m, 1000));
}
示例8: newNumberInstance
/**
* 创建一个数词实例
*
* @param realWord 数字对应的真实字串
* @return 数词顶点
*/
public static Vertex newNumberInstance(String realWord)
{
return new Vertex(Predefine.TAG_NUMBER, realWord, new CoreDictionary.Attribute(Nature.m, 1000));
}