C++ (Qt)void MainWindow::bufferButtonSave(){ QClipboard *clipboard = QApplication::clipboard(); QString originalText = clipboard->text(); QString countItemFullString; QString countItemString; QStringList itemList; int countItem(0); int countItemFull(0); originalText = originalText.toLower(); originalText.replace(QRegExp("\\W"), " "); originalText.replace(QRegExp("\\d"), " "); originalText.replace(QRegExp("_"), " "); // ЗАДАЧА1: ЭТО НЕ РАБОТАЕТ originalText.replace(QRegExp("[а-я]"), ""); textory.clear(); itemList = originalText.split(QRegExp("\\s+"),QString::SkipEmptyParts); QMap <QString, int> frequencyMap; foreach (QString Item, itemList) ++frequencyMap[Item]; QList<QString> frequencyList; QMapIterator<QString,int> Iter(frequencyMap); while(Iter.hasNext()) { Iter.next(); countItem = Iter.value(); countItemString.setNum(countItem); if(countItem <10 )countItemString = "0000" + countItemString; if(countItem >9 && countItem <100 )countItemString = "000" + countItemString; if(countItem >99 && countItem <1000 )countItemString = "00" + countItemString; if(countItem >999 && countItem <10000 )countItemString = "0" + countItemString; countItemFull = countItemFull + countItem; frequencyList.append(countItemString + "_" + Iter.key() ); } qSort(frequencyList); textory.enableAdd( true ); QString wordItem, wordCount; foreach (QString itm, frequencyList) { wordItem = itm; wordCount = itm; wordItem.remove(0,6); wordCount.remove(5,100); wordCount.remove(QRegExp("^[0]")); wordCount.remove(QRegExp("^[0]")); wordCount.remove(QRegExp("^[0]")); wordCount.remove(QRegExp("^[0]")); textory.addItem( Textory::Item( 1, wordItem + "\t" + wordCount ) ); } countItemFullString.setNum(countItemFull); ui.textoryPaneWidget->getTextoryLabel().setText( "Frequency list (" + countItemFullString + ")" );}
C++ (Qt) originalText = originalText.toLower(); originalText.replace(QRegExp("\\W"), " "); originalText.replace(QRegExp("\\d"), " "); originalText.replace(QRegExp("_"), " "); originalText.replace(QRegExp("[а-я]"), "");
C++ (Qt) itemList = originalText.split(QRegExp("\\s+"),QString::SkipEmptyParts);
C++ (Qt) originalText.replace(QRegExp("[а-я]"), "");
C++ (Qt) originalText.replace(QRegExp("[a-z]"), "");