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


C++ Word类代码示例

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


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

示例1: test_unfold

void test_unfold( )
{
  typedef IntLabeledGraph Graph;
  typedef Graph::edge_type edge_type;
  typedef Graph::vertex_type vertex_type;
  Graph F;

  int o = F.newVertex( );
  Word x1( 1 );
  Word x2( 2 );
  for( int i=0 ; i<5; ++i ) {
    Word w = Word::randomWord( 2 , 3 );
    addLoop( F , o , w.begin( ) , w.end( ) );
  }
  
  set< int > candidates;
  candidates.insert( o );
  list< FoldDetails< vertex_type , edge_type > > details;
  fold( F , candidates , &details );
  if( F.getVertices( ).size( )>1 )
    return;
  
  pair< bool , list< edge_type > > path = trace_path( F , o , x2.begin( ) , x2.end( ) );
  liftup( F , o , path.second , details.begin( ) , details.end( ) );
}
开发者ID:dpantele,项目名称:crag,代码行数:25,代码来源:test_graph_algs.cpp

示例2: main

int main( )
{
  FPGroup G;
  cout << "Enter nilpotentcy class first then group ";
  int NilpotentcyClass;
  cin >> NilpotentcyClass;
  Chars errMsg = cin >> G;
  if (errMsg.length()>0) 
    return 1;
 
  NilpotentGroup ng(G.namesOfGenerators(),
		    NilpotentcyClass,makeVectorOf(G.getRelators()));
  ng.initialize();
  VectorOf<Word> vw;
  Word w;
  for (int i=1;true;i++){
    cout << endl << "Enter the "<<i<<" generator of subgroup"<< endl;
    cout << "Empty word to finish: ";
    w = G.readWord(cin,errMsg);
    if (w.length()==0)
      break;
    if (errMsg.length()>0) 
      return 1;
    vw.append(w);
  }
  SGOfNilpotentGroup sg(ng,vw);
  sg.initBasis();
  sg.printBasis(cout);
  cout << "The Hirsch number :" << sg.theHirschNumber() << endl;
  cout << "Index in parent group :" << sg.index() << endl;
  cout << "Is Trivial :" << sg.isTrivial() << endl;
  cout << "Is Central :" << sg.isCentral() << endl;
  cout << "Is normal :" << sg.isNormal() << endl;
  cout << "Is abelian :" << sg.isAbelian() << endl;
  cout << "Subgroup class :" << sg.subgroupClass() << endl;
  cout << "Generators of normal closure :" << endl;
  vw = sg.normalClosureGens();
  for (int i=0;i<vw.length();i++){
    G.printWord(cout,vw[i]);
    cout << endl;
  }
  PresentationForSNG sgp = sg.makePresentation();
  cout << "Presentation of subgroup :" << endl;
  sgp.print(cout);
  cout << endl << "Enter the word :";
  errMsg = "";
  w = G.readWord(cin,errMsg);
  if (errMsg.length()>0){ 
    cout << errMsg;
    return 1; 
  }
  cout << endl << "Does subgroup contain the word :" << sg.contains(w) << endl;
  PolyWord result;
  if (sg.decompose(ng.decompose(w),result))
    cout << "Decomposition in sg basis :" << sg.asDecomposition(result);
  else
    cout << "Subgroup does not contain this word";

}
开发者ID:koudonojinchuu,项目名称:magnus,代码行数:59,代码来源:test_NilpotentSubgroup.C

示例3: GetWordID

// get wordID_t index for word represented as string
wordID_t Vocab::GetWordID(const std::string& word_str,
                          const FactorDirection& direction, const FactorList& factors, bool isNonTerminal)
{
  // get id for factored string
  Word word;
  word.CreateFromString( direction, factors, word_str, isNonTerminal);
  return GetWordID( word);
}
开发者ID:sleepcry,项目名称:mosesdecoder,代码行数:9,代码来源:vocab.cpp

示例4: right

int Group::right (int v, const Word& word)
{
    int g = v;
    for (unsigned t=0; t<word.size(); ++t) {
        g = right(g, word[word.size() -t -1]);
    }
    return g;
}
开发者ID:Hovelander,项目名称:jenn3d,代码行数:8,代码来源:todd_coxeter.C

示例5: main6

//测试word的相关操作
int main6() {
	Word *word = new Word("wordfdsafds");
	RedisProxy redisProxy("localhost", 6379);
	redisProxy.addWord(word);
	word = redisProxy.getWord(word->getId());
	std::cout << word->getId() << " " << word->getName();
	return 0;
}
开发者ID:muyuxuebao,项目名称:eclipse_workspace_cpp,代码行数:9,代码来源:main.cpp

示例6: greedyReduce

Word GAConjProblemForORGroupSolver::greedyReduce( const OneRelatorGroup& group , const Word& word )
{
  Word w = word;
  w = w.cyclicallyReduce( );
  while( oneGreedyReduce( group , w ) );

  return w;
}
开发者ID:koudonojinchuu,项目名称:magnus,代码行数:8,代码来源:GACPforORGSolver.C

示例7: MakeWord

static Word MakeWord(string text)
{
    FactorCollection &factorCollection = FactorCollection::Instance();
    const Factor* f = factorCollection.AddFactor(Input,0,text);
    Word w;
    w.SetFactor(0,f);
    return w;
}
开发者ID:mitramah,项目名称:mosesdecoder,代码行数:8,代码来源:PhraseLengthFeatureTest.cpp

示例8: transform

bool operator > (Word w1, Word w2) {
    string w1word = w1.getWord();
    string w2word = w2.getWord();
    transform(w1word.begin(), w1word.end(), w1word.begin(), ::toupper);
    transform(w2word.begin(), w2word.end(), w2word.begin(), ::toupper);

    return (w1word > w2word);
}
开发者ID:codingkitty81,项目名称:CSCI-21-FALL-2015,代码行数:8,代码来源:word.cpp

示例9: reduce

Word TheGrigorchukGroupAlgorithms::reduce( const Word& w )
{
  Word result;
  for( Word::const_iterator w_it=w.begin( ) ; w_it!=w.end( ) ; ++w_it )
    push_back( result , *w_it );
  
  return result;
}
开发者ID:dpantele,项目名称:crag,代码行数:8,代码来源:TheGrigorchukGroupWordProblem.cpp

示例10: int2word

 Word int2word(int g)
 {
   Word result;
   while (g) {
     result.push_back((g % 10) - 1);
     g /= 10;
   }
   return result;
 }
开发者ID:b3sigma,项目名称:fourd,代码行数:9,代码来源:polytopes.cpp

示例11: VERBOSE

void GlobalLexicalModel::Load()
{
  FactorCollection &factorCollection = FactorCollection::Instance();
  const std::string& factorDelimiter = StaticData::Instance().GetFactorDelimiter();

  VERBOSE(2, "Loading global lexical model from file " << m_filePath << endl);

  m_inputFactors = FactorMask(m_inputFactorsVec);
  m_outputFactors = FactorMask(m_outputFactorsVec);
  InputFileStream inFile(m_filePath);

  // reading in data one line at a time
  size_t lineNum = 0;
  string line;
  while(getline(inFile, line)) {
    ++lineNum;
    vector<string> token = Tokenize<string>(line, " ");

    if (token.size() != 3) { // format checking
      UTIL_THROW2("Syntax error at " << m_filePath << ":" << lineNum << ":" << line);
    }

    // create the output word
    Word *outWord = new Word();
    vector<string> factorString = Tokenize( token[0], factorDelimiter );
    for (size_t i=0 ; i < m_outputFactorsVec.size() ; i++) {
      const FactorDirection& direction = Output;
      const FactorType& factorType = m_outputFactorsVec[i];
      const Factor* factor = factorCollection.AddFactor( direction, factorType, factorString[i] );
      outWord->SetFactor( factorType, factor );
    }

    // create the input word
    Word *inWord = new Word();
    factorString = Tokenize( token[1], factorDelimiter );
    for (size_t i=0 ; i < m_inputFactorsVec.size() ; i++) {
      const FactorDirection& direction = Input;
      const FactorType& factorType = m_inputFactorsVec[i];
      const Factor* factor = factorCollection.AddFactor( direction, factorType, factorString[i] );
      inWord->SetFactor( factorType, factor );
    }

    // maximum entropy feature score
    float score = Scan<float>(token[2]);

    // std::cerr << "storing word " << *outWord << " " << *inWord << " " << score << endl;

    // store feature in hash
    DoubleHash::iterator keyOutWord = m_hash.find( outWord );
    if( keyOutWord == m_hash.end() ) {
      m_hash[outWord][inWord] = score;
    } else { // already have hash for outword, delete the word to avoid leaks
      (keyOutWord->second)[inWord] = score;
      delete outWord;
    }
  }
}
开发者ID:DoWhatILove,项目名称:mosesdecoder,代码行数:57,代码来源:GlobalLexicalModel.cpp

示例12: print

void WQueue::print()
{
	Word* cur = front;
	while (cur != NULL)
	{
		cout << cur->getData() << " ";
		cur = cur->getNext();
	}
}
开发者ID:k1ll3rzamb0n1,项目名称:Code_backup,代码行数:9,代码来源:WQueue.cpp

示例13: DisplayS

void TTSQueue::DisplayS()
{
	Word * word = header;
	while(word != NULL)
	{
		word->DisplayS();
		word = word->next;
	}
}
开发者ID:engindemir,项目名称:Turkish_TTS,代码行数:9,代码来源:TTSQueue.cpp

示例14: strcpy

Word Word::operator+(const Word& rhs)
{
	char* temp = new char[this->string_length_ + rhs.len() - 1];
	strcpy(temp, this->string_);
	strcat(temp, rhs.getString());
	Word sum(temp);
	delete [] temp;
	return sum;
}
开发者ID:wspurgin,项目名称:SortingProject,代码行数:9,代码来源:Word.cpp

示例15: TEST_F

//word
TEST_F(Gtest, test_Word) {
	std::string name = "wordfdsafds";
	Word *word = new Word("wordfdsafds");
	RedisProxy redisProxy("localhost", 6379);
	redisProxy.addWord(word);
	word = redisProxy.getWord(word->getId());
	std::cout << word->getId() << " " << word->getName() << std::endl;
	EXPECT_EQ(name, word->getName());
}
开发者ID:muyuxuebao,项目名称:RedisJson_makefile,代码行数:10,代码来源:test.cpp


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