当前位置: 首页>>代码示例>>Java>>正文


Java Nature.nz方法代码示例

本文整理汇总了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;
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:20,代码来源:CRFSegment.java

示例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;
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:20,代码来源:CustomDictionary.java

示例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;
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:40,代码来源:AtomNode.java

示例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;
}
 
开发者ID:ml-distribution,项目名称:HanLP,代码行数:19,代码来源:CustomDictionary.java


注:本文中的com.hankcs.hanlp.corpus.tag.Nature.nz方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。