From 9bca6154fd3e8c49a08adac568a237d15cb75b67 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 31 Aug 2015 06:51:47 +0000 Subject: [PATCH] =?UTF-8?q?d3view=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://192.168.0.12/source@177 8346c931-da38-4b9b-9d4c-e48b93cbd075 --- MorphereAnalyzer/MorphereAnalyzer.pro | 6 +- MorphereAnalyzer/mainwindow.cpp | 27 +- MorphereAnalyzer/mainwindow.h | 4 +- MorphereAnalyzer/widget.cpp | 6 +- MorphereAnalyzer/yalgorithm.cpp | 138 +++++ MorphereAnalyzer/yalgorithm.h | 7 + MorphereAnalyzer/ychildrenthread.cpp | 742 ++++++++++++++++++++++++- MorphereAnalyzer/ychildrenthread.h | 43 ++ MorphereAnalyzer/ymbasicwidget.cpp | 115 +++- MorphereAnalyzer/ymbasicwidget.h | 2 + MorphereAnalyzer/ymfilterchildren.cpp | 472 +++++++++++++++- MorphereAnalyzer/ymfilterchildren.h | 32 ++ MorphereAnalyzer/ymnxnmatrixwidget.cpp | 79 ++- MorphereAnalyzer/ymnxnmatrixwidget.h | 2 +- MorphereAnalyzer/ymonedepthwidget.cpp | 144 ++++- MorphereAnalyzer/ymonedepthwidget.h | 1 + MorphereAnalyzer/ymorpherewidget.cpp | 11 + MorphereAnalyzer/ymorpherewidget.h | 3 + MorphereAnalyzer/ymtwodepthwidget.cpp | 167 +++++- MorphereAnalyzer/ymtwodepthwidget.h | 1 + MorphereAnalyzer/ymuploadwidget.cpp | 123 ++-- 21 files changed, 2007 insertions(+), 118 deletions(-) diff --git a/MorphereAnalyzer/MorphereAnalyzer.pro b/MorphereAnalyzer/MorphereAnalyzer.pro index 1255ea1..447d131 100644 --- a/MorphereAnalyzer/MorphereAnalyzer.pro +++ b/MorphereAnalyzer/MorphereAnalyzer.pro @@ -34,7 +34,8 @@ SOURCES += main.cpp\ ymfilter.cpp \ ymfilterchildren.cpp \ ymtwodepthwidget.cpp \ - ymuploadwidget.cpp + ymuploadwidget.cpp \ + ymplatformwidget.cpp HEADERS += mainwindow.h \ @@ -87,7 +88,8 @@ HEADERS += mainwindow.h \ ymfilter.h \ ymfilterchildren.h \ ymtwodepthwidget.h \ - ymuploadwidget.h + ymuploadwidget.h \ + ymplatformwidget.h FORMS += mainwindow.ui diff --git a/MorphereAnalyzer/mainwindow.cpp b/MorphereAnalyzer/mainwindow.cpp index 7451fcd..a99ae82 100644 --- a/MorphereAnalyzer/mainwindow.cpp +++ b/MorphereAnalyzer/mainwindow.cpp @@ -52,6 +52,7 @@ #include #include #include "ymtwodepthwidget.h" +#include "ymplatformwidget.h" #include #include #include @@ -70,6 +71,7 @@ MainWindow::MainWindow() m_pYMOneDepthWidget = new YMOneDepthWidget; m_pYMTwoDepthWidget = new YMTwoDepthWidget; m_pYMNxNMatrixWidget = new YMNxNMatrixWidget; + m_pYMPlatformWidget = new YMPlatformWidget; p_qwDict = new SDictionary; //p_qwAnalyzer1->setWidget(p_qwDB); @@ -93,13 +95,13 @@ MainWindow::MainWindow() m_ptwResult->addTab(m_pYMOneDepthWidget, "OneDepth"); m_ptwResult->addTab(m_pYMTwoDepthWidget, "TwoDepth"); m_ptwResult->addTab(m_pYMNxNMatrixWidget, "NxNMatrix"); + m_ptwResult->addTab(m_pYMPlatformWidget, "Platform"); - - m_pYMBasicWidget->setTabWidget(m_ptwSource); - m_pYMOneDepthWidget->setTabWidget(m_ptwSource); - m_pYMTwoDepthWidget->setTabWidget(m_ptwSource); - m_pYMNxNMatrixWidget->setTabWidget(m_ptwSource); - + m_pYMBasicWidget->setTabWidget(m_ptwSource); + m_pYMOneDepthWidget->setTabWidget(m_ptwSource); + m_pYMTwoDepthWidget->setTabWidget(m_ptwSource); + m_pYMNxNMatrixWidget->setTabWidget(m_ptwSource); + m_pYMPlatformWidget->setTabWidget(m_ptwSource); m_pUploadWidget->setResultTabWidget(m_ptwResult); m_pUploadWidget->setSourceTabWidget(m_ptwSource); @@ -112,6 +114,11 @@ MainWindow::MainWindow() widget->setLayout(layout); //! [1] + actD3View = new QAction(tr("D3View"), this); + actD3View->setShortcut(Qt::Key_0 | Qt::CTRL); + connect(actD3View, SIGNAL(triggered()), this, SLOT(slotD3View())); + this->addAction(actD3View); + //! [2] createActions(); createMenus(); @@ -120,11 +127,6 @@ MainWindow::MainWindow() statusBar()->showMessage(message); //test = new QWebView(this); - actD3View = new QAction(tr("D3View"), this); - actD3View->setShortcut(Qt::Key_0 | Qt::CTRL); - connect(actD3View, SIGNAL(triggered()), this, SLOT(slotD3View())); - this->addAction(actD3View); - setWindowTitle(tr("Morphere Analyzer")); setMinimumSize(800, 600); resize(800, 600); @@ -221,6 +223,9 @@ void MainWindow::createMenus() menuShowUpload = menuBar()->addMenu(tr("ShowUpload")); menuShowUpload->addAction(actShowUpload); + menuD3View = menuBar()->addMenu(tr("D3View")); + menuD3View->addAction(actD3View); + } //! [12] diff --git a/MorphereAnalyzer/mainwindow.h b/MorphereAnalyzer/mainwindow.h index b34dd47..a69e811 100644 --- a/MorphereAnalyzer/mainwindow.h +++ b/MorphereAnalyzer/mainwindow.h @@ -119,7 +119,7 @@ private: YMorphereWidget *m_pYMOneDepthWidget; YMorphereWidget *m_pYMNxNMatrixWidget; YMorphereWidget *m_pYMTwoDepthWidget; - + YMorphereWidget *m_pYMPlatformWidget; QAction *actDBNew; QAction *actDBCsvImport; @@ -139,6 +139,8 @@ private: QMenu *menuDictionary; QMenu *menuTestUpload; QMenu *menuShowUpload; + QMenu *menuD3View; + QAction *actD3View; QAction *actShowUpload; diff --git a/MorphereAnalyzer/widget.cpp b/MorphereAnalyzer/widget.cpp index 50574e7..b612b9f 100644 --- a/MorphereAnalyzer/widget.cpp +++ b/MorphereAnalyzer/widget.cpp @@ -1569,7 +1569,7 @@ void Widget::FileImport() for(int i = 0; i < m_vecColumn.size(); i++) { - strlistHeader << m_vecColumn.at(i).at(E_COLUMN_DATABASE); + strlistHeader << m_vecColumn.at(i).at(E_COLUMN_NAME); } @@ -1600,7 +1600,7 @@ void Widget::FileImport() { if (strlistHeader.contains(strings.at(i))) { - if (m_vecColumn.at(j).at(E_COLUMN_DATABASE) == strings.at(i).trimmed()) + if (m_vecColumn.at(j).at(E_COLUMN_NAME) == strings.at(i).trimmed()) { wgHeader << j; } @@ -1660,7 +1660,7 @@ void Widget::FileExport() out << "#Head#,"; foreach(QStringList strList,m_vecColumn) - out << strList.at(E_COLUMN_DATABASE) << ","; + out << strList.at(E_COLUMN_NAME) << ","; out << endl; m_pProgress->setRange(0,pCurrent->rowCount()-1); diff --git a/MorphereAnalyzer/yalgorithm.cpp b/MorphereAnalyzer/yalgorithm.cpp index d7e475b..efd9db1 100644 --- a/MorphereAnalyzer/yalgorithm.cpp +++ b/MorphereAnalyzer/yalgorithm.cpp @@ -77,6 +77,12 @@ YAlgorithm* YAFactory::getYAlgorithm(QMap mapParam) m_mapAlgorithm.insert("basic", new YAlgorithm()); Algorithm = m_mapAlgorithm.value("basic"); } + else if(mapParam.value("Algorithm").compare("platform", Qt::CaseInsensitive) == 0) + { + if(!m_mapAlgorithm.contains("platform")) + m_mapAlgorithm.insert("platform", new YPlatformAlgorithm()); + Algorithm = m_mapAlgorithm.value("platform"); + } else { Algorithm = NULL; @@ -379,3 +385,135 @@ void YTwoDepthAlgorithm::Start() } +void YPlatformAlgorithm::Start() +{ + if(m_mapParam.isEmpty()) + return; + + bool okThread = false; + int nThread = m_mapParam.value("Thread").trimmed().toInt(&okThread); + + if(!okThread) + setThreadNumber(1); + else + setThreadNumber(nThread); + + QMapmapParam = m_mapParam; + + mapParam["Algorithm"] = "platformone"; + + + m_pYMThread = new YMorphereThread*[getThreadNumber()]; + for(int i = 0; i < getThreadNumber(); i++) + { + m_pYMThread[i] = ThreadFactory::getThread(mapParam); + m_pYMThread[i]->setDataAlgorithmInterface(m_pDAInterface); + m_pYMThread[i]->setMutex(&mutex); + m_pYMThread[i]->setParam(mapParam); + } + for(int i = 0;i < getThreadNumber(); i++) + { + m_pYMThread[i]->start(); + } + for(int i = 0;i < getThreadNumber(); i++) + { + m_pYMThread[i]->wait(); + } + + m_mapThreadResult = new QMap*[getThreadNumber()]; + for(int i = 0; i < getThreadNumber(); i++) + { + m_mapThreadResult[i] = new QMap(); + } + for(int i = 0; i < getThreadNumber(); i++) + { + *m_mapThreadResult[i] = m_pYMThread[i]->getResult(); + m_pYMThread[i]->clearResult(); + } + + for(int i = 0;i < getThreadNumber(); i++) + { + delete m_pYMThread[i]; + } + delete[] m_pYMThread; + + EmergeThreadResult(); + + YMFilter* ymfilter = YMFilterFactory::getFilter(mapParam); + //qDebug() << "EXEC"; + if(ymfilter != NULL) + { + ymfilter->setParam(m_mapParam); + m_mapTotalResult = ymfilter->Exec(m_mapTotalResult); + } + delete ymfilter; + + + + + QList listKeys = m_mapTotalResult.keys(); + + QString strKeys; + + for(int i = 0; i < listKeys.count(); i++) + { + strKeys += (listKeys.at(i).trimmed() + " "); + } + + strKeys = strKeys.trimmed(); + + m_mapTotalResult.clear(); + + m_mapParam.insert("OneDepthKeys", strKeys); + m_pDAInterface->reset(); + m_pYMThread = new YMorphereThread*[getThreadNumber()]; + for(int i = 0; i < getThreadNumber(); i++) + { + m_pYMThread[i] = ThreadFactory::getThread(m_mapParam); + m_pYMThread[i]->setDataAlgorithmInterface(m_pDAInterface); + m_pYMThread[i]->setMutex(&mutex); + m_pYMThread[i]->setParam(m_mapParam); + } + for(int i = 0;i < getThreadNumber(); i++) + { + m_pYMThread[i]->start(); + } + for(int i = 0;i < getThreadNumber(); i++) + { + m_pYMThread[i]->wait(); + } + + m_mapThreadResult = new QMap*[getThreadNumber()]; + for(int i = 0; i < getThreadNumber(); i++) + { + m_mapThreadResult[i] = new QMap(); + } + for(int i = 0; i < getThreadNumber(); i++) + { + *m_mapThreadResult[i] = m_pYMThread[i]->getResult(); + m_pYMThread[i]->clearResult(); + } + + for(int i = 0;i < getThreadNumber(); i++) + { + delete m_pYMThread[i]; + } + delete[] m_pYMThread; + + EmergeThreadResult(); + + ymfilter = YMFilterFactory::getFilter(m_mapParam); + //qDebug() << "EXEC"; + if(ymfilter != NULL) + { + qDebug() << "totalresult: " << m_mapTotalResult.size(); + ymfilter->setParam(m_mapParam); + m_mapTotalResult = ymfilter->Exec(m_mapTotalResult); + } + delete ymfilter; + + + + +} + diff --git a/MorphereAnalyzer/yalgorithm.h b/MorphereAnalyzer/yalgorithm.h index ff29c58..6179c42 100644 --- a/MorphereAnalyzer/yalgorithm.h +++ b/MorphereAnalyzer/yalgorithm.h @@ -68,5 +68,12 @@ public: void Start(); }; +class YPlatformAlgorithm:public YAlgorithm +{ +public: + void Start(); +}; + + #endif // YALGORITHM diff --git a/MorphereAnalyzer/ychildrenthread.cpp b/MorphereAnalyzer/ychildrenthread.cpp index 9b351d7..2c5526e 100644 --- a/MorphereAnalyzer/ychildrenthread.cpp +++ b/MorphereAnalyzer/ychildrenthread.cpp @@ -19,6 +19,10 @@ YMorphereThread* ThreadFactory::getThread(QMap mapParam) { return new YTwoDepthMThread(); } + else if(mapParam.value("Algorithm").trimmed().compare("platformone", Qt::CaseInsensitive) == 0) + { + return new YPlatformOneMThread(); + } else if(mapParam.value("Algorithm").trimmed().compare("platform", Qt::CaseInsensitive) == 0) { return new YPlatformMThread(); @@ -1072,18 +1076,6 @@ void YTwoDepthMThread::parseParam() } - -void YPlatformMThread::run() -{ - -} - -void YPlatformMThread::parseParam() -{ - -} - - void YIDMThread::run() { @@ -1362,3 +1354,729 @@ void YNNMatrixMThread::parseParam() } + +void YPlatformOneMThread::parseParam() +{ + + userdict = m_mapParam.value("UserDict"); + + m_nArticle = m_mapParam.value("Article").toInt(); + + m_nTitleBody = m_mapParam.value("TitleBody").toInt(); + m_nPeriod = m_mapParam.value("Period").toInt(); + + m_nDateStart = m_mapParam.value("DateStart").toInt(); + m_nDateEnd = m_mapParam.value("DateEnd").toInt(); + + m_bDateAll = true; + + if(m_mapParam.value("DateALL") == "true") + m_bDateAll = true; + else + m_bDateAll = false; + + m_slMorphereList = m_mapParam.value("MorphereList").split(" "); + + m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed(); + if(m_mapParam.value("CountMethod") == "Duplicate") + m_bDuplicate = true; + else + m_bDuplicate = false; + + m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed(); + + if(m_strRecentPeriod == "None") + { + + } + else if(m_strRecentPeriod == "Days") + { + int nDate = m_mapParam.value("RecentDate").trimmed().toInt(); + QDateTime today = QDateTime::currentDateTime(); + QDateTime startday = today.addDays(-(nDate)); + startday = startday.addDays(1); + m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt(); + m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt(); + m_bDateAll = false; + } + else if(m_strRecentPeriod == "Weeks") + { + int nDate = m_mapParam.value("RecentDate").trimmed().toInt(); + QDateTime today = QDateTime::currentDateTime(); + QDateTime startday = today.addDays(-(nDate*7)); + startday = startday.addDays(1); + m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt(); + m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt(); + m_bDateAll = false; + } + else if(m_strRecentPeriod == "Months") + { + int nDate = m_mapParam.value("RecentDate").trimmed().toInt(); + QDateTime today = QDateTime::currentDateTime(); + QDateTime startday = today.addMonths(-(nDate)); + startday = startday.addDays(1); + m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt(); + m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt(); + m_bDateAll = false; + } + else if(m_strRecentPeriod == "Years") + { + int nDate = m_mapParam.value("RecentDate").trimmed().toInt(); + QDateTime today = QDateTime::currentDateTime(); + QDateTime startday = today.addYears(-(nDate)); + startday = startday.addDays(1); + m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt(); + m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt(); + m_bDateAll = false; + } +} + + + + +void YPlatformOneMThread::run() +{ + typedef mecab_t* (*mecab_new_fun)(int,char**); + typedef const char* (*mecab_sparse_tostr_fun)(mecab_t *mecab, const char *str); + typedef void (*mecab_destroy_fun)(mecab_t *mecab); + + mecab_t *mecab; + mecab_new_fun mecab_new = (mecab_new_fun)QLibrary::resolve("libmecab.dll","mecab_new"); + mecab_sparse_tostr_fun mecab_sparse_tostr = (mecab_sparse_tostr_fun)QLibrary::resolve("libmecab.dll","mecab_sparse_tostr"); + + parseParam(); + + if(userdict.length() < 1) + { + /* + char *t[] = {"RRR","-d","dic"}; + int int_t = 3; + */ + + char a[] = "RRR"; + char b[] = "-d"; + char c[] = "dic"; + char *t[3]; + t[0] = a; + t[1] = b; + t[2] = c; + int int_t = 3; + + mecab = mecab_new(int_t, t); + } + else + { + char *cstr = new char[userdict.toStdString().length() + 1]; + strcpy(cstr, userdict.toStdString().c_str()); + /* + char **t = {"RRR","-d","dic","-u",cstr}; + int int_t = 5; + */ + char a[] = "RRR"; + char b[] = "-d"; + char c[] = "dic"; + char d[] = "-u"; + + char *t[5]; + t[0] = a; + t[1] = b; + t[2] = c; + t[3] = d; + t[4] = cstr; + int int_t = 5; + + mecab = mecab_new(int_t, t); + delete[] cstr; + } + mecab_destroy_fun mecab_destroy = (mecab_destroy_fun)QLibrary::resolve("libmecab.dll","mecab_destroy"); + + + + //qDebug() << num; + + int nDate = 0; + while(true) + { + QString strTitle; + QString strBody; + QString strDate; + QString strData; + QString strPlatformTitle; + QString strArticle; + QString strPlatformName; + QString strPlatformForm; + { + mutex->lock(); + if(!m_pDAInterface->hasNext()) + { + mutex->unlock(); + break; + } + strTitle = m_pDAInterface->getArticleTitle(); + strDate = m_pDAInterface->getArticleDate(); + strPlatformTitle = m_pDAInterface->getPlatformTitle(); + strBody = m_pDAInterface->getArticleData(); + strArticle = m_pDAInterface->getArticleForm(); + strPlatformName = m_pDAInterface->getPlatformName().trimmed(); + strPlatformForm = m_pDAInterface->getPlatformForm().trimmed(); + + m_pDAInterface->next(); + mutex->unlock(); + } + + + bool bContinue = true; + { + switch(m_nArticle) + { + case 0: + break; + case 1: + { + if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0) + bContinue = false; + break; + } + case 2: + { + if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0) + bContinue = false; + break; + } + } + } + + if(!bContinue) + continue; + + if(strPlatformForm.trimmed().isEmpty()) + continue; + + if(strPlatformName.trimmed().isEmpty()) + continue; + + + { + switch(m_nTitleBody) + { + case 0: + { + strData = strTitle; + break; + } + case 1: + { + strData = strBody; + break; + } + case 2: + { + strData = strTitle + "\n" + strBody; + break; + } + case 3: + strData = strPlatformTitle; + break; + } + strTitle.clear(); + strBody.clear(); + strPlatformTitle.clear(); + } + + //if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive)) + if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive)) + continue; + + if(strDate.length() < 11) + continue; + + strDate = strDate.left(11); + if(strDate.trimmed().length()<10) + { + nDate = 0; + } + else + { + strDate = strDate.replace("-","").trimmed(); + if(strDate.length() < 8) + { + nDate = 0; + } + else + nDate = strDate.toInt(); + } + + if(!m_bDateAll) + { + if(nDate < m_nDateStart || m_nDateEnd < nDate) + continue; + } + + QString m_strDate; + QString m_strKeyword; + QString m_strMorphere; + + switch(m_nPeriod) + { + case 0: + { + m_strDate = "ALL"; + break; + } + case 1: + { + m_strDate = "D" + QString::number(nDate); + break; + } + case 2: + { + /* + QDate tempdate = QDate(nDate/10000, (nDate%10000)/100, nDate%100); + mapkey.strDate = "W" + QString::number(nDate/10000); + if(tempdate.weekNumber() < 10) + mapkey.strDate += "0"; + mapkey.strDate += QString::number(tempdate.weekNumber()); + */ + m_strDate = getWeeksInMonth(nDate); + break; + } + case 3: + { + m_strDate = "M"; + if((nDate/100) < 10) + m_strDate += "0"; + m_strDate += QString::number(nDate/100); + break; + } + } + + QString strAnalyzedLine = QString::fromStdString(mecab_sparse_tostr(mecab, strData.toStdString().c_str())) + "\n"; + QStringList strListAll = strAnalyzedLine.split("\n",QString::SkipEmptyParts); + QMap mapResult; + + foreach(QString strLine, strListAll) + { + QStringList strListLine = strLine.split("\t"); + if(strListLine.size() < 2) + continue; + QStringList strpumsa = strListLine.at(1).trimmed().split(","); + foreach(QString strMorphere, m_slMorphereList) + { + if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive)) + { + m_strKeyword = strListLine.at(0).toLower(); + m_strMorphere = strMorphere; + QString strkey = m_strDate + "~!@" + strPlatformName + "~!@" + strPlatformForm + "~!@" + m_strMorphere + "~!@" + m_strKeyword; + if(mapResult.contains(strkey)) + { + (mapResult)[strkey]++; + } + + else + { + mapResult.insert(strkey,1); + } + } + } + } + + if(!m_bDuplicate) + { + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + mapResult[iterPos.key()] = 1; + } + } + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + if(m_mapResult.contains(iterPos.key())) + { + m_mapResult[iterPos.key()] += iterPos.value(); + } + else + { + m_mapResult.insert(iterPos.key(), iterPos.value()); + } + } + + + + //if(m_bDateAll) + + //qDebug() << num << " : " << strData; + } + + mecab_destroy(mecab); + +} + + + + + +void YPlatformMThread::parseParam() +{ + userdict = m_mapParam.value("UserDict"); + + m_nArticle = m_mapParam.value("Article").toInt(); + + m_nTitleBody = m_mapParam.value("TitleBody").toInt(); + m_nPeriod = m_mapParam.value("Period").toInt(); + + m_nDateStart = m_mapParam.value("DateStart").toInt(); + m_nDateEnd = m_mapParam.value("DateEnd").toInt(); + + m_bDateAll = true; + + if(m_mapParam.value("DateALL") == "true") + m_bDateAll = true; + else + m_bDateAll = false; + + m_slMorphereList = m_mapParam.value("MorphereList").split(" "); + + m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed(); + + m_slOneDepthKeys = m_mapParam.value("OneDepthKeys").split(" "); + if(m_mapParam.value("CountMethod") == "Duplicate") + m_bDuplicate = true; + else + m_bDuplicate = false; + + + m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed(); + + if(m_strRecentPeriod == "None") + { + + } + else if(m_strRecentPeriod == "Days") + { + int nDate = m_mapParam.value("RecentDate").trimmed().toInt(); + QDateTime today = QDateTime::currentDateTime(); + QDateTime startday = today.addDays(-(nDate)); + startday = startday.addDays(1); + m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt(); + m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt(); + m_bDateAll = false; + } + else if(m_strRecentPeriod == "Weeks") + { + int nDate = m_mapParam.value("RecentDate").trimmed().toInt(); + QDateTime today = QDateTime::currentDateTime(); + QDateTime startday = today.addDays(-(nDate*7)); + startday = startday.addDays(1); + m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt(); + m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt(); + m_bDateAll = false; + } + else if(m_strRecentPeriod == "Months") + { + int nDate = m_mapParam.value("RecentDate").trimmed().toInt(); + QDateTime today = QDateTime::currentDateTime(); + QDateTime startday = today.addMonths(-(nDate)); + startday = startday.addDays(1); + m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt(); + m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt(); + m_bDateAll = false; + } + else if(m_strRecentPeriod == "Years") + { + int nDate = m_mapParam.value("RecentDate").trimmed().toInt(); + QDateTime today = QDateTime::currentDateTime(); + QDateTime startday = today.addYears(-(nDate)); + startday = startday.addDays(1); + m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt(); + m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt(); + m_bDateAll = false; + } + +} + +void YPlatformMThread::run() +{ + typedef mecab_t* (*mecab_new_fun)(int,char**); + typedef const char* (*mecab_sparse_tostr_fun)(mecab_t *mecab, const char *str); + typedef void (*mecab_destroy_fun)(mecab_t *mecab); + + mecab_t *mecab; + mecab_new_fun mecab_new = (mecab_new_fun)QLibrary::resolve("libmecab.dll","mecab_new"); + mecab_sparse_tostr_fun mecab_sparse_tostr = (mecab_sparse_tostr_fun)QLibrary::resolve("libmecab.dll","mecab_sparse_tostr"); + + parseParam(); + + if(userdict.length() < 1) + { + /* + char *t[] = {"RRR","-d","dic"}; + int int_t = 3; + */ + + char a[] = "RRR"; + char b[] = "-d"; + char c[] = "dic"; + char *t[3]; + t[0] = a; + t[1] = b; + t[2] = c; + int int_t = 3; + + mecab = mecab_new(int_t, t); + } + else + { + char *cstr = new char[userdict.toStdString().length() + 1]; + strcpy(cstr, userdict.toStdString().c_str()); + /* + char **t = {"RRR","-d","dic","-u",cstr}; + int int_t = 5; + */ + char a[] = "RRR"; + char b[] = "-d"; + char c[] = "dic"; + char d[] = "-u"; + + char *t[5]; + t[0] = a; + t[1] = b; + t[2] = c; + t[3] = d; + t[4] = cstr; + int int_t = 5; + + mecab = mecab_new(int_t, t); + delete[] cstr; + } + mecab_destroy_fun mecab_destroy = (mecab_destroy_fun)QLibrary::resolve("libmecab.dll","mecab_destroy"); + + + + //qDebug() << num; + + int nDate = 0; + while(true) + { + QString strTitle; + QString strBody; + QString strDate; + QString strData; + QString strPlatformTitle; + QString strArticle; + QString strPlatformName; + QString strPlatformForm; + { + mutex->lock(); + if(!m_pDAInterface->hasNext()) + { + mutex->unlock(); + break; + } + strTitle = m_pDAInterface->getArticleTitle(); + strDate = m_pDAInterface->getArticleDate(); + strPlatformTitle = m_pDAInterface->getPlatformTitle(); + strBody = m_pDAInterface->getArticleData(); + strArticle = m_pDAInterface->getArticleForm(); + strPlatformName = m_pDAInterface->getPlatformName().trimmed(); + strPlatformForm = m_pDAInterface->getPlatformForm().trimmed(); + + m_pDAInterface->next(); + mutex->unlock(); + } + + bool bContinue = true; + { + switch(m_nArticle) + { + case 0: + break; + case 1: + { + if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0) + bContinue = false; + break; + } + case 2: + { + if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0) + bContinue = false; + break; + } + } + } + + if(!bContinue) + continue; + + + if(strPlatformForm.trimmed().isEmpty()) + continue; + + if(strPlatformName.trimmed().isEmpty()) + continue; + + + + + { + switch(m_nTitleBody) + { + case 0: + { + strData = strTitle; + break; + } + case 1: + { + strData = strBody; + break; + } + case 2: + { + strData = strTitle + "\n" + strBody; + break; + } + case 3: + strData = strPlatformTitle; + break; + } + strTitle.clear(); + strBody.clear(); + strPlatformTitle.clear(); + } + + //if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive)) + if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive)) + continue; + + if(strDate.length() < 11) + continue; + + strDate = strDate.left(11); + if(strDate.trimmed().length()<10) + { + nDate = 0; + } + else + { + strDate = strDate.replace("-","").trimmed(); + if(strDate.length() < 8) + { + nDate = 0; + } + else + nDate = strDate.toInt(); + } + + if(!m_bDateAll) + { + if(nDate < m_nDateStart || m_nDateEnd < nDate) + continue; + } + + QString m_strDate; + QString m_strKeyword; + QString m_strMorphere; + + switch(m_nPeriod) + { + case 0: + { + m_strDate = "ALL"; + break; + } + case 1: + { + m_strDate = "D" + QString::number(nDate); + break; + } + case 2: + { + /* + QDate tempdate = QDate(nDate/10000, (nDate%10000)/100, nDate%100); + mapkey.strDate = "W" + QString::number(nDate/10000); + if(tempdate.weekNumber() < 10) + mapkey.strDate += "0"; + mapkey.strDate += QString::number(tempdate.weekNumber()); + */ + m_strDate = getWeeksInMonth(nDate); + break; + } + case 3: + { + m_strDate = "M"; + if((nDate/100) < 10) + m_strDate += "0"; + m_strDate += QString::number(nDate/100); + break; + } + } + + QString strAnalyzedLine = QString::fromStdString(mecab_sparse_tostr(mecab, strData.toStdString().c_str())) + "\n"; + QStringList strListAll = strAnalyzedLine.split("\n",QString::SkipEmptyParts); + + QMap mapResult; + + foreach(QString strLine, strListAll) + { + QStringList strListLine = strLine.split("\t"); + if(strListLine.size() < 2) + continue; + QStringList strpumsa = strListLine.at(1).trimmed().split(","); + foreach(QString strMorphere, m_slMorphereList) + { + if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive)) + { + m_strKeyword = strListLine.at(0).toLower(); + m_strMorphere = strMorphere; + QString strkey = m_strDate + "~!@" + strPlatformName + "~!@" + strPlatformForm + "~!@" + m_strMorphere + "~!@" + m_strKeyword; + if(mapResult.contains(strkey)) + { + (mapResult)[strkey]++; + } + + else + { + mapResult.insert(strkey,1); + } + } + } + } + + if(!m_bDuplicate) + { + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + mapResult[iterPos.key()] = 1; + } + } + + + foreach(QString str, m_slOneDepthKeys) + { + //qDebug() << "str :" << str; + if(mapResult.contains(str)) + { + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + if(iterPos.key() == str) + continue; + QString key = iterPos.key(); + QStringList slkey = key.split("~!@", QString::SkipEmptyParts); + int nLength = slkey.length(); + QString strkey = str + "~!@" + slkey.at(nLength - 2) + "~!@" + slkey.at(nLength - 1); + if(m_mapResult.contains(strkey)) + { + m_mapResult[strkey] += iterPos.value(); + //qDebug() << strkey; + } + else + { + m_mapResult.insert(strkey, iterPos.value()); + } + } + } + } + } + mecab_destroy(mecab); +} diff --git a/MorphereAnalyzer/ychildrenthread.h b/MorphereAnalyzer/ychildrenthread.h index 74304ca..1980c4d 100644 --- a/MorphereAnalyzer/ychildrenthread.h +++ b/MorphereAnalyzer/ychildrenthread.h @@ -90,12 +90,55 @@ public: class YPlatformMThread:public YMorphereThread { Q_OBJECT + +private: + QString userdict; + int m_nTitleBody; + int m_nPeriod; + unsigned int m_nDateStart; + unsigned int m_nDateEnd; + bool m_bDateAll; + QStringList m_slMorphereList; + QString m_strCKeyword; + QStringList m_slOneDepthKeys; + bool m_bDuplicate; + QString m_strRecentPeriod; + int m_nArticle; + protected: void run(); public: void parseParam(); }; + +class YPlatformOneMThread:public YMorphereThread +{ + Q_OBJECT +private: + //QString getWeeksInMonth(unsigned int _nDate); + + + + QString userdict; + int m_nTitleBody; + int m_nPeriod; + unsigned int m_nDateStart; + unsigned int m_nDateEnd; + bool m_bDateAll; + QStringList m_slMorphereList; + QString m_strCKeyword; + bool m_bDuplicate; + QString m_strRecentPeriod; + int m_nArticle; +protected: + void run(); +public: + void parseParam(); +}; + + + class YIDMThread:public YMorphereThread { Q_OBJECT diff --git a/MorphereAnalyzer/ymbasicwidget.cpp b/MorphereAnalyzer/ymbasicwidget.cpp index eb730d5..16c063f 100644 --- a/MorphereAnalyzer/ymbasicwidget.cpp +++ b/MorphereAnalyzer/ymbasicwidget.cpp @@ -31,6 +31,8 @@ YMBasicWidget::YMBasicWidget(QWidget *parent) m_strlistMorphereko << "NNG" <<"NNP"<<"NNB"<<"NNBC"<<"NR"<<"NP"<<"VV"<<"VA"<<"VX"<<"VCP"<<"VCN"<<"MM"<<"MAG"<<"MAJ"<<"IC"<<"JKS"<<"JKC"<<"JKG"<<"JKO"<<"JKB"<<"JKV"<<"JKQ"<<"JX"<<"JC"<<"EP"<<"EF"<<"EC"<<"ETN"<<"ETM"<<"XPN"<<"XSN"<<"XSV"<<"XSA"<<"XR"<<"SF"<<"SE"<<"SSO"<<"SSC"<<"SC"<<"SY"<<"SL"<<"SH"<<"SN"; } + m_strName = "basic"; + QVBoxLayout *vMainLayout = new QVBoxLayout; vMainLayout->setAlignment(Qt::AlignVCenter); QVBoxLayout *vboxlayout = new QVBoxLayout; @@ -709,6 +711,118 @@ void YMBasicWidget::clearView() m_mapViewResult.clear(); } +void YMBasicWidget::setParam(QString strJson) +{ + + SJson json; + { + + QString strMorphere = json.Get(strJson, "MorphereList"); + QStringList slMorphere = strMorphere.split(" ", QString::SkipEmptyParts); + + for(int i = 0; i < m_plwMorphereAdd->count(); i++) + { + m_plwMorphereAdd->item(i)->setHidden(true); + } + + for(int i = 0; i < m_plwMorphereAdd->count(); i++) + { + foreach(QString morphere, slMorphere) + { + if(m_plwMorphereAdd->item(i)->data(Qt::UserRole).toString().compare(morphere, Qt::CaseInsensitive) == 0) + { + m_plwMorphereAdd->item(i)->setHidden(false); + } + } + } + } + + { + int nThread = json.Get(strJson, "Thread").toInt(); + for(int i = 0; i < m_pcbThread->count(); i++) + { + //qDebug() << m_pcbThread->itemData(i).toInt(); + if(m_pcbThread->itemText(i).trimmed().toInt() == nThread) + { + m_pcbThread->setCurrentIndex(i); + break; + } + } + } + + { + QString strCountMethod = json.Get(strJson, "CountMethod").trimmed(); + for(int i = 0; i < m_pcbCountMethod->count(); i++) + { + //qDebug() << m_pcbThread->itemData(i).toInt(); + if(m_pcbCountMethod->itemText(i).trimmed().compare(strCountMethod) == 0) + { + m_pcbCountMethod->setCurrentIndex(i); + break; + } + } + } + + { + QString strRecentPeriod = json.Get(strJson, "RecentPeriod").trimmed(); + for(int i = 0; i < m_pcbDuring->count(); i++) + { + //qDebug() << m_pcbThread->itemData(i).toInt(); + if(m_pcbDuring->itemText(i).trimmed().compare(strRecentPeriod) == 0) + { + m_pcbDuring->setCurrentIndex(i); + break; + } + } + } + { + int nPeriod = json.Get(strJson, "Period").toInt(); + m_pcbPeriod->setCurrentIndex(nPeriod); + } + { + int nBodyTitle = json.Get(strJson, "TitleBody").toInt(); + m_pcbData->setCurrentIndex(nBodyTitle); + } + { + QString strDateAll = json.Get(strJson, "DateALL").trimmed(); + if(strDateAll.compare("true",Qt::CaseInsensitive) == 0) + { + m_pcbDate->setCurrentIndex(0); + } + else + { + m_pcbDate->setCurrentIndex(1); + } + } + { + QString strRecentDate = json.Get(strJson, "RecentDate"); + m_pleDates->setText(strRecentDate); + } + { + + m_pdeStart->setDate(QDate::fromString(json.Get(strJson,"DateStart"),"yyyyMMdd")); + m_pdeEnd->setDate(QDate::fromString(json.Get(strJson,"DateEnd"),"yyyyMMdd")); + } + { + QString userdict = json.Get(strJson, "UserDict"); + if(!userdict.isEmpty()) + { + + m_pcbDictionary->clear(); + QStringList sluserdict = userdict.split(","); + foreach(QString dict, sluserdict) + { + m_pcbDictionary->addItem(dict); + } + } + else + { + m_pcbDictionary->clear(); + } + } +} + + void YMBasicWidget::SortViewResult() { @@ -782,7 +896,6 @@ void YMBasicWidget::SortViewResult() } } - void YMBasicWidget::ViewResult() { SortViewResult(); diff --git a/MorphereAnalyzer/ymbasicwidget.h b/MorphereAnalyzer/ymbasicwidget.h index a4d7c67..be90e33 100644 --- a/MorphereAnalyzer/ymbasicwidget.h +++ b/MorphereAnalyzer/ymbasicwidget.h @@ -40,6 +40,8 @@ public: QString getUserDictList(); void SaveFile(); void SaveFileSimple(); + void setParam(QString strJson); + private: // Data diff --git a/MorphereAnalyzer/ymfilterchildren.cpp b/MorphereAnalyzer/ymfilterchildren.cpp index 028f2ad..39af2cc 100644 --- a/MorphereAnalyzer/ymfilterchildren.cpp +++ b/MorphereAnalyzer/ymfilterchildren.cpp @@ -16,10 +16,14 @@ YMFilterFactory::~YMFilterFactory() YMFilter* YMFilterFactory::getFilter(QMap mapParam) { - if(mapParam.value("Algorithm").trimmed() == "onedepth") + if(mapParam.value("Algorithm").trimmed().compare("onedepth", Qt::CaseInsensitive) == 0) return new YMOneDepthFilter(); - else if(mapParam.value("Algorithm").trimmed() == "twodepth") + else if(mapParam.value("Algorithm").trimmed().compare("twodepth", Qt::CaseInsensitive) == 0) return new YMTwoDepthFilter(); + else if(mapParam.value("Algorithm").trimmed().compare("platformone", Qt::CaseInsensitive) == 0) + return new YMPlatformOneFilter(); + else if(mapParam.value("Algorithm").trimmed().compare("platform", Qt::CaseInsensitive) == 0) + return new YMPlatformFilter(); else return NULL; } @@ -377,6 +381,468 @@ QMap YMTwoDepthFilter::RankFilterALL(QMap mapResult) } + //qDebug() << slkey.at(0); + if(Result.contains(key)) + { + Result[key].insertMulti(iterPos.value(), iterPos.key()); + } + else + { + QMap qLast; + qLast.insert(iterPos.value(), iterPos.key()); + Result.insert(key, qLast); + } + + } + + int nRank = m_mapParam.value("RankFilterAll2").toInt(); + + qDebug() << "TwoDepth nRank: " << nRank; + + QMap totalResult; + //qDebug() << "rankfilter:" << nRank; + for(QMap >::iterator iterPos = Result.begin(); iterPos != Result.end(); iterPos++) + { + QMapIterator iter(Result[iterPos.key()]); + iter.toBack(); + int i = 0; + while(iter.hasPrevious()) + { + if(i >= nRank) + break; + + iter.previous(); + totalResult.insertMulti(iter.value(), iter.key()); + + i++; + } + } + + return totalResult; +} + + + +/* + * class YMPlatformOneFilter + */ + + + +YMPlatformOneFilter::YMPlatformOneFilter() +{ + +} + +YMPlatformOneFilter::~YMPlatformOneFilter() +{ + +} + +QMap YMPlatformOneFilter::Extractor(QMap mapResult) +{ + QMap totalResult; + QStringList slExtractor; + QRegExp rx("[\\s,.;]"); + slExtractor = m_mapParam.value("Extractor").split(rx); + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts); + int nLastIndex = slkey.length() - 1; + + foreach(QString str, slExtractor) + { + if(slkey.at(nLastIndex).compare(str.trimmed(), Qt::CaseInsensitive) == 0) + totalResult.insert(iterPos.key(), iterPos.value()); + } + } + return totalResult; +} + +QMap YMPlatformOneFilter::KeywordLengthFilter(QMap mapResult) +{ + QMap totalResult; + + int nLength = m_mapParam.value("KeywordLengthFilter").toInt(); + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts); + int nLastIndex = slkey.length() - 1; + + if(slkey.at(nLastIndex).trimmed().length() >= nLength) + { + totalResult.insert(iterPos.key(), iterPos.value()); + //qDebug() << iterPos.key() << " :" << iterPos.value(); + } + + } + return totalResult; +} + +QMap YMPlatformOneFilter::KeywordFilter(QMap mapResult) +{ + QMap totalResult; + QRegExp rx("[\\s,;]"); + QStringList slKeywordFilter = m_mapParam.value("KeywordFilter").split(rx); + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts); + int nLastIndex = slkey.length() - 1; + //qDebug() << "nLastIndex: " << nLastIndex; + bool bChecked = true; + foreach(QString str, slKeywordFilter) + { + if(slkey.at(nLastIndex).compare(str.trimmed(), Qt::CaseInsensitive) == 0) + { + bChecked = false; + break; + } + } + if(bChecked) + totalResult.insert(iterPos.key(), iterPos.value()); + } + + return totalResult; +} + + +QMap YMPlatformOneFilter::RankFilterSeparated(QMap mapResult) +{ + QMap > > m_mapViewResult; + int nRank = m_mapParam.value("RankFilterSeparated").toInt(); + + //qDebug() << "nRank" <::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + int count = iterPos.value(); + QStringList strlistKey = strkey.split("~!@"); + QString strDate = strlistKey.at(0); + QString strMorphere = strlistKey.at(1); + QString strKeyword = strlistKey.at(2); + + if(m_mapViewResult.contains(strDate)) + { + if(m_mapViewResult.value(strDate).contains(strMorphere)) + { + m_mapViewResult[(strDate)][(strMorphere)].insertMulti(count, strKeyword); + } + else + { + QMap qLast; + qLast.insert(count, strKeyword); + m_mapViewResult[(strDate)].insert(strMorphere, qLast); + } + } + else + { + QMap qLast; + qLast.insert(count , strKeyword); + QMap > qMedium; + qMedium.insert(strMorphere, qLast); + m_mapViewResult.insert(strDate, qMedium); + } + } + QMap totalResult; + + for(QMap > >::iterator iterPos1 = m_mapViewResult.begin(); iterPos1 != m_mapViewResult.end(); iterPos1++) + { + for(QMap >::iterator iterPos2 = iterPos1.value().begin(); iterPos2 != iterPos1.value().end(); iterPos2++) + { + int i = 0; + QMapIterator iter(m_mapViewResult[iterPos1.key()][iterPos2.key()]); + iter.toBack(); + while(iter.hasPrevious()) + { + if(i >= nRank) + break; + iter.previous(); + QString key = iterPos1.key() + "~!@" + iterPos2.key() + "~!@" + iter.value(); + //totalResult.insert(QString(iterPos1.key() + "~!@" + iterPos2.key() + "~!@" + iter.value()), iter.key()); + totalResult.insert(key, iter.key()); + i++; + } + } + } + + return totalResult; +} + + + +QMap YMPlatformOneFilter::RankFilterALL(QMap mapResult) +{ + QMap > Result; + //QMap Result; + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts); + QString key = slkey.at(0).trimmed(); + int nLength = slkey.length(); + + for(int i = 1; i < nLength - 2 ; i++) + { + key += "~!@"; + key += slkey.at(i).trimmed(); + } + + + //qDebug() << slkey.at(0); + if(Result.contains(key)) + { + Result[key].insertMulti(iterPos.value(), iterPos.key()); + } + else + { + QMap qLast; + qLast.insert(iterPos.value(), iterPos.key()); + Result.insert(key, qLast); + } + + } + + int nRank = m_mapParam.value("RankFilterAll").toInt(); + + qDebug() << "TwoDepth nRank: " << nRank; + + QMap totalResult; + //qDebug() << "rankfilter:" << nRank; + for(QMap >::iterator iterPos = Result.begin(); iterPos != Result.end(); iterPos++) + { + QMapIterator iter(Result[iterPos.key()]); + iter.toBack(); + int i = 0; + while(iter.hasPrevious()) + { + if(i >= nRank) + break; + + iter.previous(); + totalResult.insertMulti(iter.value(), iter.key()); + + i++; + } + } + + return totalResult; +} + +/* + * + * class YMPlatformFilter + * + */ + + + +QMap YMPlatformFilter::Extractor(QMap mapResult) +{ + QMap totalResult; + QStringList slExtractor; + QRegExp rx("[\\s,.;]"); + slExtractor = m_mapParam.value("Extractor2").split(rx); + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts); + int nLastIndex = slkey.length() - 1; + + foreach(QString str, slExtractor) + { + if(slkey.at(nLastIndex).compare(str.trimmed(), Qt::CaseInsensitive) == 0) + totalResult.insert(iterPos.key(), iterPos.value()); + } + } + return totalResult; +} + +QMap YMPlatformFilter::KeywordLengthFilter(QMap mapResult) +{ + QMap totalResult; + + int nLength = m_mapParam.value("KeywordLengthFilter2").toInt(); + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts); + int nLastIndex = slkey.length() - 1; + + if(slkey.at(nLastIndex).trimmed().length() >= nLength) + { + totalResult.insert(iterPos.key(), iterPos.value()); + //qDebug() << iterPos.key() << " :" << iterPos.value(); + } + + } + return totalResult; +} + +QMap YMPlatformFilter::KeywordFilter(QMap mapResult) +{ + QMap totalResult; + QRegExp rx("[\\s,;]"); + QStringList slKeywordFilter = m_mapParam.value("KeywordFilter2").split(rx); + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts); + int nLastIndex = slkey.length() - 1; + //qDebug() << "nLastIndex: " << nLastIndex; + bool bChecked = true; + foreach(QString str, slKeywordFilter) + { + if(slkey.at(nLastIndex).compare(str.trimmed(), Qt::CaseInsensitive) == 0) + { + bChecked = false; + break; + } + } + if(bChecked) + totalResult.insert(iterPos.key(), iterPos.value()); + } + + return totalResult; +} + + +QMap YMPlatformFilter::RankFilterSeparated(QMap mapResult) +{ + QMap > > m_mapViewResult; + int nRank = m_mapParam.value("RankFilterSeparated2").toInt(); + + //qDebug() << "nRank" <::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + int count = iterPos.value(); + QStringList strlistKey = strkey.split("~!@"); + QString strDate = strlistKey.at(0); + QString strMorphere = strlistKey.at(1); + QString strKeyword = strlistKey.at(2); + + if(m_mapViewResult.contains(strDate)) + { + if(m_mapViewResult.value(strDate).contains(strMorphere)) + { + m_mapViewResult[(strDate)][(strMorphere)].insertMulti(count, strKeyword); + } + else + { + QMap qLast; + qLast.insert(count, strKeyword); + m_mapViewResult[(strDate)].insert(strMorphere, qLast); + } + } + else + { + QMap qLast; + qLast.insert(count , strKeyword); + QMap > qMedium; + qMedium.insert(strMorphere, qLast); + m_mapViewResult.insert(strDate, qMedium); + } + } + QMap totalResult; + + for(QMap > >::iterator iterPos1 = m_mapViewResult.begin(); iterPos1 != m_mapViewResult.end(); iterPos1++) + { + for(QMap >::iterator iterPos2 = iterPos1.value().begin(); iterPos2 != iterPos1.value().end(); iterPos2++) + { + int i = 0; + QMapIterator iter(m_mapViewResult[iterPos1.key()][iterPos2.key()]); + iter.toBack(); + while(iter.hasPrevious()) + { + if(i >= nRank) + break; + iter.previous(); + QString key = iterPos1.key() + "~!@" + iterPos2.key() + "~!@" + iter.value(); + //totalResult.insert(QString(iterPos1.key() + "~!@" + iterPos2.key() + "~!@" + iter.value()), iter.key()); + totalResult.insert(key, iter.key()); + i++; + } + } + } + + return totalResult; +} + + +YMPlatformFilter::YMPlatformFilter() +{ + +} + +YMPlatformFilter::~YMPlatformFilter() +{ + +} + + +QMap YMPlatformFilter::Exec(QMap mapResult) +{ + QMap totalResult; + if(!m_mapParam.value("Extractor2").isEmpty()) + { + AppendMap(totalResult, Extractor(mapResult)); + } + if(!m_mapParam.value("KeywordFilter2").isEmpty()) + { + mapResult = KeywordFilter(mapResult); + //AppendMap(totalResult, KeywordFilter(mapResult)); + } + if(!m_mapParam.value("KeywordLengthFilter2").isEmpty()) + { + mapResult = KeywordLengthFilter(mapResult); + //totalResult = KeywordLengthFilter(totalResult); + } + AppendMap(totalResult, mapResult); + if(!m_mapParam.value("RankFilterAll2").isEmpty()) + { + totalResult = RankFilterALL(totalResult); + } + else if(!m_mapParam.value("RankFilterSeparated2").isEmpty()) + { + totalResult = RankFilterSeparated(totalResult); + } + if(!m_mapParam.value("CounterFilter2").isEmpty()) + { + totalResult = RankFilterSeparated(totalResult); + } + return totalResult; +} + +QMap YMPlatformFilter::RankFilterALL(QMap mapResult) +{ + QMap > Result; + //QMap Result; + + for(QMap::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++) + { + QString strkey = iterPos.key(); + QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts); + QString key = slkey.at(0).trimmed(); + int nLength = slkey.length(); + + for(int i = 1; i < nLength - 2 ; i++) + { + key += "~!@"; + key += slkey.at(i).trimmed(); + } + //qDebug() << slkey.at(0); if(Result.contains(key)) @@ -417,3 +883,5 @@ QMap YMTwoDepthFilter::RankFilterALL(QMap mapResult) return totalResult; } + + diff --git a/MorphereAnalyzer/ymfilterchildren.h b/MorphereAnalyzer/ymfilterchildren.h index 5904ca2..0f28868 100644 --- a/MorphereAnalyzer/ymfilterchildren.h +++ b/MorphereAnalyzer/ymfilterchildren.h @@ -19,6 +19,7 @@ protected: QMap KeywordLengthFilter(QMap mapResult); QMap KeywordFilter(QMap mapResult); QMap RankFilterSeparated(QMap mapResult); + public: YMOneDepthFilter(); ~YMOneDepthFilter(); @@ -42,6 +43,37 @@ public: }; +class YMPlatformOneFilter:public YMFilter +{ +protected: + QMap Extractor(QMap mapResult); + QMap KeywordLengthFilter(QMap mapResult); + QMap KeywordFilter(QMap mapResult); + QMap RankFilterSeparated(QMap mapResult); + QMap RankFilterALL(QMap mapResult); +public: + YMPlatformOneFilter(); + ~YMPlatformOneFilter(); + +}; + + +class YMPlatformFilter:public YMFilter +{ +protected: + QMap Extractor(QMap mapResult); + QMap KeywordLengthFilter(QMap mapResult); + QMap KeywordFilter(QMap mapResult); + QMap RankFilterSeparated(QMap mapResult); + QMap RankFilterALL(QMap mapResult); +public: + YMPlatformFilter(); + ~YMPlatformFilter(); + + QMap Exec(QMap mapResult); +}; + + #endif // YMFILTERCHILDREN diff --git a/MorphereAnalyzer/ymnxnmatrixwidget.cpp b/MorphereAnalyzer/ymnxnmatrixwidget.cpp index 6e56203..2774832 100644 --- a/MorphereAnalyzer/ymnxnmatrixwidget.cpp +++ b/MorphereAnalyzer/ymnxnmatrixwidget.cpp @@ -31,6 +31,8 @@ YMNxNMatrixWidget::YMNxNMatrixWidget(QWidget *parent) m_strlistMorphereko << "NNG" <<"NNP"<<"NNB"<<"NNBC"<<"NR"<<"NP"<<"VV"<<"VA"<<"VX"<<"VCP"<<"VCN"<<"MM"<<"MAG"<<"MAJ"<<"IC"<<"JKS"<<"JKC"<<"JKG"<<"JKO"<<"JKB"<<"JKV"<<"JKQ"<<"JX"<<"JC"<<"EP"<<"EF"<<"EC"<<"ETN"<<"ETM"<<"XPN"<<"XSN"<<"XSV"<<"XSA"<<"XR"<<"SF"<<"SE"<<"SSO"<<"SSC"<<"SC"<<"SY"<<"SL"<<"SH"<<"SN"; } + m_strName = "nxnmatrix"; + QVBoxLayout *vMainLayout = new QVBoxLayout; vMainLayout->setAlignment(Qt::AlignVCenter); QVBoxLayout *vboxlayout = new QVBoxLayout; @@ -660,6 +662,82 @@ void YMNxNMatrixWidget::clearView() m_mapViewResult.clear(); } +void YMNxNMatrixWidget::setParam(QString strJson) +{ + SJson json; + { + int nThread = json.Get(strJson, "Thread").toInt(); + for(int i = 0; i < m_pcbThread->count(); i++) + { + //qDebug() << m_pcbThread->itemData(i).toInt(); + if(m_pcbThread->itemText(i).trimmed().toInt() == nThread) + { + m_pcbThread->setCurrentIndex(i); + break; + } + } + } + { + QString strCountMethod = json.Get(strJson, "CountMethod").trimmed(); + for(int i = 0; i < m_pcbCountMethod->count(); i++) + { + //qDebug() << m_pcbThread->itemData(i).toInt(); + if(m_pcbCountMethod->itemText(i).trimmed().compare(strCountMethod) == 0) + { + m_pcbCountMethod->setCurrentIndex(i); + break; + } + } + } + + { + QString strRecentPeriod = json.Get(strJson, "RecentPeriod").trimmed(); + for(int i = 0; i < m_pcbDuring->count(); i++) + { + //qDebug() << m_pcbThread->itemData(i).toInt(); + if(m_pcbDuring->itemText(i).trimmed().compare(strRecentPeriod) == 0) + { + m_pcbDuring->setCurrentIndex(i); + break; + } + } + } + { + int nPeriod = json.Get(strJson, "Period").toInt(); + m_pcbPeriod->setCurrentIndex(nPeriod); + } + { + int nBodyTitle = json.Get(strJson, "TitleBody").toInt(); + m_pcbData->setCurrentIndex(nBodyTitle); + } + { + QString strDateAll = json.Get(strJson, "DateALL").trimmed(); + if(strDateAll.compare("true",Qt::CaseInsensitive) == 0) + { + m_pcbDate->setCurrentIndex(0); + } + else + { + m_pcbDate->setCurrentIndex(1); + } + } + { + QString strRecentDate = json.Get(strJson, "RecentDate"); + m_pleDates->setText(strRecentDate); + } + { + + m_pdeStart->setDate(QDate::fromString(json.Get(strJson,"DateStart"),"yyyyMMdd")); + m_pdeEnd->setDate(QDate::fromString(json.Get(strJson,"DateEnd"),"yyyyMMdd")); + } + + { + QString mKeyword = json.Get(strJson, "MatrixKeyword"); + m_pleMKeyword->setText(mKeyword); + } +} + + void YMNxNMatrixWidget::SortViewResult() { /* @@ -942,7 +1020,6 @@ QGroupBox *YMNxNMatrixWidget::setData() } - QString YMNxNMatrixWidget::getMatrixKeyword() { return m_pleMKeyword->text().trimmed(); diff --git a/MorphereAnalyzer/ymnxnmatrixwidget.h b/MorphereAnalyzer/ymnxnmatrixwidget.h index 055c9c9..bca163a 100644 --- a/MorphereAnalyzer/ymnxnmatrixwidget.h +++ b/MorphereAnalyzer/ymnxnmatrixwidget.h @@ -42,7 +42,7 @@ public: bool getDateAll(); QString getUserDictList(); QString getMatrixKeyword(); - + void setParam(QString strJson); private: // Data QListWidget *m_plwData; diff --git a/MorphereAnalyzer/ymonedepthwidget.cpp b/MorphereAnalyzer/ymonedepthwidget.cpp index 699f790..d2c67fa 100644 --- a/MorphereAnalyzer/ymonedepthwidget.cpp +++ b/MorphereAnalyzer/ymonedepthwidget.cpp @@ -35,6 +35,8 @@ YMOneDepthWidget::YMOneDepthWidget(QWidget *parent) m_strlistMorphereko << "NNG" <<"NNP"<<"NNB"<<"NNBC"<<"NR"<<"NP"<<"VV"<<"VA"<<"VX"<<"VCP"<<"VCN"<<"MM"<<"MAG"<<"MAJ"<<"IC"<<"JKS"<<"JKC"<<"JKG"<<"JKO"<<"JKB"<<"JKV"<<"JKQ"<<"JX"<<"JC"<<"EP"<<"EF"<<"EC"<<"ETN"<<"ETM"<<"XPN"<<"XSN"<<"XSV"<<"XSA"<<"XR"<<"SF"<<"SE"<<"SSO"<<"SSC"<<"SC"<<"SY"<<"SL"<<"SH"<<"SN"; } + m_strName = "onedepth"; + QVBoxLayout *vMainLayout = new QVBoxLayout; vMainLayout->setAlignment(Qt::AlignVCenter); QVBoxLayout *vboxlayout = new QVBoxLayout; @@ -666,7 +668,7 @@ void YMOneDepthWidget::D3View() "\n}" "\n" "\n.node text {" - "\n font: 10px sans-serif;" + "\n font: 14px sans-serif;" "\n pointer-events: none;" "\n text-anchor: middle;" "\n}" @@ -682,8 +684,8 @@ void YMOneDepthWidget::D3View() "\n" "\n" "\n