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


C++ Unicode::size方法代码示例

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


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

示例1: trie

TEST(DictTrieTest, Test1) {
  string s1, s2;
  DictTrie trie(DICT_FILE);
  ASSERT_LT(trie.GetMinWeight() + 15.6479, 0.001);
  string word("来到");
  Unicode uni;
  ASSERT_TRUE(TransCode::Decode(word, uni));
  DictUnit nodeInfo;
  nodeInfo.word = uni;
  nodeInfo.tag = "v";
  nodeInfo.weight = -8.87033;
  s1 << nodeInfo;
  s2 << (*trie.Find(uni.begin(), uni.end()));

  EXPECT_EQ("[\"26469\", \"21040\"] v -8.870", s2);
  word = "清华大学";
  LocalVector<pair<size_t, const DictUnit*> > res;
  const char * words[] = {"清", "清华", "清华大学"};
  for (size_t i = 0; i < sizeof(words)/sizeof(words[0]); i++) {
    ASSERT_TRUE(TransCode::Decode(words[i], uni));
    res.push_back(make_pair(uni.size() - 1, trie.Find(uni.begin(), uni.end())));
    //resMap[uni.size() - 1] = trie.Find(uni.begin(), uni.end());
  }
  vector<pair<size_t, const DictUnit*> > vec;
  vector<struct Dag> dags;
  ASSERT_TRUE(TransCode::Decode(word, uni));
  trie.Find(uni.begin(), uni.end(), dags);
  ASSERT_EQ(dags.size(), uni.size());
  ASSERT_NE(dags.size(), 0u);
  s1 << res;
  s2 << dags[0].nexts;
  ASSERT_EQ(s1, s2);
  
}
开发者ID:arrack,项目名称:cppjieba,代码行数:34,代码来源:trie_test.cpp

示例2: _loadEmitProb

 bool _loadEmitProb(const string &line, EmitProbMap &mp)
 {
     if (line.empty())
     {
         return false;
     }
     vector<string> tmp, tmp2;
     Unicode unicode;
     split(line, tmp, ",");
     for (size_t i = 0; i < tmp.size(); i++)
     {
         split(tmp[i], tmp2, ":");
         if (2 != tmp2.size())
         {
             Rcout << "_emitProb illegal." << std::endl;
             return false;
         }
         if (!TransCode::decode(tmp2[0], unicode) || unicode.size() != 1)
         {
             Rcout << "TransCode failed." << std::endl;
             return false;
         }
         mp[unicode[0]] = atof(tmp2[1].c_str());
     }
     return true;
 }
开发者ID:hoyoung2015,项目名称:jiebaR,代码行数:26,代码来源:HMMSegment.hpp

示例3: IsSingleWord

 bool IsSingleWord(const string& str) const {
   Unicode unicode;
   TransCode::Decode(str, unicode);
   if (unicode.size() == 1)
     return true;
   return false;
 }
开发者ID:amikey,项目名称:cppjieba,代码行数:7,代码来源:KeywordExtractor.hpp

示例4: find

	bool Trie::find(const Unicode& unico, vector<pair<uint, const TrieNodeInfo*> >& res)const
	{
        if(!_getInitFlag())
        {
            LogFatal("trie not initted!");
            return false;
        }
        TrieNode* p = _root;
        //for(Unicode::const_iterator it = begin; it != end; it++)
        for(uint i = 0; i < unico.size(); i++)
        {
            if(p->hmap.find(unico[i]) == p-> hmap.end())
            {
				break;
            }
			p = p->hmap[unico[i]];
			if(p->isLeaf)
			{
				uint pos = p->nodeInfoVecPos;
				if(pos < _nodeInfoVec.size())
				{
					res.push_back(make_pair(i, &_nodeInfoVec[pos]));
				}
				else
				{
					LogFatal("node's nodeInfoVecPos is out of _nodeInfoVec's range");
					return false;
				}
			}
        }
		return !res.empty();
	}
开发者ID:Alienfeel,项目名称:cppjieba,代码行数:32,代码来源:Trie.cpp

示例5: IsAllAscii

 bool IsAllAscii(const Unicode& s) const {
  for(size_t i = 0; i < s.size(); i++) {
    if (s[i] >= 0x80) {
      return false;
    }
  }
  return true;
 }
开发者ID:dreamsxin,项目名称:pg_jieba,代码行数:8,代码来源:QuerySegment.hpp

示例6: findPrefix

    const TrieNodeInfo* Trie::findPrefix(const string& str)const
    {
        if(!_getInitFlag())
        {
            LogFatal("trie not initted!");
            return NULL;
        }
        Unicode uintVec;
        
        if(!TransCode::decode(str, uintVec))
        {
            LogError("TransCode::decode failed.");
            return NULL;
        }

        //find
        TrieNode* p = _root;
        uint pos = 0;
        uint16_t chUni = 0;
        const TrieNodeInfo * res = NULL;
        for(uint i = 0; i < uintVec.size(); i++)
        {
            chUni = uintVec[i];
            if(p->isLeaf)
            {
                pos = p->nodeInfoVecPos;
                if(pos >= _nodeInfoVec.size())
                {
                    LogFatal("node's nodeInfoVecPos is out of _nodeInfoVec's range");
                    return NULL;
                }
                res = &(_nodeInfoVec[pos]);
                
            }
            if(p->hmap.find(chUni) == p->hmap.end())
            {
                break;
            }
            else
            {
                p = p->hmap[chUni];
            }
        }
        return res;
    }
开发者ID:Alienfeel,项目名称:cppjieba,代码行数:45,代码来源:Trie.cpp

示例7: LoadEmitProb

  bool LoadEmitProb(const std::string& line, EmitProbMap& mp) {
    if (line.empty()) {
      return false;
    }
    std::vector<std::string> tmp, tmp2;
    Unicode unicode;
	limonp::Split(line, tmp, ",");
    for (size_t i = 0; i < tmp.size(); i++) {
		limonp::Split(tmp[i], tmp2, ":");
      if (2 != tmp2.size()) {
//        limonp::LOG(ERROR) << "emitProb illegal.";
        return false;
      }
      if (!TransCode::Decode(tmp2[0], unicode) || unicode.size() != 1) {
//        limonp::LOG(ERROR) << "TransCode failed.";
        return false;
      }
      mp[unicode[0]] = atof(tmp2[1].c_str());
    }
    return true;
  }
开发者ID:samevers,项目名称:posTrunk,代码行数:21,代码来源:HMMModel.hpp


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