2depth 추가
git-svn-id: svn://192.168.0.12/source@170 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -32,7 +32,9 @@ SOURCES += main.cpp\
|
||||
ymonedepthwidget.cpp \
|
||||
ymnxnmatrixwidget.cpp \
|
||||
ymfilter.cpp \
|
||||
ymfilterchildren.cpp
|
||||
ymfilterchildren.cpp \
|
||||
ymupload.cpp \
|
||||
ymtwodepthwidget.cpp
|
||||
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
@@ -83,7 +85,9 @@ HEADERS += mainwindow.h \
|
||||
ymonedepthwidget.h \
|
||||
ymnxnmatrixwidget.h \
|
||||
ymfilter.h \
|
||||
ymfilterchildren.h
|
||||
ymfilterchildren.h \
|
||||
ymupload.h \
|
||||
ymtwodepthwidget.h
|
||||
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
#include "ymbasicwidget.h"
|
||||
#include "ymonedepthwidget.h"
|
||||
#include "ymnxnmatrixwidget.h"
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
#include "ymtwodepthwidget.h"
|
||||
//! [0]
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
@@ -61,6 +65,8 @@ MainWindow::MainWindow()
|
||||
//p_qwAnalyzer2 = new SAnaly2;
|
||||
m_pYMBasicWidget = new YMBasicWidget;
|
||||
m_pYMOneDepthWidget = new YMOneDepthWidget;
|
||||
m_pYMTwoDepthWidget = new YMTwoDepthWidget;
|
||||
|
||||
m_pYMNxNMatrixWidget = new YMNxNMatrixWidget;
|
||||
p_qwDict = new SDictionary;
|
||||
|
||||
@@ -82,6 +88,7 @@ MainWindow::MainWindow()
|
||||
//m_ptwResult->addTab(p_qwAnalyzer2, "Analysis2");
|
||||
m_ptwResult->addTab(m_pYMBasicWidget, "Basic");
|
||||
m_ptwResult->addTab(m_pYMOneDepthWidget, "OneDepth");
|
||||
m_ptwResult->addTab(m_pYMTwoDepthWidget, "TwoDepth");
|
||||
m_ptwResult->addTab(m_pYMNxNMatrixWidget, "NxNMatrix");
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
|
||||
@@ -120,7 +127,7 @@ void MainWindow::createActions()
|
||||
actDBCsvExport->setStatusTip(tr("Export DB as a csv file"));
|
||||
connect(actDBCsvExport, SIGNAL(triggered()), this, SLOT(exportDB()));
|
||||
|
||||
actMorphereOriginalExport = new QAction(tr("Morphere - CSV Export(Raw Result)"), this);
|
||||
actMorphereOriginalExport = new QAction(tr("Morphere - CSV Export(OtherType Result)"), this);
|
||||
actMorphereOriginalExport->setStatusTip(tr("Export Morphere as a csv file"));
|
||||
connect(actMorphereOriginalExport, SIGNAL(triggered()), this, SLOT(exportOriginalMorphere()));
|
||||
|
||||
@@ -143,6 +150,10 @@ void MainWindow::createActions()
|
||||
actDictionary = new QAction(tr("Dictionary"), this);
|
||||
actAnalyze->setStatusTip(tr("Execute Dictionary Widget"));
|
||||
connect(actDictionary, SIGNAL(triggered()), this, SLOT(slotDictionary()));
|
||||
|
||||
actTestUpload = new QAction(tr("Test Upload"), this);
|
||||
connect(actTestUpload, SIGNAL(triggered()), this, SLOT(slotTestUpload()));
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::createMenus()
|
||||
@@ -172,6 +183,9 @@ void MainWindow::createMenus()
|
||||
menuAnalyze = menuBar()->addMenu(tr("Analyze"));
|
||||
menuAnalyze->addAction(actAnalyze);
|
||||
|
||||
menuTestUpload = menuBar()->addMenu(tr("TestUpload"));
|
||||
menuTestUpload->addAction(actTestUpload);
|
||||
|
||||
}
|
||||
//! [12]
|
||||
|
||||
@@ -204,6 +218,7 @@ void MainWindow::exportMorphere()
|
||||
|
||||
void MainWindow::exportOriginalMorphere()
|
||||
{
|
||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->SaveFileSimple();
|
||||
// p_qwAnalyzer1->RawFileExport();
|
||||
}
|
||||
|
||||
@@ -230,7 +245,7 @@ void MainWindow::slotAnalyze()
|
||||
msg2.setVisible(true);
|
||||
//qDebug() << p_qwDB->GetTabWidget()->currentIndex();
|
||||
m_pTAInterface->setSource(p_qwDB->GetTabWidget()->currentWidget());
|
||||
YASingleton::getInstance()->setDataAlgorithmInterface(m_pTAInterface);
|
||||
YAFactory::getInstance()->getYAlgorithm(((YMorphereWidget*)(m_ptwResult->currentWidget()))->convertToParam())->setDataAlgorithmInterface(m_pTAInterface);
|
||||
m_ptwResult->currentWidget();
|
||||
//qDebug() << m_ptwResult->currentIndex();
|
||||
|
||||
@@ -275,6 +290,14 @@ void MainWindow::slotAnalyze()
|
||||
msg2.setVisible(false);
|
||||
}
|
||||
|
||||
void MainWindow::slotTestUpload()
|
||||
{
|
||||
|
||||
((YMorphereWidget*)(m_ptwResult->currentWidget()))->TestUpload();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::slotDictionary()
|
||||
{
|
||||
p_qwDict->show();
|
||||
|
||||
@@ -80,6 +80,7 @@ private slots:
|
||||
void slotAnalyze();
|
||||
void slotDictionary();
|
||||
void exportOriginalMorphere();
|
||||
void slotTestUpload();
|
||||
|
||||
|
||||
|
||||
@@ -111,6 +112,8 @@ private:
|
||||
YMorphereWidget *m_pYMBasicWidget;
|
||||
YMorphereWidget *m_pYMOneDepthWidget;
|
||||
YMorphereWidget *m_pYMNxNMatrixWidget;
|
||||
YMorphereWidget *m_pYMTwoDepthWidget;
|
||||
|
||||
|
||||
QAction *actDBNew;
|
||||
QAction *actDBCsvImport;
|
||||
@@ -123,9 +126,12 @@ private:
|
||||
QAction *actAnalyze;
|
||||
QAction *actDictionary;
|
||||
|
||||
QAction *actTestUpload;
|
||||
|
||||
QMenu *menuFile;
|
||||
QMenu *menuAnalyze;
|
||||
QMenu *menuDictionary;
|
||||
QMenu *menuTestUpload;
|
||||
|
||||
//AnalyzerThread m_pThread[16];
|
||||
/*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "yalgorithm.h"
|
||||
#include "ychildrenthread.h"
|
||||
#include <QDebug>
|
||||
#include "ymfilterchildren.h"
|
||||
/*
|
||||
*class YASingleton
|
||||
*
|
||||
@@ -21,6 +22,68 @@ YASingleton::~YASingleton()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Class YAFactory
|
||||
*
|
||||
*/
|
||||
|
||||
YAFactory* YAFactory::instance = NULL;
|
||||
|
||||
YAFactory::YAFactory()
|
||||
{
|
||||
}
|
||||
|
||||
YAFactory::~YAFactory()
|
||||
{
|
||||
}
|
||||
|
||||
YAFactory* YAFactory::getInstance()
|
||||
{
|
||||
if(instance == NULL)
|
||||
instance = new YAFactory();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
YAlgorithm* YAFactory::getYAlgorithm(QMap<QString, QString> mapParam)
|
||||
{
|
||||
YAlgorithm* Algorithm;
|
||||
//qDebug() << "hohoho";
|
||||
if(mapParam.value("Algorithm").compare("onedepth", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(!m_mapAlgorithm.contains("onedepth"))
|
||||
m_mapAlgorithm.insert("onedepth", new YAlgorithm());
|
||||
Algorithm = m_mapAlgorithm.value("onedepth");
|
||||
}
|
||||
else if(mapParam.value("Algorithm").compare("twodepth", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(!m_mapAlgorithm.contains("twodepth"))
|
||||
m_mapAlgorithm.insert("twodepth", new YTwoDepthAlgorithm() );
|
||||
Algorithm = m_mapAlgorithm.value("twodepth");
|
||||
//qDebug() << "two depth";
|
||||
}
|
||||
else if(mapParam.value("Algorithm").compare("nxnmatrix", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(!m_mapAlgorithm.contains("nxnmatrix"))
|
||||
m_mapAlgorithm.insert("nxnmatrix", new YAlgorithm());
|
||||
Algorithm = m_mapAlgorithm.value("nxnmatrix");
|
||||
}
|
||||
else if(mapParam.value("Algorithm").compare("basic", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(!m_mapAlgorithm.contains("basic"))
|
||||
m_mapAlgorithm.insert("basic", new YAlgorithm());
|
||||
Algorithm = m_mapAlgorithm.value("basic");
|
||||
}
|
||||
else
|
||||
{
|
||||
Algorithm = NULL;
|
||||
}
|
||||
return Algorithm;
|
||||
}
|
||||
|
||||
/*
|
||||
*class YAlgorithm
|
||||
*
|
||||
@@ -36,7 +99,6 @@ YAlgorithm::~YAlgorithm()
|
||||
|
||||
}
|
||||
|
||||
|
||||
QMap <QString, int> YAlgorithm::getResult()
|
||||
{
|
||||
return m_mapTotalResult;
|
||||
@@ -93,9 +155,6 @@ QMap <QString, int> YAlgorithm::RankFilter(QMap <QString, int> mapResult)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void YAlgorithm::EmergeThreadResult()
|
||||
{
|
||||
for(int i = 0;i < getThreadNumber(); i++)
|
||||
@@ -179,16 +238,144 @@ void YAlgorithm::Start()
|
||||
delete[] m_pYMThread;
|
||||
|
||||
EmergeThreadResult();
|
||||
/*
|
||||
if(!m_mapParam.value("KeywordFilter").isEmpty())
|
||||
|
||||
YMFilter* ymfilter = YMFilterFactory::getFilter(m_mapParam);
|
||||
//qDebug() << "EXEC";
|
||||
if(ymfilter != NULL)
|
||||
{
|
||||
m_mapTotalResult = KeywordFilter(m_mapTotalResult);
|
||||
ymfilter->setParam(m_mapParam);
|
||||
m_mapTotalResult = ymfilter->Exec(m_mapTotalResult);
|
||||
}
|
||||
if(!m_mapParam.value("RankFilter").isEmpty())
|
||||
delete ymfilter;
|
||||
|
||||
}
|
||||
|
||||
void YTwoDepthAlgorithm::Start()
|
||||
{
|
||||
m_mapTotalResult = RankFilter(m_mapTotalResult);
|
||||
if(m_mapParam.isEmpty())
|
||||
return;
|
||||
|
||||
bool okThread = false;
|
||||
int nThread = m_mapParam.value("Thread").trimmed().toInt(&okThread);
|
||||
|
||||
if(!okThread)
|
||||
setThreadNumber(1);
|
||||
else
|
||||
setThreadNumber(nThread);
|
||||
|
||||
QMap<QString, QString>mapParam = m_mapParam;
|
||||
|
||||
mapParam["Algorithm"] = "onedepth";
|
||||
|
||||
|
||||
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<QString, int>*[getThreadNumber()];
|
||||
for(int i = 0; i < getThreadNumber(); i++)
|
||||
{
|
||||
m_mapThreadResult[i] = new QMap<QString, int>();
|
||||
}
|
||||
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<QString> 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<QString, int>*[getThreadNumber()];
|
||||
for(int i = 0; i < getThreadNumber(); i++)
|
||||
{
|
||||
m_mapThreadResult[i] = new QMap<QString, int>();
|
||||
}
|
||||
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)
|
||||
{
|
||||
ymfilter->setParam(m_mapParam);
|
||||
m_mapTotalResult = ymfilter->Exec(m_mapTotalResult);
|
||||
}
|
||||
delete ymfilter;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "dataalgorithm_interface.h"
|
||||
#include "ymorpherethread.h"
|
||||
class YAlgorithm{
|
||||
private:
|
||||
protected:
|
||||
QMutex mutex;
|
||||
QMap <QString, int> m_mapTotalResult;
|
||||
QMap <QString, QString> m_mapParam;
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
int m_nThread;
|
||||
YMorphereThread** m_pYMThread;
|
||||
|
||||
private:
|
||||
protected:
|
||||
void setThreadNumber(int nThread);
|
||||
QMap <QString, int> KeywordFilter(QMap <QString, int> mapResult);
|
||||
QMap <QString, int> RankFilter(QMap <QString, int> mapResult);
|
||||
@@ -33,10 +33,11 @@ public:
|
||||
void EmergeThreadResult();
|
||||
|
||||
int getThreadNumber();
|
||||
void Start();
|
||||
virtual void Start();
|
||||
};
|
||||
|
||||
class YASingleton{
|
||||
class YASingleton
|
||||
{
|
||||
private:
|
||||
static YAlgorithm* algorithm;
|
||||
YASingleton();
|
||||
@@ -48,6 +49,24 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class YAFactory
|
||||
{
|
||||
private:
|
||||
QMap<QString, YAlgorithm*> m_mapAlgorithm;
|
||||
static YAFactory* instance;
|
||||
YAFactory();
|
||||
~YAFactory();
|
||||
|
||||
public:
|
||||
static YAFactory* getInstance();
|
||||
YAlgorithm* getYAlgorithm(QMap<QString, QString> mapParam);
|
||||
};
|
||||
|
||||
class YTwoDepthAlgorithm:public YAlgorithm
|
||||
{
|
||||
public:
|
||||
void Start();
|
||||
};
|
||||
|
||||
#endif // YALGORITHM
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ void YBasicMThread::run()
|
||||
{
|
||||
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
||||
{
|
||||
m_strKeyword = strListLine.at(0);
|
||||
m_strKeyword = strListLine.at(0).toLower();
|
||||
m_strMorphere = strMorphere;
|
||||
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
||||
if(m_mapResult.contains(strkey))
|
||||
@@ -531,7 +531,7 @@ void YOneDepthMThread::run()
|
||||
{
|
||||
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
||||
{
|
||||
m_strKeyword = strListLine.at(0);
|
||||
m_strKeyword = strListLine.at(0).toLower();
|
||||
m_strMorphere = strMorphere;
|
||||
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
||||
if(m_mapResult.contains(strkey))
|
||||
@@ -652,20 +652,339 @@ QString YOneDepthMThread::getWeeksInMonth(unsigned int _nDate)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void YTwoDepthMThread::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;
|
||||
{
|
||||
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();
|
||||
m_pDAInterface->next();
|
||||
mutex->unlock();
|
||||
}
|
||||
|
||||
{
|
||||
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<QString, int> tempResult;
|
||||
|
||||
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 + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
||||
if(tempResult.contains(strkey))
|
||||
{
|
||||
(tempResult)[strkey]++;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
tempResult.insert(strkey,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(QString str, m_slOneDepthKeys)
|
||||
{
|
||||
if(tempResult.contains(str))
|
||||
{
|
||||
for(QMap<QString, int>::iterator iterPos = tempResult.begin(); iterPos != tempResult.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();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mapResult.insert(strkey, iterPos.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mecab_destroy(mecab);
|
||||
}
|
||||
|
||||
void YTwoDepthMThread::parseParam()
|
||||
{
|
||||
userdict = m_mapParam.value("UserDict");
|
||||
|
||||
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(" ");
|
||||
}
|
||||
|
||||
|
||||
QString YTwoDepthMThread::getWeeksInMonth(unsigned int _nDate)
|
||||
{
|
||||
|
||||
QDate qToday(_nDate/10000, (_nDate/100)%100, _nDate%100);
|
||||
if(!qToday.isValid())
|
||||
return "inVaildDate";
|
||||
|
||||
QDate qTodayFirstDay = QDate(qToday.year(), qToday.month(), 1);
|
||||
QDate qTodayLastDay = QDate(qToday.year(), qToday.month(), qToday.daysInMonth());
|
||||
|
||||
int thisFirstDayofWeek = qTodayFirstDay.dayOfWeek();
|
||||
int thisLastDayofWeek = qTodayLastDay.dayOfWeek();
|
||||
int thisLastDay = qTodayLastDay.daysInMonth();
|
||||
int week = 0;
|
||||
int firstWeekDays = (WEEK - thisFirstDayofWeek) + 1;
|
||||
QString strWeek = "W";
|
||||
|
||||
if(thisFirstDayofWeek < FRIDAY)
|
||||
{
|
||||
week = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
week = 0;
|
||||
}
|
||||
|
||||
if((firstWeekDays < qToday.day()) && (qToday.day() <= (thisLastDay - thisLastDayofWeek)))
|
||||
{
|
||||
week = week + ((qToday.day() - firstWeekDays + WEEK - 1)/WEEK);
|
||||
}
|
||||
else if((firstWeekDays >= qToday.day()))
|
||||
{
|
||||
if(thisFirstDayofWeek >= FRIDAY)
|
||||
{
|
||||
|
||||
const int DAYS_IN_WEEK = 7;
|
||||
qToday = qToday.addMonths(-1);
|
||||
int DaysInMonth = qToday.daysInMonth();
|
||||
QDate FirstDayOfMonth = qToday;
|
||||
FirstDayOfMonth.setDate(qToday.year(), qToday.month(), 1);
|
||||
|
||||
int WeekCount = DaysInMonth / DAYS_IN_WEEK;
|
||||
int DaysLeft = DaysInMonth % DAYS_IN_WEEK;
|
||||
if (DaysLeft > 0) {
|
||||
WeekCount++;
|
||||
// Check if the remaining days are split on two weeks
|
||||
if (FirstDayOfMonth.dayOfWeek() + DaysLeft - 1 > DAYS_IN_WEEK)
|
||||
WeekCount++;
|
||||
}
|
||||
week = WeekCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(thisLastDayofWeek < THURSDAY)
|
||||
{
|
||||
week = 1;
|
||||
qToday = qToday.addMonths(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
week = week + ((qToday.day() - firstWeekDays + WEEK - 1)/WEEK);
|
||||
}
|
||||
}
|
||||
|
||||
strWeek += qToday.toString("yyyyMM");
|
||||
strWeek += QString::number(week);
|
||||
return strWeek;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void YPlatformMThread::run()
|
||||
{
|
||||
|
||||
|
||||
@@ -86,10 +86,40 @@ public:
|
||||
class YTwoDepthMThread:public YMorphereThread
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QString getWeeksInMonth(unsigned int _nDate);
|
||||
enum {
|
||||
MONDAY = 1,
|
||||
TUESDAY,
|
||||
WEDNESDAY,
|
||||
THURSDAY,
|
||||
FRIDAY,
|
||||
SATURDAY,
|
||||
SUNDAY
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
WEEK = 7
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
protected:
|
||||
void run();
|
||||
public:
|
||||
void parseParam();
|
||||
|
||||
};
|
||||
|
||||
class YPlatformMThread:public YMorphereThread
|
||||
|
||||
@@ -429,6 +429,37 @@ void YMBasicWidget::FileImport()
|
||||
ViewResult();
|
||||
}
|
||||
|
||||
void YMBasicWidget::SaveFile()
|
||||
{
|
||||
/*
|
||||
QString strFilename = QFileDialog::getSaveFileName(0,"save file",QDir::currentPath(),
|
||||
"csv files (*.csv);;All files (*.*)",new QString("Text files (*.csv)"));
|
||||
if (strFilename.toLower().right(4) != QString(".csv"))
|
||||
strFilename += ".csv";
|
||||
QFile file(strFilename);
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
STable* pTable = (STable*)((QTabWidget*)(m_ptwTable->currentWidget()))->currentWidget();
|
||||
int nCountIndex = pTable->columnCount() - 1;
|
||||
int nKeywordIndex = pTable->columnCount() - 2;
|
||||
|
||||
QString strCKeyword = m_pleCKeyword->text().trimmed();
|
||||
for (int i = 0; i < pTable->rowCount(); i++)
|
||||
{
|
||||
QString strKeyword = pTable->item(i, nKeywordIndex)->text().trimmed();
|
||||
int nCount = pTable->item(i, nCountIndex)->text().trimmed().toInt();
|
||||
for(int j = 0; j < nCount; j++)
|
||||
{
|
||||
out << strCKeyword << ";" << strKeyword << endl;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void YMBasicWidget::FileExport()
|
||||
{
|
||||
QString strFilename = QFileDialog::getSaveFileName(0,"Exoprt file",QDir::currentPath(),
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
QStringList getMorphereList();
|
||||
bool getDateAll();
|
||||
QString getUserDictList();
|
||||
|
||||
void SaveFile();
|
||||
|
||||
private:
|
||||
// Data
|
||||
|
||||
@@ -30,18 +30,27 @@ QMap<QString, int> YMFilter::RankFilterALL(QMap<QString, int> mapResult)
|
||||
{
|
||||
QString strkey = iterPos.key();
|
||||
QStringList slkey = strkey.split("~!@", QString::SkipEmptyParts);
|
||||
QString key = slkey.at(0).trimmed();
|
||||
int nLength = slkey.length();
|
||||
|
||||
|
||||
qDebug() << slkey.at(0);
|
||||
if(Result.contains(slkey.at(0).trimmed()))
|
||||
for(int i = 1; i < nLength - 2 ; i++)
|
||||
{
|
||||
Result[slkey.at(0).trimmed()].insertMulti(iterPos.value(), iterPos.key());
|
||||
key += "~!@";
|
||||
key += slkey.at(i).trimmed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//qDebug() << slkey.at(0);
|
||||
if(Result.contains(key))
|
||||
{
|
||||
Result[key].insertMulti(iterPos.value(), iterPos.key());
|
||||
}
|
||||
else
|
||||
{
|
||||
QMap<int, QString> qLast;
|
||||
qLast.insert(iterPos.value(), iterPos.key());
|
||||
Result.insert(slkey.at(0).trimmed(), qLast);
|
||||
Result.insert(key, qLast);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -139,7 +148,6 @@ QMap<QString, int> YMFilter::Exec(QMap<QString, int> mapResult)
|
||||
}
|
||||
|
||||
return totalResult;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ protected:
|
||||
|
||||
|
||||
public:
|
||||
QMap<QString, int> Exec(QMap<QString, int> mapResult);
|
||||
virtual QMap<QString, int> Exec(QMap<QString, int> mapResult);
|
||||
void setParam(QMap <QString, QString> mapParam);
|
||||
void clearParam();
|
||||
YMFilter();
|
||||
|
||||
@@ -18,6 +18,8 @@ YMFilter* YMFilterFactory::getFilter(QMap<QString, QString> mapParam)
|
||||
{
|
||||
if(mapParam.value("Algorithm").trimmed() == "onedepth")
|
||||
return new YMOneDepthFilter();
|
||||
else if(mapParam.value("Algorithm").trimmed() == "twodepth")
|
||||
return new YMTwoDepthFilter();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
@@ -169,3 +171,249 @@ QMap<QString, int> YMOneDepthFilter::RankFilterSeparated(QMap<QString, int> mapR
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* class YMTwoDepthFilter
|
||||
*/
|
||||
|
||||
|
||||
|
||||
QMap<QString, int> YMTwoDepthFilter::Extractor(QMap<QString, int> mapResult)
|
||||
{
|
||||
QMap<QString, int> totalResult;
|
||||
QStringList slExtractor;
|
||||
QRegExp rx("[\\s,.;]");
|
||||
slExtractor = m_mapParam.value("Extractor2").split(rx);
|
||||
|
||||
for(QMap<QString, int>::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<QString, int> YMTwoDepthFilter::KeywordLengthFilter(QMap<QString, int> mapResult)
|
||||
{
|
||||
QMap<QString, int> totalResult;
|
||||
|
||||
int nLength = m_mapParam.value("KeywordLengthFilter2").toInt();
|
||||
|
||||
for(QMap<QString, int>::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<QString, int> YMTwoDepthFilter::KeywordFilter(QMap<QString, int> mapResult)
|
||||
{
|
||||
QMap<QString, int> totalResult;
|
||||
QRegExp rx("[\\s,;]");
|
||||
QStringList slKeywordFilter = m_mapParam.value("KeywordFilter2").split(rx);
|
||||
|
||||
for(QMap<QString, int>::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<QString, int> YMTwoDepthFilter::RankFilterSeparated(QMap<QString, int> mapResult)
|
||||
{
|
||||
QMap<QString, QMap<QString, QMap<int, QString> > > m_mapViewResult;
|
||||
int nRank = m_mapParam.value("RankFilterSeparated2").toInt();
|
||||
|
||||
//qDebug() << "nRank" <<nRank;
|
||||
|
||||
for(QMap<QString, int>::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<int, QString> qLast;
|
||||
qLast.insert(count, strKeyword);
|
||||
m_mapViewResult[(strDate)].insert(strMorphere, qLast);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMap<int, QString> qLast;
|
||||
qLast.insert(count , strKeyword);
|
||||
QMap<QString, QMap<int, QString> > qMedium;
|
||||
qMedium.insert(strMorphere, qLast);
|
||||
m_mapViewResult.insert(strDate, qMedium);
|
||||
}
|
||||
}
|
||||
QMap<QString, int> totalResult;
|
||||
|
||||
for(QMap<QString, QMap<QString, QMap<int, QString> > >::iterator iterPos1 = m_mapViewResult.begin(); iterPos1 != m_mapViewResult.end(); iterPos1++)
|
||||
{
|
||||
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos1.value().begin(); iterPos2 != iterPos1.value().end(); iterPos2++)
|
||||
{
|
||||
int i = 0;
|
||||
QMapIterator<int, QString> 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;
|
||||
}
|
||||
|
||||
|
||||
YMTwoDepthFilter::YMTwoDepthFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
YMTwoDepthFilter::~YMTwoDepthFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, int> YMTwoDepthFilter::Exec(QMap<QString, int> mapResult)
|
||||
{
|
||||
QMap<QString, int> 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<QString, int> YMTwoDepthFilter::RankFilterALL(QMap<QString, int> mapResult)
|
||||
{
|
||||
QMap<QString, QMap<int, QString> > Result;
|
||||
//QMap<int, QString> Result;
|
||||
|
||||
for(QMap<QString, int>::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<int, QString> qLast;
|
||||
qLast.insert(iterPos.value(), iterPos.key());
|
||||
Result.insert(key, qLast);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int nRank = m_mapParam.value("RankFilterAll2").toInt();
|
||||
|
||||
qDebug() << "TwoDepth nRank: " << nRank;
|
||||
|
||||
QMap <QString, int> totalResult;
|
||||
//qDebug() << "rankfilter:" << nRank;
|
||||
for(QMap<QString, QMap<int, QString> >::iterator iterPos = Result.begin(); iterPos != Result.end(); iterPos++)
|
||||
{
|
||||
QMapIterator <int, QString> 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;
|
||||
}
|
||||
|
||||
@@ -25,5 +25,23 @@ public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class YMTwoDepthFilter:public YMFilter
|
||||
{
|
||||
protected:
|
||||
QMap<QString, int> Extractor(QMap<QString, int> mapResult);
|
||||
QMap<QString, int> KeywordLengthFilter(QMap<QString, int> mapResult);
|
||||
QMap<QString, int> KeywordFilter(QMap<QString, int> mapResult);
|
||||
QMap<QString, int> RankFilterSeparated(QMap<QString, int> mapResult);
|
||||
QMap<QString, int> RankFilterALL(QMap<QString, int> mapResult);
|
||||
public:
|
||||
YMTwoDepthFilter();
|
||||
~YMTwoDepthFilter();
|
||||
|
||||
QMap<QString, int> Exec(QMap<QString, int> mapResult);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // YMFILTERCHILDREN
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include <QMenuBar>
|
||||
#include <QInputDialog>
|
||||
#include <QIntValidator>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
#define D_NOT_SELECT -1
|
||||
|
||||
@@ -966,6 +969,112 @@ void YMOneDepthWidget::SaveFile()
|
||||
file.close();
|
||||
}
|
||||
|
||||
void YMOneDepthWidget::SaveFileSimple()
|
||||
{
|
||||
QString strFilename = QFileDialog::getSaveFileName(0,"save file",QDir::currentPath(),
|
||||
"csv files (*.csv);;All files (*.*)",new QString("Text files (*.csv)"));
|
||||
if (strFilename.toLower().right(4) != QString(".csv"))
|
||||
strFilename += ".csv";
|
||||
QFile file(strFilename);
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
|
||||
QTextStream out(&file);
|
||||
|
||||
STable* pTable = (STable*)((QTabWidget*)(m_ptwTable->currentWidget()))->currentWidget();
|
||||
int nCountIndex = pTable->columnCount() - 1;
|
||||
int nKeywordIndex = pTable->columnCount() - 2;
|
||||
|
||||
QString strCKeyword = m_pleCKeyword->text().trimmed();
|
||||
out << strCKeyword;
|
||||
|
||||
for (int i = 0; i < pTable->rowCount(); i++)
|
||||
{
|
||||
QString strKeyword = pTable->item(i, nKeywordIndex)->text().trimmed();
|
||||
int nCount = pTable->item(i, nCountIndex)->text().trimmed().toInt();
|
||||
for(int j = 0; j < nCount; j++)
|
||||
{
|
||||
out << "," << strKeyword;
|
||||
}
|
||||
|
||||
}
|
||||
out << endl;
|
||||
file.close();
|
||||
}
|
||||
|
||||
QMap<QString, int> YMOneDepthWidget::getResult()
|
||||
{
|
||||
return m_mapResult;
|
||||
}
|
||||
|
||||
|
||||
void YMOneDepthWidget::TestUpload()
|
||||
{
|
||||
//QMap<QString, int> mapResult = m_mapResult;
|
||||
|
||||
QString strCKeyword = getCenterKeyword();
|
||||
//qDebug() << "executed";
|
||||
QString strjson = "{\n\t\"name\":\" " + strCKeyword + "\",\n";
|
||||
strjson += ("\t\"children\": [\n");
|
||||
|
||||
STable* pTable = (STable*)((QTabWidget*)(m_ptwTable->currentWidget()))->currentWidget();
|
||||
int nCountIndex = pTable->columnCount() - 1;
|
||||
int nKeywordIndex = pTable->columnCount() - 2;
|
||||
|
||||
for (int i = 0; i < pTable->rowCount(); i++)
|
||||
{
|
||||
QString strKeyword = pTable->item(i, nKeywordIndex)->text().trimmed();
|
||||
int nCount = pTable->item(i, nCountIndex)->text().trimmed().toInt();
|
||||
strjson += ("\t{\"name\": \"" + strKeyword + "\", \"size\": " + QString::number(nCount) + "},\n");
|
||||
}
|
||||
strjson = strjson.trimmed();
|
||||
strjson = strjson.left(strjson.length() - 1);
|
||||
strjson += "\n\t]\n}";
|
||||
|
||||
/*
|
||||
QFile file("c:/data/jsontest.txt");
|
||||
if(!file.open(QFile::WriteOnly | QFile::Text)) return;
|
||||
QTextStream out(&file);
|
||||
|
||||
out << strjson;
|
||||
|
||||
file.close();
|
||||
*/
|
||||
|
||||
|
||||
|
||||
QSqlDatabase dbWeb = QSqlDatabase::addDatabase("QMYSQL");
|
||||
dbWeb.setHostName("db.big-bird.co.kr");
|
||||
dbWeb.setUserName("concepters");
|
||||
dbWeb.setPassword("con97996655");
|
||||
dbWeb.setDatabaseName("dbconcepters");
|
||||
|
||||
int nCompany = 90;
|
||||
|
||||
if(!dbWeb.open())
|
||||
qDebug() << "DB open Failed";
|
||||
|
||||
|
||||
|
||||
QSqlQuery query(QSqlDatabase::database(dbWeb.connectionName()));
|
||||
|
||||
QString strquery;
|
||||
|
||||
strquery = "insert into stats_json (jdata, company_num) values ('" + strjson + "', " + QString::number(nCompany) + ")";
|
||||
|
||||
if(!query.exec(strquery.toUtf8()))
|
||||
{
|
||||
strquery = "update stats_json set jdata='" + strjson + "' where company_num=" + QString::number(nCompany);
|
||||
if(!query.exec(strquery.toUtf8()))
|
||||
{
|
||||
qDebug() << query.lastError().text();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dbWeb.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
QString YMOneDepthWidget::getCenterKeyword()
|
||||
{
|
||||
|
||||
@@ -41,6 +41,9 @@ public:
|
||||
QString getUserDictList();
|
||||
QString getCenterKeyword();
|
||||
void SaveFile();
|
||||
void SaveFileSimple();
|
||||
QMap<QString, int> getResult();
|
||||
void TestUpload();
|
||||
|
||||
private:
|
||||
// Data
|
||||
|
||||
@@ -38,26 +38,32 @@ void YMorphereWidget::SaveFile()
|
||||
|
||||
}
|
||||
|
||||
|
||||
void YMorphereWidget::SaveFileSimple()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void YMorphereWidget::TestUpload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void YMorphereWidget::Exec(int nTitleBody)
|
||||
{
|
||||
clearResult();
|
||||
clearViewResult();
|
||||
clearView();
|
||||
m_pYAlgorithm = YASingleton::getInstance();
|
||||
QMap <QString, QString> mapParam = convertToParam();
|
||||
mapParam["TitleBody"] = QString::number(nTitleBody);
|
||||
|
||||
m_pYAlgorithm = YAFactory::getInstance()->getYAlgorithm(mapParam);
|
||||
m_pYAlgorithm->init();
|
||||
QMap <QString, QString> mapResult = convertToParam();
|
||||
mapResult["TitleBody"] = QString::number(nTitleBody);
|
||||
m_pYAlgorithm->setParam(mapResult);
|
||||
m_pYAlgorithm->setParam(mapParam);
|
||||
m_pYAlgorithm->Start();
|
||||
m_mapResult = m_pYAlgorithm->getResult();
|
||||
//qDebug() << m_mapResult.count();
|
||||
YMFilter* ymfilter = YMFilterFactory::getFilter(mapResult);
|
||||
//qDebug() << "EXEC";
|
||||
if(ymfilter != NULL)
|
||||
{
|
||||
ymfilter->setParam(mapResult);
|
||||
m_mapResult = ymfilter->Exec(m_mapResult);
|
||||
}
|
||||
delete ymfilter;
|
||||
ViewResult();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
void Exec(int nTitleBody);
|
||||
virtual QMap<QString, QString> convertToParam() = 0;
|
||||
virtual void SaveFile();
|
||||
virtual void SaveFileSimple();
|
||||
virtual void TestUpload();
|
||||
};
|
||||
|
||||
#endif // YMORPHEREWIDGET
|
||||
|
||||
1332
MorphereAnalyzer/ymtwodepthwidget.cpp
Normal file
1332
MorphereAnalyzer/ymtwodepthwidget.cpp
Normal file
File diff suppressed because it is too large
Load Diff
154
MorphereAnalyzer/ymtwodepthwidget.h
Normal file
154
MorphereAnalyzer/ymtwodepthwidget.h
Normal file
@@ -0,0 +1,154 @@
|
||||
#ifndef YMTWODEPTHWIDGET
|
||||
#define YMTWODEPTHWIDGET
|
||||
|
||||
#include "ymorpherewidget.h"
|
||||
#include <QCalendarWidget>
|
||||
#include <QDateEdit>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QGroupBox>
|
||||
#include <QListWidget>
|
||||
#include <QTabWidget>
|
||||
#include <QRadioButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QTableWidget>
|
||||
#include <QProgressBar>
|
||||
#include <QMenuBar>
|
||||
#include <QSqlDatabase>
|
||||
#include <QListWidgetItem>
|
||||
#include "stable.h"
|
||||
class YMTwoDepthWidget:public YMorphereWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
YMTwoDepthWidget(QWidget *parent = 0);
|
||||
~YMTwoDepthWidget();
|
||||
void clearViewResult();
|
||||
void clearView();
|
||||
void ViewResult();
|
||||
QMap<QString, QString> convertToParam();
|
||||
|
||||
//Morphere List
|
||||
int getThread();
|
||||
unsigned int getDateStart();
|
||||
unsigned int getDateEnd();
|
||||
int getPeriod();
|
||||
QStringList getMorphereList();
|
||||
bool getDateAll();
|
||||
QString getUserDictList();
|
||||
QString getCenterKeyword();
|
||||
void SaveFile();
|
||||
void SaveFileSimple();
|
||||
QMap<QString, int> getResult();
|
||||
void TestUpload();
|
||||
|
||||
private:
|
||||
// Data
|
||||
QListWidget *m_plwData;
|
||||
// Date
|
||||
QCalendarWidget *m_pcw;
|
||||
QDateEdit *m_pdeStart;
|
||||
QDateEdit *m_pdeEnd;
|
||||
//QPushButton *m_ppbInsertCalc;
|
||||
//QComboBox *m_pcbDateCatalog;
|
||||
//
|
||||
QTabWidget *m_ptwData;
|
||||
//
|
||||
QProgressBar *m_pProgress;
|
||||
// Column
|
||||
QVector <QStringList> m_vecColumn;
|
||||
// MorphereList
|
||||
QListWidget *m_plwMorphereList;
|
||||
QListWidget *m_plwMorphereAdd;
|
||||
|
||||
QComboBox *m_pcbDate;
|
||||
QComboBox *m_pcbPeriod;
|
||||
|
||||
QLineEdit *m_pleFilterRankALL;
|
||||
QLineEdit *m_pleFilterRankSeparated;
|
||||
QLineEdit *m_pleFilterKeyword;
|
||||
QLineEdit *m_pleFilterKeywordLength;
|
||||
QLineEdit *m_pleFilterExtractor;
|
||||
|
||||
|
||||
QLineEdit *m_pleFilterRankALL2;
|
||||
QLineEdit *m_pleFilterRankSeparated2;
|
||||
QLineEdit *m_pleFilterKeyword2;
|
||||
QLineEdit *m_pleFilterKeywordLength2;
|
||||
QLineEdit *m_pleFilterExtractor2;
|
||||
|
||||
|
||||
QComboBox *m_pcbThread;
|
||||
QComboBox *m_pcbSort;
|
||||
|
||||
QListWidgetItem **m_plwiMorphere;
|
||||
QStringList m_strlistMorphere;
|
||||
QStringList m_strlistMorphereko;
|
||||
|
||||
QRadioButton *m_rbDateMorphere;
|
||||
QRadioButton *m_rbMorphereDate;
|
||||
QButtonGroup *m_bgRadioGroup;
|
||||
|
||||
QComboBox *m_pcbDictionary;
|
||||
QList<STable*> m_lTable;
|
||||
QList<QTabWidget*> m_lTabWidget;
|
||||
QTabWidget* m_ptwTable;
|
||||
|
||||
|
||||
QMap<QString, QMap<QString, QMap<int, QString> > > m_mapViewResult;
|
||||
QMap<QString, QMap<int, QMap<QString, QString> > > m_mapViewResult2;
|
||||
|
||||
QString m_strCKeyword;
|
||||
QLineEdit *m_pleCKeyword;
|
||||
|
||||
|
||||
public:
|
||||
struct m_mapKey
|
||||
{
|
||||
QString strDate;
|
||||
QString strMorphere;
|
||||
QString strKeyword;
|
||||
};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QGroupBox *setMorphereList();
|
||||
QGroupBox *setDate();
|
||||
QGroupBox *setFilter();
|
||||
QGroupBox *setFilter2();
|
||||
|
||||
QGroupBox *setOther();
|
||||
QGroupBox *setSort();
|
||||
QGroupBox *setDictionary();
|
||||
QGroupBox *setCenterKeyword();
|
||||
|
||||
void SortViewResult();
|
||||
|
||||
QTableWidget *AddTable(QString _str);
|
||||
|
||||
|
||||
public slots:
|
||||
void CloseTab(int index);
|
||||
void DoubleClickTab(int index);
|
||||
void FileImport();
|
||||
void FileExport();
|
||||
void RawFileExport();
|
||||
void MemClear();
|
||||
void MorphereListAdd();
|
||||
void MorphereListDel();
|
||||
void AddDictionary();
|
||||
void DelDictionary();
|
||||
bool setListMorphere(QStringList& MorphereEN, QStringList& MorphereKO);
|
||||
QTabWidget* getQTabWidget();
|
||||
bool isSortMorphereDateChecked();
|
||||
bool isSortDateMorphereChecked();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // YMTWODEPTHWIDGET
|
||||
|
||||
Reference in New Issue
Block a user