本文整理汇总了C++中WordList类的典型用法代码示例。如果您正苦于以下问题:C++ WordList类的具体用法?C++ WordList怎么用?C++ WordList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WordList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: replaceWordsInCurrentEditor
void SpellCheckerCore::replaceWordsInCurrentEditor(const WordList &wordsToReplace, const QString &replacementWord)
{
if(wordsToReplace.count() == 0) {
Q_ASSERT(wordsToReplace.count() != 0);
return;
}
if(d->currentEditor == NULL) {
Q_ASSERT(d->currentEditor != NULL);
return;
}
TextEditor::TextEditorWidget* editorWidget = qobject_cast<TextEditor::TextEditorWidget*>(d->currentEditor->widget());
if(editorWidget == NULL) {
Q_ASSERT(editorWidget != NULL);
return;
}
QTextCursor cursor = editorWidget->textCursor();
/* Iterate the words and replace all one by one */
foreach(const Word& wordToReplace, wordsToReplace) {
editorWidget->gotoLine(wordToReplace.lineNumber, wordToReplace.columnNumber - 1);
int wordStartPos = editorWidget->textCursor().position();
editorWidget->gotoLine(wordToReplace.lineNumber, wordToReplace.columnNumber + wordToReplace.length - 1);
int wordEndPos = editorWidget->textCursor().position();
cursor.beginEditBlock();
cursor.setPosition(wordStartPos);
cursor.setPosition(wordEndPos, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
cursor.insertText(replacementWord);
cursor.endEditBlock();
}
开发者ID:Typz,项目名称:SpellChecker-Plugin,代码行数:31,代码来源:spellcheckercore.cpp
示例2: giveSuggestionsForWordUnderCursor
void SpellCheckerCore::giveSuggestionsForWordUnderCursor()
{
if( d->currentEditor.isNull() == true ) {
return;
}
Word word;
WordList wordsToReplace;
bool wordMistake = isWordUnderCursorMistake( word );
if( wordMistake == false ) {
return;
}
getAllOccurrencesOfWord( word, wordsToReplace );
SuggestionsDialog dialog( word.text, word.suggestions, wordsToReplace.count() );
SuggestionsDialog::ReturnCode code = static_cast<SuggestionsDialog::ReturnCode>( dialog.exec() );
switch( code ) {
case SuggestionsDialog::Rejected:
/* Cancel and exit */
return;
case SuggestionsDialog::Accepted:
/* Clear the list and only add the one to replace */
wordsToReplace.clear();
wordsToReplace.append( word );
break;
case SuggestionsDialog::AcceptAll:
/* Do nothing since the list of words is already valid */
break;
}
QString replacement = dialog.replacementWord();
replaceWordsInCurrentEditor( wordsToReplace, replacement );
}
开发者ID:CJCombrink,项目名称:SpellChecker-Plugin,代码行数:33,代码来源:spellcheckercore.cpp
示例3: ColouriseWord
static void ColouriseWord(StyleContext& sc, WordList& keywords, WordList& keywords2, WordList& keywords3, bool& apostropheStartsAttribute) {
apostropheStartsAttribute = true;
sc.SetState(SCE_SPICE_IDENTIFIER);
std::string word;
while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) {
word += static_cast<char>(tolower(sc.ch));
sc.Forward();
}
if (keywords.InList(word.c_str())) {
sc.ChangeState(SCE_SPICE_KEYWORD);
if (word != "all") {
apostropheStartsAttribute = false;
}
}
else if (keywords2.InList(word.c_str())) {
sc.ChangeState(SCE_SPICE_KEYWORD2);
if (word != "all") {
apostropheStartsAttribute = false;
}
}
else if (keywords3.InList(word.c_str())) {
sc.ChangeState(SCE_SPICE_KEYWORD3);
if (word != "all") {
apostropheStartsAttribute = false;
}
}
sc.SetState(SCE_SPICE_DEFAULT);
}
开发者ID:6qat,项目名称:robomongo,代码行数:28,代码来源:LexSpice.cpp
示例4: WordList
DictViewInstance::WordList *DictViewInstance::WordSuggestion(FarStringW &word)
{
WordList *wl = new WordList();
_current_color = -1;
_current_word = word;
DecisionTable::action_inst_t act_inst = logic.Execute();
Action *action = static_cast<Action *>(act_inst->client_context);
far_assert(action);
FarString suggestion_order = action->suggestions;
if (suggestion_order.IsEmpty())
for (int i = 0; i<DictCount(); i++)
suggestion_order += GetDict(i)->dict + ';';
if (suggestion_order.IsEmpty())
return wl;
FarStringTokenizer dicts(suggestion_order, ';');
for (int i = 0; i < DictCount() && dicts.HasNext(); i++)
{
const FarString &dict(dicts.NextToken());
for (int j = 0; j < DictCount(); j++)
if (GetDict(j)->dict == dict) {
far_assert(spell_factory);
SpellInstance *dict_inst = spell_factory->GetDictInstance(dict);
far_assert(dict_inst);
wl->Add(dict_inst->Suggest(word));
}
}
return wl;
}
开发者ID:FarManagerLegacy,项目名称:farspell,代码行数:28,代码来源:DictViewFactory.cpp
示例5: isWordUnderCursorMistake
bool SpellCheckerCore::isWordUnderCursorMistake(Word& word) const
{
if(d->currentEditor.isNull() == true) {
return false;
}
unsigned int column = d->currentEditor->currentColumn();
unsigned int line = d->currentEditor->currentLine();
QString currentFileName = d->currentEditor->document()->filePath().toString();
WordList wl;
wl = d->spellingMistakesModel->mistakesForFile(currentFileName);
if(wl.isEmpty() == true) {
return false;
}
WordList::ConstIterator iter = wl.constBegin();
while(iter != wl.constEnd()) {
const Word& currentWord = iter.value();
if((currentWord.lineNumber == line)
&& ((currentWord.columnNumber <= column)
&& (currentWord.columnNumber + currentWord.length) >= column)) {
word = currentWord;
return true;
}
++iter;
}
return false;
}
开发者ID:Typz,项目名称:SpellChecker-Plugin,代码行数:27,代码来源:spellcheckercore.cpp
示例6: generateRandomName
QString RandomNameProvider::generateRandomName()
{
static WordList words;
return words.at(std::abs(iscore::random_id_generator::getRandomId() % (words.size() - 1))) +
QString::number(std::abs(iscore::random_id_generator::getRandomId() % 99)) +
words.at(std::abs(iscore::random_id_generator::getRandomId() % (words.size() - 1))) +
QString::number(std::abs(iscore::random_id_generator::getRandomId() % 99));
}
开发者ID:himito,项目名称:i-score,代码行数:9,代码来源:RandomNameProvider.cpp
示例7:
const WordList layprop::ViewProperties::getAllLayers(void)
{
//drawprop._layset
WordList listLayers;
laySetList::const_iterator it;
for( it = _drawprop._layset.begin(); it != _drawprop._layset.end(); ++it)
{
listLayers.push_back((*it).first);
}
return listLayers;
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:11,代码来源:viewprop.cpp
示例8: WordListSet
int SCI_METHOD LexerBase::WordListSet(int n, const char *wl) {
if (n < numWordLists) {
WordList wlNew;
wlNew.Set(wl);
if (*keyWordLists[n] != wlNew) {
keyWordLists[n]->Set(wl);
return 0;
}
}
return -1;
}
开发者ID:Aahanbhatt,项目名称:robomongo,代码行数:11,代码来源:LexerBase.cpp
示例9:
void laydata::tdtlibrary::collect_usedlays(WordList& laylist) const
{
for (cellList::const_iterator CC = _cells.begin(); CC != _cells.end(); CC++)
{
CC->second->collect_usedlays(NULL, false,laylist);
}
laylist.sort();
laylist.unique();
if ( (0 < laylist.size()) && (0 == laylist.front()) )
laylist.pop_front();
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:11,代码来源:tedesign.cpp
示例10: main
int main(int argc, char *argv[])
{
WordList wordlist;
if (argc == 2) {
wordlist.read_lyrics(argv[1],false);
wordlist.search();
}
else {
cout << "Usage: songsearch database.txt\n";
}
return 0;
}
开发者ID:annarichardson,项目名称:Tufts-Class,代码行数:12,代码来源:main.cpp
示例11: isWordUnderCursorMistake
void SpellCheckerCore::updateContextMenu()
{
if( d->contextMenuHolderCommands.isEmpty() == true ) {
/* Populate the internal vector with the holder actions to speed up the process
* of updating the context menu when requested again. */
QVector<const char*> holderActionIds { Constants::ACTION_HOLDER1_ID, Constants::ACTION_HOLDER2_ID, Constants::ACTION_HOLDER3_ID, Constants::ACTION_HOLDER4_ID, Constants::ACTION_HOLDER5_ID };
/* Iterate the commands and */
for( int count = 0; count < holderActionIds.size(); ++count ) {
Core::Command* cmd = Core::ActionManager::command( holderActionIds[count] );
d->contextMenuHolderCommands.push_back( cmd );
}
}
Word word;
bool isMistake = isWordUnderCursorMistake( word );
/* Do nothing if the context menu is not a mistake.
* The context menu will in this case already be disabled so there
* is no need to update it. */
if( isMistake == false ) {
return;
}
QStringList list = word.suggestions;
/* Iterate the commands and */
for( Core::Command* cmd: qAsConst( d->contextMenuHolderCommands ) ) {
Q_ASSERT( cmd != nullptr );
if( list.size() > 0 ) {
/* Disconnect the previous connection made, otherwise it will also trigger */
cmd->action()->disconnect();
/* Set the text on the action for the word to use*/
QString replacementWord = list.takeFirst();
cmd->action()->setText( replacementWord );
/* Show the action */
cmd->action()->setVisible( true );
/* Connect to lambda function to call to replace the words if the
* action is triggered. */
connect( cmd->action(), &QAction::triggered, this, [this, word, replacementWord]() {
WordList wordsToReplace;
if( d->settings->replaceAllFromRightClick == true ) {
this->getAllOccurrencesOfWord( word, wordsToReplace );
} else {
wordsToReplace.append( word );
}
this->replaceWordsInCurrentEditor( wordsToReplace, replacementWord );
} );
} else {
/* Hide the action since there are less than 5 suggestions for the word. */
cmd->action()->setVisible( false );
}
}
}
开发者ID:CJCombrink,项目名称:SpellChecker-Plugin,代码行数:50,代码来源:spellcheckercore.cpp
示例12: getBoolValue
int tellstdfunc::stdREPORTLAY::execute() {
bool recursive = getBoolValue();
std::string cellname = getStringValue();
WordList ull;
DATC->lockDB();
bool success = DATC->TEDLIB()->collect_usedlays(cellname, recursive, ull);
DATC->unlockDB();
telldata::ttlist* tllull = DEBUG_NEW telldata::ttlist(telldata::tn_int);
if (success) {
ull.sort();ull.unique();
std::ostringstream ost;
ost << "used layers: {";
for(WordList::const_iterator CL = ull.begin() ; CL != ull.end();CL++ )
ost << " " << *CL << " ";
ost << "}";
tell_log(console::MT_INFO, ost.str());
for(WordList::const_iterator CL = ull.begin() ; CL != ull.end();CL++ )
tllull->add(DEBUG_NEW telldata::ttint(*CL));
ull.clear();
}
else {
std::string news = "cell \"";
news += cellname; news += "\" doesn't exists";
tell_log(console::MT_ERROR,news);
}
OPstack.push(tllull);
return EXEC_NEXT;
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:29,代码来源:tpdf_db.cpp
示例13: HighlightBuilderException
void HighlightStateBuilder::build(StringListLangElem *elem,
HighlightState *state) {
const string &name = elem->getName();
StringDefs *alternatives = elem->getAlternatives();
WordList wordList;
bool doubleQuoted = false, nonDoubleQuoted = false, buildAsWordList = true;
for (StringDefs::const_iterator it = alternatives->begin(); it
!= alternatives->end(); ++it) {
const string &rep = (*it)->toString();
// double quoted strings generate WordListRules, otherwise simple ListRules
// we don't allow double quoted strings mixed with non double quoted
if (((*it)->isDoubleQuoted() && nonDoubleQuoted)
|| (!(*it)->isDoubleQuoted() && doubleQuoted)) {
throw HighlightBuilderException(
"cannot mix double quoted and non double quoted", elem);
}
doubleQuoted = (*it)->isDoubleQuoted();
nonDoubleQuoted = !(*it)->isDoubleQuoted();
wordList.push_back(rep);
// now check whether we must build a word list rule (word boundary) or an
// ordinary list; as soon as we find something that is not to be isolated
// we set buildAsWordList as false
if (buildAsWordList && (!doubleQuoted || !is_to_isolate(rep))) {
buildAsWordList = false;
}
}
HighlightRulePtr rule;
if (buildAsWordList)
rule = HighlightRulePtr(highlightRuleFactory->createWordListRule(name,
wordList, elem->isCaseSensitive()));
else
rule = HighlightRulePtr(highlightRuleFactory->createListRule(name,
wordList, elem->isCaseSensitive()));
rule->setAdditionalInfo(elem->toStringParserInfo());
state->addRule(rule);
setExitLevel(elem, rule.get());
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:50,代码来源:highlightstatebuilder.cpp
示例14: clear
void HalfDictionary::read( std::istream& is )
{
clear();
while (!is.eof())
{
WordList ph;
Hunglish::read(ph,is);
if (ph.empty())
continue;
push_back(ph);
}
}
开发者ID:anukat2015,项目名称:hunalign,代码行数:15,代码来源:dictionary.cpp
示例15: remove
void FrequencyMap::remove( const WordList& wordList )
{
for ( int j=0; j<wordList.size(); ++j )
{
remove(wordList[j]);
}
}
开发者ID:anukat2015,项目名称:hunalign,代码行数:7,代码来源:dictionary.cpp
示例16: build
void FrequencyMap::build( const WordList& wordList )
{
for ( int j=0; j<wordList.size(); ++j )
{
add(wordList[j]);
}
}
开发者ID:anukat2015,项目名称:hunalign,代码行数:7,代码来源:dictionary.cpp
示例17: IsFoldingContainer
/**
* This function detects keywords which are able to have a body. Note that it
* uses the Fold Containers word description, not the containers description. It
* only works when the style at that particular position is set on Containers
* or Flow (number 3 or 4).
*
* \param keywordslist The list of keywords that are scanned, they should only
* contain the start keywords, not the end keywords
* \param The actual keyword
* \return 1 if it is a folding start-keyword, -1 if it is a folding end-keyword
* 0 otherwise
*/
static inline int IsFoldingContainer(WordList &keywordslist, char * keyword) {
if(
strlen(keyword) > 3 &&
keyword[0] == 'e' && keyword[1] == 'n' && keyword[2] == 'd') {
if (keywordslist.InList(keyword + 3)) {
return -1;
}
} else {
if(keywordslist.InList(keyword)) {
return 1;
}
}
return 0;
}
开发者ID:Snake174,项目名称:PipmakAssistant,代码行数:28,代码来源:LexMagik.cpp
示例18: ColouriseLabel
static void ColouriseLabel(StyleContext& sc, WordList& keywords, bool& apostropheStartsAttribute) {
apostropheStartsAttribute = false;
sc.SetState(SCE_ADA_LABEL);
// Skip "<<"
sc.Forward();
sc.Forward();
std::string identifier;
while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) {
identifier += static_cast<char>(tolower(sc.ch));
sc.Forward();
}
// Skip ">>"
if (sc.Match('>', '>')) {
sc.Forward();
sc.Forward();
} else {
sc.ChangeState(SCE_ADA_ILLEGAL);
}
// If the name is an invalid identifier or a keyword, then make it invalid label
if (!IsValidIdentifier(identifier) || keywords.InList(identifier.c_str())) {
sc.ChangeState(SCE_ADA_ILLEGAL);
}
sc.SetState(SCE_ADA_DEFAULT);
}
开发者ID:6VV,项目名称:NewTeachingBox,代码行数:32,代码来源:LexAda.cpp
示例19: classifyWordBullant
static int classifyWordBullant(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char s[100];
s[0] = '\0';
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
s[i] = static_cast<char>(tolower(styler[start + i]));
s[i + 1] = '\0';
}
int lev= 0;
char chAttr = SCE_C_IDENTIFIER;
if (isdigit(s[0]) || (s[0] == '.')){
chAttr = SCE_C_NUMBER;
}
else {
if (keywords.InList(s)) {
chAttr = SCE_C_WORD;
if (strcmp(s, "end") == 0)
lev = -1;
else if (strcmp(s, "method") == 0 ||
strcmp(s, "case") == 0 ||
strcmp(s, "class") == 0 ||
strcmp(s, "debug") == 0 ||
strcmp(s, "test") == 0 ||
strcmp(s, "if") == 0 ||
strcmp(s, "lock") == 0 ||
strcmp(s, "transaction") == 0 ||
strcmp(s, "trap") == 0 ||
strcmp(s, "until") == 0 ||
strcmp(s, "while") == 0)
lev = 1;
}
}
styler.ColourTo(end, chAttr);
return lev;
}
开发者ID:Snake174,项目名称:PipmakAssistant,代码行数:34,代码来源:LexBullant.cpp
示例20: getSeq
/**
* Given a wordset create UYiV yields crossing them and return the best one
* @param ws set of words
* @return best UYiV
*/
shared_ptr<UYiV> Dencoder::getBestUYiV(unordered_set< shared_ptr<Word> > * ws) const
{
shared_ptr<Sequence> seq = getSeq();
shared_ptr<Word> u;
shared_ptr<Word> v;
list <std::pair<int,int> > * wordPosPairs;
WordList* y;
shared_ptr<UYiV> newUYV;
shared_ptr<UYiV> best = NULL;
for(unordered_set< shared_ptr<Word> >::iterator it1 = ws->begin(); it1!= ws->end(); ++it1)
{
u = *it1;
for(unordered_set< shared_ptr<Word> >::iterator it2 = ws->begin(); it2!= ws->end(); ++it2)
{
v = *it2;
//wordPosPairs could be NULL
wordPosPairs = seq->wordPosPairList(u,v);
if(wordPosPairs == NULL || wordPosPairs->size()>=2)
{
y = seq->obtainWordsInside(wordPosPairs, u->getSize());
newUYV = make_shared<UYiV>(u, v, y, wordPosPairs);
if(!(wordPosPairs == NULL || y->getSize() == 0))
{
if(score(best)<=score(newUYV))
{
// cout << "Score best: " << score(best) << endl;
best = newUYV;
// cout << "Score New: " << score(newUYV) << endl;
}
}
}
else
{
delete wordPosPairs;
}
// it = ls.erase(it);
}
}
return best;
}
开发者ID:frandorr,项目名称:Stage,代码行数:51,代码来源:Dencoder.cpp
注:本文中的WordList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论