本文整理汇总了C++中TokenScanner::addWordCharacters方法的典型用法代码示例。如果您正苦于以下问题:C++ TokenScanner::addWordCharacters方法的具体用法?C++ TokenScanner::addWordCharacters怎么用?C++ TokenScanner::addWordCharacters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenScanner
的用法示例。
在下文中一共展示了TokenScanner::addWordCharacters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processText
/**
* Receive information from file, processes and displays the result on the screen.
*/
void processText(TokenScanner & scanner){
int counterSentences = 0;
int counterWords = 0;
int counterSyllable = 0;
double grade = 0.0;
scanner.ignoreWhitespace(); // ignores spaces
scanner.addWordCharacters("'"); // does part of the token is the character "'"
// processes each token
while (scanner.hasMoreTokens()){
string token = scanner.nextToken();
counterSentences += checkSentences(token);
if(checkWords(token)){
counterWords ++;
counterSyllable += colSyllable(token);
}
}
// If the file does not contain any words or sentences, assume that their one
if(counterWords == 0 || counterSentences == 0) counterSentences = counterWords = 1;
grade = getGrade(counterSentences, counterWords, counterSyllable);
cout << "Words : " << counterWords << endl;
cout << "Syllable : " << counterSyllable << endl;
cout << "Sentences : " << counterSentences << endl;
cout << "Grade : " << grade << endl;
}
示例2: toAlpha
void toAlpha(std::string word, Map<std::string, std::string>& symbolTable) {
TokenScanner scanner;
scanner.ignoreWhitespace();
for(char i = 'A'; i < 'Z'; i++)
scanner.addWordCharacters(symbolTable.get(charToString(i)));
scanner.setInput(word);
while(scanner.hasMoreTokens()) {
std::string symbol = scanner.nextToken();
cout << symbolTable.get(symbol);
}
cout << endl;
}