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


Java Nature.values方法代码示例

本文整理汇总了Java中com.hankcs.hanlp.corpus.tag.Nature.values方法的典型用法代码示例。如果您正苦于以下问题:Java Nature.values方法的具体用法?Java Nature.values怎么用?Java Nature.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hankcs.hanlp.corpus.tag.Nature的用法示例。


在下文中一共展示了Nature.values方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadDat

import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
/**
 * 从磁盘加载双数组
 *
 * @param path
 * @return
 */
static boolean loadDat(String path)
{
    try
    {
        ByteArray byteArray = ByteArray.createByteArray(path + Predefine.BIN_EXT);
        if (byteArray == null) return false;
        int size = byteArray.nextInt();
        CoreDictionary.Attribute[] attributes = new CoreDictionary.Attribute[size];
        final Nature[] natureIndexArray = Nature.values();
        for (int i = 0; i < size; ++i)
        {
            // 第一个是全部频次,第二个是词性个数
            int currentTotalFrequency = byteArray.nextInt();
            int length = byteArray.nextInt();
            attributes[i] = new CoreDictionary.Attribute(length);
            attributes[i].totalFrequency = currentTotalFrequency;
            for (int j = 0; j < length; ++j)
            {
                attributes[i].nature[j] = natureIndexArray[byteArray.nextInt()];
                attributes[i].frequency[j] = byteArray.nextInt();
            }
        }
        if (!trie.load(byteArray, attributes) || byteArray.hasMore()) return false;
    }
    catch (Exception e)
    {
        logger.warning("读取失败,问题发生在" + e);
        return false;
    }
    return true;
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:38,代码来源:CoreDictionary.java

示例2: loadDat

import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
/**
 * 从磁盘加载双数组
 *
 * @param path
 * @return
 */
static boolean loadDat(String path)
{
    try
    {
        ByteArray byteArray = ByteArray.createByteArray(path + Predefine.BIN_EXT);
        if (byteArray == null) return false;
        int size = byteArray.nextInt();
        if (size < 0)   // 一种兼容措施,当size小于零表示文件头部储存了-size个用户词性
        {
            while (++size <= 0)
            {
                Nature.create(byteArray.nextString());
            }
            size = byteArray.nextInt();
        }
        CoreDictionary.Attribute[] attributes = new CoreDictionary.Attribute[size];
        final Nature[] natureIndexArray = Nature.values();
        for (int i = 0; i < size; ++i)
        {
            // 第一个是全部频次,第二个是词性个数
            int currentTotalFrequency = byteArray.nextInt();
            int length = byteArray.nextInt();
            attributes[i] = new CoreDictionary.Attribute(length);
            attributes[i].totalFrequency = currentTotalFrequency;
            for (int j = 0; j < length; ++j)
            {
                attributes[i].nature[j] = natureIndexArray[byteArray.nextInt()];
                attributes[i].frequency[j] = byteArray.nextInt();
            }
        }
        if (!dat.load(byteArray, attributes)) return false;
    }
    catch (Exception e)
    {
        logger.warning("读取失败,问题发生在" + TextUtility.exceptionToString(e));
        return false;
    }
    return true;
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:46,代码来源:CustomDictionary.java

示例3: loadDat

import com.hankcs.hanlp.corpus.tag.Nature; //导入方法依赖的package包/类
/**
 * 从磁盘加载双数组
 *
 * @param path
 * @return
 */
static boolean loadDat(String path)
{
    try
    {
        ByteArray byteArray = ByteArray.createByteArray(path + Predefine.BIN_EXT);
        int size = byteArray.nextInt();
        CoreDictionary.Attribute[] attributes = new CoreDictionary.Attribute[size];
        final Nature[] natureIndexArray = Nature.values();
        for (int i = 0; i < size; ++i)
        {
            // 第一个是全部频次,第二个是词性个数
            int currentTotalFrequency = byteArray.nextInt();
            int length = byteArray.nextInt();
            attributes[i] = new CoreDictionary.Attribute(length);
            attributes[i].totalFrequency = currentTotalFrequency;
            for (int j = 0; j < length; ++j)
            {
                attributes[i].nature[j] = natureIndexArray[byteArray.nextInt()];
                attributes[i].frequency[j] = byteArray.nextInt();
            }
        }
        if (!dat.load(byteArray, attributes) || byteArray.hasMore()) return false;
    }
    catch (Exception e)
    {
        logger.warning("读取失败,问题发生在" + e);
        return false;
    }
    return true;
}
 
开发者ID:ml-distribution,项目名称:HanLP,代码行数:37,代码来源:CustomDictionary.java


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