本文整理汇总了C++中words函数的典型用法代码示例。如果您正苦于以下问题:C++ words函数的具体用法?C++ words怎么用?C++ words使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了words函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _and
std::string EnglishSpelling::spell(int number)
{
int n = number;
return boost::trim_copy(words(n / 1000000, " million " + _and (n % 1000000)) +
words((n % 1000000) / 1000, " thousand " + _and (n % 1000)) + words(n % 1000, ""));
}
示例2: remove
bool remove(uint element) {
uint word_index = IndexSet::get_word_index(element);
uint bit_index = IndexSet::get_bit_index(element);
uint32 bit = (0x1 << bit_index);
uint32 before = words()[word_index];
words()[word_index] = before & ~bit;
return ((before & bit) != 0);
}
示例3: reset
void mpfx_manager::set(mpfx & n, mpfx const & v) {
if (is_zero(v)) {
reset(n);
return;
}
allocate_if_needed(n);
n.m_sign = v.m_sign;
unsigned * w1 = words(n);
unsigned * w2 = words(v);
for (unsigned i = 0; i < m_total_sz; i++)
w1[i] = w2[i];
SASSERT(check(n));
}
示例4: words
bool mpfx_manager::eq(mpfx const & a, mpfx const & b) const {
if (is_zero(a) && is_zero(b))
return true;
if (is_zero(a) || is_zero(b))
return false;
if (a.m_sign != b.m_sign)
return false;
unsigned * w1 = words(a);
unsigned * w2 = words(b);
for (unsigned i = 0; i < m_total_sz; i++)
if (w1[i] != w2[i])
return false;
return true;
}
示例5: words
void words(char *arr){
//base case 1
if (!(*arr))
return;
//base case 2
if (*arr==' '){
printf("\n");
words(arr+1);
}
else {
printf("%c",*arr);
words(arr+1);
}
}
示例6: FindWord
std::string FindWord(const trie_type& trie, const std::string& keys, size_t alternative)
{
typedef std::vector<Word> Words;
trie_type::result_type candidates = trie.find(keys);
Words::const_iterator match;
Words words(candidates.first, candidates.second);
std::sort(words.begin(), words.end(), boost::mem_fn(&Word::MoreFrequent));
for (Words::const_iterator word = words.begin(); word != words.end(); ++word)
{
match = word;
if (alternative == 0)
{
break;
}
else
{
--alternative;
}
}
if (match == words.end())
{
return "No alternative";
}
else
{
return match->str();
}
}
示例7: words
// Compile code in boot image so that we can execute the startup quotation
// Allocates memory
void factor_vm::prepare_boot_image() {
std::cout << "*** Stage 2 early init... " << std::flush;
// Compile all words.
data_root<array> words(instances(WORD_TYPE), this);
cell n_words = array_capacity(words.untagged());
for (cell i = 0; i < n_words; i++) {
data_root<word> word(array_nth(words.untagged(), i), this);
FACTOR_ASSERT(!word->entry_point);
jit_compile_word(word.value(), word->def, false);
}
update_code_heap_words(true);
// Initialize all quotations
data_root<array> quotations(instances(QUOTATION_TYPE), this);
cell n_quots = array_capacity(quotations.untagged());
for (cell i = 0; i < n_quots; i++) {
data_root<quotation> quot(array_nth(quotations.untagged(), i), this);
if (!quot->entry_point)
quot->entry_point = lazy_jit_compile_entry_point();
}
special_objects[OBJ_STAGE2] = special_objects[OBJ_CANONICAL_TRUE];
std::cout << "done" << std::endl;
}
示例8: words
CString CSub::GetFileNameFromPath(CString path)
{
CStringList words(10);
Split("\\", m_NameOfFile, words);
CString filename = words.GetAt(words.FindIndex(words.GetCount() - 1)) ;
return filename;
}
示例9: Ensure
Ensure(Words, invokes_callback_for_each_word_in_a_phrase) {
expect(mocked_callback, when(word, is_equal_to_string("Birds")));
expect(mocked_callback, when(word, is_equal_to_string("of")));
expect(mocked_callback, when(word, is_equal_to_string("a")));
expect(mocked_callback, when(word, is_equal_to_string("feather")));
words("Birds of a feather", &mocked_callback, NULL);
}
示例10: words
size_t
UTF8StrChrFieldSearcher::matchTerms(const FieldRef & f, const size_t mintsz)
{
(void) mintsz;
termcount_t words(0);
const byte * n = reinterpret_cast<const byte *> (f.data());
const byte * e = n + f.size();
if (f.size() >= _buf->size()) {
_buf->reserve(f.size() + 1);
}
cmptype_t * fn = &(*_buf.get())[0];
size_t fl(0);
for( ; n < e; ) {
if (!*n) { _zeroCount++; n++; }
n = tokenize(n, _buf->capacity(), fn, fl);
for(QueryTermList::iterator it=_qtl.begin(), mt=_qtl.end(); it != mt; it++) {
QueryTerm & qt = **it;
const cmptype_t * term;
termsize_t tsz = qt.term(term);
if ((tsz <= fl) && (prefix() || qt.isPrefix() || (tsz == fl))) {
const cmptype_t *tt=term, *et=term+tsz;
for (const cmptype_t *fnt=fn; (tt < et) && (*tt == *fnt); tt++, fnt++);
if (tt == et) {
addHit(qt, words);
}
}
}
words++;
}
NEED_CHAR_STAT(addAnyUtf8Field(f.size()));
return words;
}
示例11: chooseWords
std::set<std::string> chooseWords(std::string secret)
{
// Initialise word list
WordList words(wordLength);
// Create a set to hold the list of options
std::set<std::string> options;
// Put the secret word in the set
options.insert(secret);
int likeWords = 0;
while (options.size() < numberOfWords)
{
std::string word = words.getRandomWord();
// Ensure that the minimum number of words are like
if (likeWords < guaranteedNumberOfLikeWords)
{
int likeness = checkLikeness(word, secret);
// They are like if more than half of the letters match the secret
if (likeness > wordLength / 2)
{
options.insert(word);
likeWords++;
}
}
else
options.insert(word);
}
return options;
}
示例12: words
void listElements::tableInsert(unordered_map<string, vector<size_t>>& uMAP, const string& str, size_t idx)
{
vector<string> words(1, str);
string diver = " /-";
for (size_t i = 0, j, pivot = 0; i <= str.size(); i++)
{
if (i == str.size())
{
words.push_back(str.substr(pivot, i - pivot));
break;
}
for (j = 0; j < diver.size(); j++)
if (str[i] == diver[j])
break;
if (j - diver.size())
{
words.push_back(str.substr(pivot, i - pivot));
pivot = i + 1;
i++;
}
}
std::sort(words.begin(), words.end());
words.erase(unique(words.begin(), words.end()), words.end());
for (string s : words)
for (size_t i = 1, j; i <= s.size(); i++)
{
for (j = 0; j < diver.size(); j++)
if (s[i - 1] == diver[j])
break;
if (j == diver.size())
tableInsertString(uMAP, s.substr(0, i), idx);
}
}
示例13: main
void main()
{
clrscr();
int choice;
char ch;
do{clrscr();
cout<<"\n MENU ";
cout<<"\n 1.CREATE";
cout<<"\n 2.DISPLAY";
cout<<"\n 3.NO OF UPPER CASE CHARACTERS ";
cout<<"\n 4.NO OF VOWELS";
cout<<"\n 5.NO OF DIGITS";
cout<<"\n 6.NO OF WORDS";
cout<<"\n 7.NUMBER OF LINES";
cout<<"\n enter ur choice";
cin>>choice;
switch(choice)
{
case 1:create();break;
case 2:display();break;
case 3:uppercase();break;
case 4:vowels();break;
case 5:digits();break;
case 6:words();break;
case 7:lines();break;
default: cout<<"\n wrong choice entered..!!";
}
cout<<"\n do you want to continue...??";
cin>>ch;
}
while(ch=='y'||ch=='Y');
}
示例14: gc
/* Allocates memory */
void factor_vm::set_profiling(bool profiling)
{
if(profiling == profiling_p)
return;
profiling_p = profiling;
/* Push everything to tenured space so that we can heap scan
and allocate profiling blocks if necessary */
gc();
gc_root<array> words(find_all_words(),this);
cell i;
cell length = array_capacity(words.untagged());
for(i = 0; i < length; i++)
{
tagged<word> word(array_nth(words.untagged(),i));
if(profiling)
word->counter = tag_fixnum(0);
update_word_xt(word.value());
}
update_code_heap_words();
}
示例15: words
vector<vector<DisambiguatedData> > Disambiguator::Disambiguate(
const vector<Token>& tokens, double percentage, size_t maxNumberOfPaths
, vector<double>* hypothesisDistribution)
{
vector<PredisambiguatedData> predisambiguated
= featureCalculator->CalculateFeatures(tokens);
// Create chain
size_t size = predisambiguated.size();
vector<wstring> words(size);
vector<vector<wstring> > features(size);
vector<wstring> labels(size);
for (size_t chainIndex = 0; chainIndex < size; ++chainIndex)
{
words[chainIndex] = predisambiguated[chainIndex].content;
features[chainIndex] = predisambiguated[chainIndex].features;
}
LinearCRF::Chain chain(
std::move(words)
, std::move(features)
, std::move(labels)
, vector<vector<wstring> >());
vector<vector<wstring> > bestSequences;
vector<vector<double> > bestSequenceWeights;
this->Apply(chain
, percentage
, maxNumberOfPaths
, &bestSequences
, &bestSequenceWeights
, hypothesisDistribution);
vector<vector<DisambiguatedData> > topDisambiguatedSequences;
for (size_t chainIndex = 0; chainIndex < bestSequences.size()
; ++chainIndex)
{
vector<DisambiguatedData> disambiguatedData;
for (size_t tokenIndex = 0; tokenIndex < size; ++tokenIndex)
{
wstring& label = bestSequences[chainIndex][tokenIndex];
shared_ptr<Morphology> grammInfo = getBestGrammInfo(
predisambiguated[tokenIndex], label);
applyPostprocessRules(&label, grammInfo);
const wstring& lemma
= dictionary == 0 ? DICT_IS_NULL
: *(grammInfo->lemma) == NOT_FOUND_LEMMA
? Tools::ToLower(predisambiguated[tokenIndex].content) : *(grammInfo->lemma);
disambiguatedData.emplace_back(
predisambiguated[tokenIndex].content
, predisambiguated[tokenIndex].punctuation
, predisambiguated[tokenIndex].source
, predisambiguated[tokenIndex].isNextSpace
, lemma
, label
, bestSequenceWeights[chainIndex][tokenIndex]
, grammInfo->lemma_id);
}
topDisambiguatedSequences.push_back(std::move(disambiguatedData));
}
return topDisambiguatedSequences;
}