1depth Center keyword 분석 추가
dataalgorithm_interface 추가 git-svn-id: svn://192.168.0.12/source@167 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -19,8 +19,12 @@ SOURCES += main.cpp\
|
||||
stable.cpp \
|
||||
../Json/sjson.cpp \
|
||||
sanaly1.cpp \
|
||||
sanaly2.cpp \
|
||||
sanalyzer.cpp \
|
||||
sdictionary.cpp
|
||||
sdictionary.cpp \
|
||||
keywordthread.cpp \
|
||||
tablealgorithm_interface.cpp
|
||||
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
widget.h \
|
||||
@@ -28,6 +32,7 @@ HEADERS += mainwindow.h \
|
||||
../Json/sjson.h \
|
||||
../common.h \
|
||||
sanaly1.h \
|
||||
sanaly2.h \
|
||||
char_property.h \
|
||||
common.h \
|
||||
connector.h \
|
||||
@@ -57,6 +62,10 @@ HEADERS += mainwindow.h \
|
||||
winmain.h \
|
||||
writer.h \
|
||||
sanalyzer.h \
|
||||
sdictionary.h
|
||||
sdictionary.h \
|
||||
keywordthread.h \
|
||||
dataalgorithm_interface.h \
|
||||
tablealgorithm_interface.h
|
||||
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
||||
65
MorphereAnalyzer/dataalgorithm_interface.h
Normal file
65
MorphereAnalyzer/dataalgorithm_interface.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef DATAALGORITHM_INTERFACE
|
||||
#define DATAALGORITHM_INTERFACE
|
||||
#include <QString>
|
||||
|
||||
class DataAlgorithmInterface{
|
||||
|
||||
public:
|
||||
virtual QString getArticleID() = 0;
|
||||
virtual QString getKeywordID() = 0;
|
||||
virtual QString getPlatformName() = 0;
|
||||
virtual QString getPlatformForm() = 0;
|
||||
virtual QString getArticleForm() = 0;
|
||||
virtual QString getArticleNickname() = 0;
|
||||
virtual QString getArticleDate() = 0;
|
||||
virtual QString getArticleTitle() = 0;
|
||||
virtual QString getArticleData() = 0;
|
||||
virtual QString getArticleUrl() = 0;
|
||||
virtual QString getArticleParent() = 0;
|
||||
virtual QString getArticleOrder() = 0;
|
||||
virtual QString getReplyUrl() = 0;
|
||||
virtual QString getArticleHit() = 0;
|
||||
virtual QString getArticleProfileUrl() = 0;
|
||||
virtual QString getArticleProfile() = 0;
|
||||
virtual QString getEtc() = 0;
|
||||
virtual QString getPlatformTitle() = 0;
|
||||
virtual QString getPlatformID() = 0;
|
||||
virtual void next() = 0;
|
||||
virtual bool hasNext() = 0;
|
||||
virtual int currentIndex() = 0;
|
||||
virtual void seek(int n) = 0;
|
||||
virtual int length() = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void moveFirst() = 0;
|
||||
virtual void moveLast() = 0;
|
||||
|
||||
public:
|
||||
enum E_DATA
|
||||
{
|
||||
E_DATA_platform_title = 0,
|
||||
E_DATA_article_form,
|
||||
E_DATA_article_parent,
|
||||
E_DATA_article_id,
|
||||
E_DATA_article_nickname,
|
||||
E_DATA_article_title,
|
||||
E_DATA_article_data,
|
||||
E_DATA_article_url,
|
||||
E_DATA_article_hit,
|
||||
E_DATA_article_date,
|
||||
E_DATA_article_order,
|
||||
E_DATA_platform_id,
|
||||
E_DATA_platform_name,
|
||||
E_DATA_platform_form,
|
||||
E_DATA_reply_url,
|
||||
E_DATA_keyword_id,
|
||||
E_DATA_article_profileurl,
|
||||
E_DATA_article_profile,
|
||||
E_DATA_etc,
|
||||
E_DATA_MAX,
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // DATAALGORITHM_INTERFACE
|
||||
448
MorphereAnalyzer/keywordthread.cpp
Normal file
448
MorphereAnalyzer/keywordthread.cpp
Normal file
@@ -0,0 +1,448 @@
|
||||
#include "keywordthread.h"
|
||||
#include "sanaly2.h"
|
||||
#include <QFile>
|
||||
KeywordThread::KeywordThread(QObject *parent) : QThread(parent), m_nThread(1), m_pWidget(NULL), m_nSource(0), m_bPeriod(false), m_nPeriod(0)
|
||||
{
|
||||
}
|
||||
KeywordThread::KeywordThread(int number)
|
||||
{
|
||||
}
|
||||
|
||||
KeywordThread::KeywordThread(QMutex &_mutex, int _number, int &_nCount)
|
||||
{
|
||||
KeywordThread();
|
||||
num = _number;
|
||||
mutex = &_mutex;
|
||||
nCount = &_nCount;
|
||||
}
|
||||
|
||||
void KeywordThread::setThreadNumber(int _nThread)
|
||||
{
|
||||
m_nThread = _nThread;
|
||||
}
|
||||
|
||||
int KeywordThread::getThreadNumber()
|
||||
{
|
||||
return m_nThread;
|
||||
}
|
||||
|
||||
void KeywordThread::setWidget(QWidget *_pWidget)
|
||||
{
|
||||
m_pWidget = (Widget*)_pWidget;
|
||||
m_pTabWidget = m_pWidget->GetTabWidget();
|
||||
}
|
||||
|
||||
QWidget* KeywordThread::getWidget()
|
||||
{
|
||||
return m_pQWidget;
|
||||
}
|
||||
|
||||
void KeywordThread::setMorphereList(const QStringList morpherelist)
|
||||
{
|
||||
m_slMorphereList.append(morpherelist);
|
||||
}
|
||||
|
||||
|
||||
void KeywordThread::setMorphereList(const QString morphere)
|
||||
{
|
||||
m_slMorphereList.append(morphere);
|
||||
}
|
||||
|
||||
void KeywordThread::resetMorphereList()
|
||||
{
|
||||
m_slMorphereList.clear();
|
||||
}
|
||||
|
||||
void KeywordThread::setParametersfromWidget(QWidget *_pWidget, int _nSource)
|
||||
{
|
||||
resetMorphereList();
|
||||
if(_nSource == 0)
|
||||
{
|
||||
pWidget = (SAnaly2*)_pWidget;
|
||||
setThreadNumber(pWidget->getThread());
|
||||
setPeriod(pWidget->getPeriod());
|
||||
m_bDateAll = pWidget->getDateAll();
|
||||
m_nDateStart = pWidget->getDateStart();
|
||||
m_nDateEnd = pWidget->getDateEnd();
|
||||
setMorphereList(pWidget->getMorphereList());
|
||||
}
|
||||
}
|
||||
|
||||
QStringList KeywordThread::getMorphereList()
|
||||
{
|
||||
return m_slMorphereList;
|
||||
}
|
||||
|
||||
void KeywordThread::setPeriod(const int _nPeriod)
|
||||
{
|
||||
m_nPeriod = _nPeriod;
|
||||
}
|
||||
|
||||
int KeywordThread::getPeriod()
|
||||
{
|
||||
return m_nPeriod;
|
||||
}
|
||||
|
||||
void KeywordThread::setDate(const QDateTime _dtStart, const QDateTime _dtEnd)
|
||||
{
|
||||
m_nDateStart = _dtStart.toString("yyyy-MM-dd").replace("-","").toInt();
|
||||
m_nDateEnd = _dtEnd.toString("yyyy-MM-dd").replace("-","").toInt();
|
||||
}
|
||||
void KeywordThread::setDate(const QString _strStart, const QString _strEnd)
|
||||
{
|
||||
m_nDateStart = _strStart.toInt();
|
||||
m_nDateEnd = _strEnd.toInt();
|
||||
}
|
||||
|
||||
unsigned int KeywordThread::getDateStart()
|
||||
{
|
||||
return m_nDateStart;
|
||||
}
|
||||
|
||||
unsigned int KeywordThread::getDateEnd()
|
||||
{
|
||||
return m_nDateEnd;
|
||||
}
|
||||
|
||||
void KeywordThread::setTitleBody(const int _n)
|
||||
{
|
||||
m_nTitleBody = _n;
|
||||
}
|
||||
|
||||
void KeywordThread::setPosDate(const int _nPos)
|
||||
{
|
||||
m_nPosDate = _nPos;
|
||||
}
|
||||
|
||||
void KeywordThread::setPosBody(const int _nPos)
|
||||
{
|
||||
m_nPosBody = _nPos;
|
||||
}
|
||||
|
||||
void KeywordThread::setPosTitle(const int _nPos)
|
||||
{
|
||||
m_nPosTitle = _nPos;
|
||||
}
|
||||
|
||||
void KeywordThread::setPosPlatformTitle(const int _nPos)
|
||||
{
|
||||
m_nPosPlatformTitle = _nPos;
|
||||
}
|
||||
|
||||
void KeywordThread::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");
|
||||
|
||||
QString userdict = pWidget->getUserDictList();
|
||||
|
||||
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;
|
||||
|
||||
STable *pCurrent = (STable *)m_pTabWidget->currentWidget();
|
||||
int nDate = 0;
|
||||
while(true)
|
||||
{
|
||||
QString strTitle;
|
||||
QString strBody;
|
||||
QString strDate;
|
||||
QString strData;
|
||||
QString strPlatformTitle;
|
||||
{
|
||||
mutex->lock();
|
||||
if(*nCount >= pCurrent->rowCount())
|
||||
{
|
||||
mutex->unlock();
|
||||
break;
|
||||
}
|
||||
strTitle = pCurrent->item((*nCount),m_nPosTitle)->text();
|
||||
strDate = pCurrent->item((*nCount),m_nPosDate)->text();
|
||||
strPlatformTitle = pCurrent->item((*nCount),m_nPosPlatformTitle)->text();
|
||||
strBody = pCurrent->item((*nCount)++,m_nPosBody)->text();
|
||||
|
||||
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))
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
SAnaly2::m_mapKey mapkey;
|
||||
|
||||
switch(m_nPeriod)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
mapkey.strDate = "ALL";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
mapkey.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());
|
||||
*/
|
||||
mapkey.strDate = getWeeksInMonth(nDate);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
mapkey.strDate = "M";
|
||||
if((nDate/100) < 10)
|
||||
mapkey.strDate += "0";
|
||||
mapkey.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);
|
||||
|
||||
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))
|
||||
{
|
||||
mapkey.strKeyword = strListLine.at(0);
|
||||
mapkey.strMorphere = strMorphere;
|
||||
QString strkey = mapkey.strDate + "~!@" + mapkey.strMorphere + "~!@" + mapkey.strKeyword;
|
||||
if(pWidget->m_HashResult[num].contains(strkey))
|
||||
{
|
||||
(pWidget->m_HashResult[num])[strkey]++;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
pWidget->m_HashResult[num].insert(strkey,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if(m_bDateAll)
|
||||
|
||||
//qDebug() << num << " : " << strData;
|
||||
}
|
||||
|
||||
mecab_destroy(mecab);
|
||||
/*
|
||||
for (int nCount = 0 ; nCount < pCurrent->rowCount(); nCount++ )
|
||||
{
|
||||
QString strData = pCurrent->item(nCount,m_nPosBody)->text();
|
||||
qDebug() << strData;
|
||||
}
|
||||
|
||||
for(QHash<QString, int>::iterator iterPos = pWidget->m_HashResult[num].begin(); iterPos != pWidget->m_HashResult[num].end(); iterPos++)
|
||||
{
|
||||
qDebug() << num << " : " << iterPos.key() << " ===== " << iterPos.value();
|
||||
}
|
||||
|
||||
foreach(QString str, m_slMorphereList)
|
||||
{
|
||||
qDebug() << num << " : " << str;
|
||||
}
|
||||
qDebug() << num << " : " << m_bDateAll;
|
||||
qDebug() << num << " : " << m_bPeriod;
|
||||
qDebug() << num << " : " << m_nDateStart;
|
||||
qDebug() << num << " : " << m_nDateEnd;
|
||||
qDebug() << num << " : " << pWidget->m_HashResult[num].isEmpty();
|
||||
*/
|
||||
}
|
||||
|
||||
QString KeywordThread::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 KeywordThread::setKeywordThread(QMutex &_mutex, int number, int &_nCount)
|
||||
{
|
||||
num = number;
|
||||
mutex = &_mutex;
|
||||
nCount = &_nCount;
|
||||
}
|
||||
|
||||
void KeywordThread::setCenterKeyword(QString strCKeyword)
|
||||
{
|
||||
m_strCKeyword = strCKeyword;
|
||||
}
|
||||
98
MorphereAnalyzer/keywordthread.h
Normal file
98
MorphereAnalyzer/keywordthread.h
Normal file
@@ -0,0 +1,98 @@
|
||||
#ifndef KEYWORDTHREAD
|
||||
#define KEYWORDTHREAD
|
||||
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
#include "widget.h"
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
#include "mecab.h"
|
||||
#include <QLibrary>
|
||||
|
||||
class SAnaly2;
|
||||
class KeywordThread : public QThread
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
KeywordThread(QObject *parent = NULL);
|
||||
KeywordThread(int number);
|
||||
KeywordThread(QMutex &_mutex, int number, int &_nCount);
|
||||
|
||||
private:
|
||||
|
||||
enum {
|
||||
MONDAY = 1,
|
||||
TUESDAY,
|
||||
WEDNESDAY,
|
||||
THURSDAY,
|
||||
FRIDAY,
|
||||
SATURDAY,
|
||||
SUNDAY
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
WEEK = 7
|
||||
};
|
||||
int num;
|
||||
QWidget *m_pQWidget;
|
||||
int m_nThread;
|
||||
QStringList m_slMorphereList;
|
||||
int m_nSource;
|
||||
bool m_bPeriod;
|
||||
bool m_bDateAll;
|
||||
int m_nPeriod; // 0 none, 1 1day, 2 1week, 3 1month;
|
||||
unsigned int m_nDateStart;
|
||||
unsigned int m_nDateEnd;
|
||||
int m_nTitleBody;
|
||||
Widget *m_pWidget;
|
||||
int m_nPosDate;
|
||||
int m_nPosBody;
|
||||
int m_nPosTitle;
|
||||
int m_nPosPlatformTitle;
|
||||
QMutex *mutex;
|
||||
SAnaly2 *pWidget;
|
||||
QTabWidget *m_pTabWidget;
|
||||
int *nCount;
|
||||
QString m_strCKeyword;
|
||||
|
||||
protected:
|
||||
void run();
|
||||
|
||||
public:
|
||||
void setThreadNumber(int _nThread = 1);
|
||||
int getThreadNumber();
|
||||
void setWidget(QWidget *_pWidget);
|
||||
QWidget* getWidget();
|
||||
void setMorphereList(const QStringList morpherelist);
|
||||
void setMorphereList(const QString morphere);
|
||||
QStringList getMorphereList();
|
||||
void resetMorphereList();
|
||||
void setParametersfromWidget(QWidget *_pWidget, int _nSource);
|
||||
void setPeriod(const int _nPeriod);
|
||||
int getPeriod();
|
||||
void setDate(const QString _strStart, const QString _strEnd);
|
||||
void setDate(const QDateTime _dtStart, const QDateTime _dtEnd);
|
||||
void setDateStart(const QString _strStart);
|
||||
void setDateStart(const QDateTime _dtStart);
|
||||
void setDateEnd(const QString _strEnd);
|
||||
void setDateEnd(const QDateTime _dtStart);
|
||||
unsigned int getDateStart();
|
||||
unsigned int getDateEnd();
|
||||
void setTitleBody(const int _n);
|
||||
void setSource(QWidget* _qwidget);
|
||||
void setPosDate(const int _nPos);
|
||||
void setPosBody(const int _nPos);
|
||||
void setPosTitle(const int _nPos);
|
||||
void setPosPlatformTitle(const int _nPos);
|
||||
QString getWeeksInMonth(unsigned int _nDate);
|
||||
void setKeywordThread(QMutex &_mutex, int number, int &_nCount);
|
||||
void setCenterKeyword(QString strCKeyword);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // KEYWORDTHREAD
|
||||
|
||||
@@ -39,12 +39,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "widget.h"
|
||||
#include "stable.h"
|
||||
#include "sanaly1.h"
|
||||
#include "sdictionary.h"
|
||||
#include "tablealgorithm_interface.h"
|
||||
//! [0]
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
@@ -55,9 +54,12 @@ MainWindow::MainWindow()
|
||||
//p_qwAnalyzed1 = new QWidget;
|
||||
//p_qwText = new QWidget;
|
||||
p_qwAnalyzer1 = new SAnaly1;
|
||||
//p_qwAnalyzer2 = new QWidget;
|
||||
p_qwAnalyzer2 = new SAnaly2;
|
||||
|
||||
p_qwDict = new SDictionary;
|
||||
|
||||
p_qwAnalyzer1->setWidget(p_qwDB);
|
||||
p_qwAnalyzer2->setWidget(p_qwDB);
|
||||
|
||||
m_ptwSource = new QTabWidget;
|
||||
m_ptwSource->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@@ -70,7 +72,7 @@ MainWindow::MainWindow()
|
||||
m_ptwResult = new QTabWidget;
|
||||
m_ptwResult->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_ptwResult->addTab(p_qwAnalyzer1, "Analysis1");
|
||||
//m_ptwResult->addTab(p_qwAnalyzer2, "Analysis2");
|
||||
m_ptwResult->addTab(p_qwAnalyzer2, "Analysis2");
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
|
||||
@@ -88,118 +90,11 @@ MainWindow::MainWindow()
|
||||
QString message = tr("A context menu is available by right-clicking");
|
||||
statusBar()->showMessage(message);
|
||||
|
||||
|
||||
setWindowTitle(tr("Morphere Analyzer"));
|
||||
setMinimumSize(800, 600);
|
||||
resize(800, 600);
|
||||
//(STable*)(p_qwDB->GetTabWidget()->widget(1));
|
||||
}
|
||||
//! [2]
|
||||
|
||||
//! [3]
|
||||
/*
|
||||
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu menu(this);
|
||||
menu.addAction(cutAct);
|
||||
menu.addAction(copyAct);
|
||||
menu.addAction(pasteAct);
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
*/
|
||||
//! [3]
|
||||
/*
|
||||
void MainWindow::newFile()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::open()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::save()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::print()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::undo()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::redo()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::cut()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::copy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::paste()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::bold()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::italic()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::leftAlign()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::rightAlign()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::justify()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::center()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::setLineSpacing()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::setParagraphSpacing()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::about()
|
||||
{
|
||||
|
||||
QMessageBox::about(this, tr("About Menu"),
|
||||
tr("The <b>Menu</b> example shows how to create "
|
||||
"menu-bar menus and context menus."));
|
||||
}
|
||||
|
||||
void MainWindow::aboutQt()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
//! [4]
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
//! [5]
|
||||
@@ -228,8 +123,6 @@ void MainWindow::createActions()
|
||||
actMorphereImport->setStatusTip(tr("Import Morphere as a csv file"));
|
||||
connect(actMorphereImport, SIGNAL(triggered()), this, SLOT(importMorphere()));
|
||||
|
||||
|
||||
|
||||
actExit = new QAction(tr("Exit"), this);
|
||||
actExit->setStatusTip(tr("Exit the application"));
|
||||
connect(actExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
@@ -241,140 +134,8 @@ void MainWindow::createActions()
|
||||
actDictionary = new QAction(tr("Dictionary"), this);
|
||||
actAnalyze->setStatusTip(tr("Execute Dictionary Widget"));
|
||||
connect(actDictionary, SIGNAL(triggered()), this, SLOT(slotDictionary()));
|
||||
/*
|
||||
//!
|
||||
newAct = new QAction(tr("&New"), this);
|
||||
newAct->setShortcuts(QKeySequence::New);
|
||||
newAct->setStatusTip(tr("Create a new file"));
|
||||
connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
|
||||
//! [4]
|
||||
|
||||
openAct = new QAction(tr("&Open..."), this);
|
||||
openAct->setShortcuts(QKeySequence::Open);
|
||||
openAct->setStatusTip(tr("Open an existing file"));
|
||||
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
||||
//! [5]
|
||||
|
||||
saveAct = new QAction(tr("&Save"), this);
|
||||
saveAct->setShortcuts(QKeySequence::Save);
|
||||
saveAct->setStatusTip(tr("Save the document to disk"));
|
||||
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
|
||||
|
||||
printAct = new QAction(tr("&Print..."), this);
|
||||
printAct->setShortcuts(QKeySequence::Print);
|
||||
printAct->setStatusTip(tr("Print the document"));
|
||||
connect(printAct, SIGNAL(triggered()), this, SLOT(print()));
|
||||
|
||||
exitAct = new QAction(tr("E&xit"), this);
|
||||
exitAct->setShortcuts(QKeySequence::Quit);
|
||||
exitAct->setStatusTip(tr("Exit the application"));
|
||||
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
||||
|
||||
undoAct = new QAction(tr("&Undo"), this);
|
||||
undoAct->setShortcuts(QKeySequence::Undo);
|
||||
undoAct->setStatusTip(tr("Undo the last operation"));
|
||||
connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));
|
||||
|
||||
redoAct = new QAction(tr("&Redo"), this);
|
||||
redoAct->setShortcuts(QKeySequence::Redo);
|
||||
redoAct->setStatusTip(tr("Redo the last operation"));
|
||||
connect(redoAct, SIGNAL(triggered()), this, SLOT(redo()));
|
||||
|
||||
cutAct = new QAction(tr("Cu&t"), this);
|
||||
cutAct->setShortcuts(QKeySequence::Cut);
|
||||
cutAct->setStatusTip(tr("Cut the current selection's contents to the "
|
||||
"clipboard"));
|
||||
connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));
|
||||
|
||||
copyAct = new QAction(tr("&Copy"), this);
|
||||
copyAct->setShortcuts(QKeySequence::Copy);
|
||||
copyAct->setStatusTip(tr("Copy the current selection's contents to the "
|
||||
"clipboard"));
|
||||
connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
|
||||
|
||||
pasteAct = new QAction(tr("&Paste"), this);
|
||||
pasteAct->setShortcuts(QKeySequence::Paste);
|
||||
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
|
||||
"selection"));
|
||||
connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));
|
||||
|
||||
boldAct = new QAction(tr("&Bold"), this);
|
||||
boldAct->setCheckable(true);
|
||||
boldAct->setShortcut(QKeySequence::Bold);
|
||||
boldAct->setStatusTip(tr("Make the text bold"));
|
||||
connect(boldAct, SIGNAL(triggered()), this, SLOT(bold()));
|
||||
|
||||
QFont boldFont = boldAct->font();
|
||||
boldFont.setBold(true);
|
||||
boldAct->setFont(boldFont);
|
||||
|
||||
italicAct = new QAction(tr("&Italic"), this);
|
||||
italicAct->setCheckable(true);
|
||||
italicAct->setShortcut(QKeySequence::Italic);
|
||||
italicAct->setStatusTip(tr("Make the text italic"));
|
||||
connect(italicAct, SIGNAL(triggered()), this, SLOT(italic()));
|
||||
|
||||
QFont italicFont = italicAct->font();
|
||||
italicFont.setItalic(true);
|
||||
italicAct->setFont(italicFont);
|
||||
|
||||
setLineSpacingAct = new QAction(tr("Set &Line Spacing..."), this);
|
||||
setLineSpacingAct->setStatusTip(tr("Change the gap between the lines of a "
|
||||
"paragraph"));
|
||||
connect(setLineSpacingAct, SIGNAL(triggered()), this, SLOT(setLineSpacing()));
|
||||
|
||||
setParagraphSpacingAct = new QAction(tr("Set &Paragraph Spacing..."), this);
|
||||
setParagraphSpacingAct->setStatusTip(tr("Change the gap between paragraphs"));
|
||||
connect(setParagraphSpacingAct, SIGNAL(triggered()),
|
||||
this, SLOT(setParagraphSpacing()));
|
||||
|
||||
aboutAct = new QAction(tr("&About"), this);
|
||||
aboutAct->setStatusTip(tr("Show the application's About box"));
|
||||
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
||||
|
||||
aboutQtAct = new QAction(tr("About &Qt"), this);
|
||||
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
|
||||
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||
connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt()));
|
||||
|
||||
leftAlignAct = new QAction(tr("&Left Align"), this);
|
||||
leftAlignAct->setCheckable(true);
|
||||
leftAlignAct->setShortcut(tr("Ctrl+L"));
|
||||
leftAlignAct->setStatusTip(tr("Left align the selected text"));
|
||||
connect(leftAlignAct, SIGNAL(triggered()), this, SLOT(leftAlign()));
|
||||
|
||||
rightAlignAct = new QAction(tr("&Right Align"), this);
|
||||
rightAlignAct->setCheckable(true);
|
||||
rightAlignAct->setShortcut(tr("Ctrl+R"));
|
||||
rightAlignAct->setStatusTip(tr("Right align the selected text"));
|
||||
connect(rightAlignAct, SIGNAL(triggered()), this, SLOT(rightAlign()));
|
||||
|
||||
justifyAct = new QAction(tr("&Justify"), this);
|
||||
justifyAct->setCheckable(true);
|
||||
justifyAct->setShortcut(tr("Ctrl+J"));
|
||||
justifyAct->setStatusTip(tr("Justify the selected text"));
|
||||
connect(justifyAct, SIGNAL(triggered()), this, SLOT(justify()));
|
||||
|
||||
centerAct = new QAction(tr("&Center"), this);
|
||||
centerAct->setCheckable(true);
|
||||
centerAct->setShortcut(tr("Ctrl+E"));
|
||||
centerAct->setStatusTip(tr("Center the selected text"));
|
||||
connect(centerAct, SIGNAL(triggered()), this, SLOT(center()));
|
||||
|
||||
//! [6] //! [7]
|
||||
alignmentGroup = new QActionGroup(this);
|
||||
alignmentGroup->addAction(leftAlignAct);
|
||||
alignmentGroup->addAction(rightAlignAct);
|
||||
alignmentGroup->addAction(justifyAct);
|
||||
alignmentGroup->addAction(centerAct);
|
||||
leftAlignAct->setChecked(true);
|
||||
//! [6]
|
||||
//! */
|
||||
}
|
||||
//! [7]
|
||||
|
||||
//! [8]
|
||||
//!
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
//! [9] //! [10]
|
||||
@@ -403,34 +164,6 @@ void MainWindow::createMenus()
|
||||
menuAnalyze->addAction(actAnalyze);
|
||||
|
||||
|
||||
/*
|
||||
editMenu = menuBar()->addMenu(tr("&Edit"));
|
||||
editMenu->addAction(undoAct);
|
||||
editMenu->addAction(redoAct);
|
||||
editMenu->addSeparator();
|
||||
editMenu->addAction(cutAct);
|
||||
editMenu->addAction(copyAct);
|
||||
editMenu->addAction(pasteAct);
|
||||
editMenu->addSeparator();
|
||||
|
||||
helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||
helpMenu->addAction(aboutAct);
|
||||
helpMenu->addAction(aboutQtAct);
|
||||
//! [8]
|
||||
|
||||
//! [12]
|
||||
formatMenu = editMenu->addMenu(tr("&Format"));
|
||||
formatMenu->addAction(boldAct);
|
||||
formatMenu->addAction(italicAct);
|
||||
formatMenu->addSeparator()->setText(tr("Alignment"));
|
||||
formatMenu->addAction(leftAlignAct);
|
||||
formatMenu->addAction(rightAlignAct);
|
||||
formatMenu->addAction(justifyAct);
|
||||
formatMenu->addAction(centerAct);
|
||||
formatMenu->addSeparator();
|
||||
formatMenu->addAction(setLineSpacingAct);
|
||||
formatMenu->addAction(setParagraphSpacingAct);
|
||||
*/
|
||||
}
|
||||
//! [12]
|
||||
|
||||
@@ -452,9 +185,7 @@ void MainWindow::exportDB()
|
||||
|
||||
void MainWindow::importMorphere()
|
||||
{
|
||||
qDebug() << "import is executed";
|
||||
p_qwAnalyzer1->FileImport();
|
||||
ViewResult();
|
||||
}
|
||||
|
||||
void MainWindow::exportMorphere()
|
||||
@@ -464,96 +195,7 @@ void MainWindow::exportMorphere()
|
||||
|
||||
void MainWindow::exportOriginalMorphere()
|
||||
{
|
||||
|
||||
QString strFilename = QFileDialog::getSaveFileName(0,"Exoprt 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);
|
||||
|
||||
/*
|
||||
out << "#Head#,";
|
||||
for (int nCount = 0;nCount < pCurrent->columnCount() ;nCount++ )
|
||||
out << pCurrent->horizontalHeaderItem(nCount)->text() << ",";
|
||||
|
||||
m_pProgress->setRange(0,pCurrent->rowCount()-1);
|
||||
*/
|
||||
|
||||
for( QMap<QString,QMap<QString,QMap<int, QString> > >::iterator iterPos = p_qwAnalyzer1->m_mapViewResult.begin(); iterPos != p_qwAnalyzer1->m_mapViewResult.end(); iterPos++)
|
||||
{
|
||||
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos.value().begin(); iterPos2 != iterPos.value().end(); iterPos2++)
|
||||
{
|
||||
QMapIterator<int, QString> i(p_qwAnalyzer1->m_mapViewResult[iterPos.key()][iterPos2.key()]);
|
||||
i.toBack();
|
||||
while(i.hasPrevious())
|
||||
{
|
||||
i.previous();
|
||||
out << "\"" << iterPos.key() << "\"" << ",";
|
||||
out << "\"" << iterPos2.key() << "\"" << ",";
|
||||
out << "\"" << i.value() << "\"" << ",";
|
||||
out << "\"" << i.key() << "\"" << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
/*
|
||||
for( QMap<QString,QMap<QString,QMap<int, QString> > >::iterator iterPos = p_qwAnalyzer1->m_mapViewResult.begin(); iterPos != p_qwAnalyzer1->m_mapViewResult.end(); iterPos++)
|
||||
{
|
||||
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos.value().begin(); iterPos2 != iterPos.value().end(); iterPos2++)
|
||||
{
|
||||
for(QMap<int, QString>::iterator iterPos3 = iterPos2.value().begin();iterPos3 != iterPos2.value().end(); iterPos3++)
|
||||
{
|
||||
out2 << iterPos.key() << "," << iterPos2.key() << "," << iterPos3.key() << "," << iterPos3.value() << "\n";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for( QMap<QString,QMap<QString,QMap<int, QString> > >::iterator iterPos = p_qwAnalyzer1->m_mapViewResult.begin(); iterPos != p_qwAnalyzer1->m_mapViewResult.end(); iterPos++)
|
||||
{
|
||||
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos.value().begin(); iterPos2 != iterPos.value().end(); iterPos2++)
|
||||
{
|
||||
QMapIterator<int, QString> i(p_qwAnalyzer1->m_mapViewResult[iterPos.key()][iterPos2.key()]);
|
||||
i.toBack();
|
||||
while(i.hasPrevious())
|
||||
{
|
||||
i.previous();
|
||||
out2 << iterPos.key() << "," << iterPos2.key() << "," << i.key() << "," << i.value() << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QFile file("result.txt");
|
||||
|
||||
if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug() << "File read error";
|
||||
|
||||
return ;
|
||||
}
|
||||
QTextStream out(&file);
|
||||
|
||||
for(QMap<QString, int>::iterator iterPos = p_qwAnalyzer1->m_TotalResult.begin(); iterPos != p_qwAnalyzer1->m_TotalResult.end(); iterPos++)
|
||||
{
|
||||
QString strkey = iterPos.key();
|
||||
QStringList strlistKey = strkey.split("~!@");
|
||||
foreach(QString str, strlistKey)
|
||||
{
|
||||
out << str << ",";
|
||||
}
|
||||
out << iterPos.value() << "\n";
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
*/
|
||||
|
||||
p_qwAnalyzer1->RawFileExport();
|
||||
}
|
||||
|
||||
void MainWindow::slotAnalyze()
|
||||
@@ -561,6 +203,7 @@ void MainWindow::slotAnalyze()
|
||||
QMessageBox msg;
|
||||
msg.setText("Please choose...");
|
||||
msg.setModal(true);
|
||||
|
||||
QPushButton *pbTitle = msg.addButton("Title",QMessageBox::ActionRole);
|
||||
QPushButton *pbBody = msg.addButton("Body",QMessageBox::ActionRole);
|
||||
QPushButton *pbAll = msg.addButton("ALL",QMessageBox::ActionRole);
|
||||
@@ -572,25 +215,20 @@ void MainWindow::slotAnalyze()
|
||||
else if (msg.clickedButton() == pbAll) { setbody = 2; }
|
||||
else if (msg.clickedButton() == pbPlatformTitle) { setbody = 3; }
|
||||
|
||||
|
||||
QMessageBox msg2;
|
||||
msg2.setText("Please wait...");
|
||||
msg2.setVisible(true);
|
||||
|
||||
for(int i = 0; i < 16;i++)
|
||||
{
|
||||
p_qwAnalyzer1->m_HashResult[i].clear();
|
||||
}
|
||||
//p_qwAnalyzer1->MemClear();
|
||||
p_qwAnalyzer1->m_mapViewResult.clear();
|
||||
p_qwAnalyzer1->m_TotalResult.clear();
|
||||
|
||||
if(m_ptwResult->currentIndex() == 0)
|
||||
{
|
||||
ExecThread(setbody);
|
||||
EmergeThreadResult();
|
||||
SortViewResult();
|
||||
ViewResult();
|
||||
p_qwAnalyzer1->Exec(setbody);
|
||||
}
|
||||
else if(m_ptwResult->currentIndex() == 1)
|
||||
{
|
||||
p_qwAnalyzer2->Exec(setbody);
|
||||
}
|
||||
|
||||
msg2.setVisible(false);
|
||||
}
|
||||
|
||||
@@ -599,179 +237,3 @@ void MainWindow::slotDictionary()
|
||||
p_qwDict->show();
|
||||
p_qwDict->repaint();
|
||||
}
|
||||
|
||||
void MainWindow::ExecThread(int _setBodyTitle)
|
||||
{
|
||||
int nCount = 0;
|
||||
m_pThread = new AnalyzerThread*[p_qwAnalyzer1->getThread()];
|
||||
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
||||
{
|
||||
m_pThread[i] = new AnalyzerThread(mutex, i, nCount);
|
||||
m_pThread[i]->setParametersfromWidget(p_qwAnalyzer1,m_ptwResult->currentIndex());
|
||||
m_pThread[i]->setWidget(p_qwDB);
|
||||
m_pThread[i]->setPosBody(p_qwDB->getBodyPosition());
|
||||
m_pThread[i]->setPosDate(p_qwDB->getDatePosition());
|
||||
m_pThread[i]->setPosTitle(p_qwDB->getTitlePosition());
|
||||
m_pThread[i]->setPosPlatformTitle(p_qwDB->getPlatformTitlePosition());
|
||||
m_pThread[i]->setTitleBody(_setBodyTitle);
|
||||
}
|
||||
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
||||
{
|
||||
m_pThread[i]->start();
|
||||
}
|
||||
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
||||
{
|
||||
m_pThread[i]->wait();
|
||||
}
|
||||
|
||||
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
||||
{
|
||||
delete m_pThread[i];
|
||||
}
|
||||
delete[] m_pThread;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::EmergeThreadResult()
|
||||
{
|
||||
for(int i=0;i<p_qwAnalyzer1->getThread();i++)
|
||||
{
|
||||
for(QHash<QString, int>::iterator iterPos = p_qwAnalyzer1->m_HashResult[i].begin(); iterPos != p_qwAnalyzer1->m_HashResult[i].end();iterPos++)
|
||||
{
|
||||
if(p_qwAnalyzer1->m_TotalResult.contains(iterPos.key()))
|
||||
{
|
||||
p_qwAnalyzer1->m_TotalResult[iterPos.key()] += iterPos.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
p_qwAnalyzer1->m_TotalResult.insert(iterPos.key(), iterPos.value());
|
||||
}
|
||||
}
|
||||
p_qwAnalyzer1->m_HashResult[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::SortViewResult()
|
||||
{
|
||||
|
||||
if(p_qwAnalyzer1->isSortDateMorphereChecked())
|
||||
{
|
||||
for(QMap<QString, int>::iterator iterPos = p_qwAnalyzer1->m_TotalResult.begin(); iterPos != p_qwAnalyzer1->m_TotalResult.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(p_qwAnalyzer1->m_mapViewResult.contains(strDate))
|
||||
{
|
||||
if(p_qwAnalyzer1->m_mapViewResult.value(strDate).contains(strMorphere))
|
||||
{
|
||||
p_qwAnalyzer1->m_mapViewResult[(strDate)][(strMorphere)].insertMulti(count, strKeyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMap<int, QString> qLast;
|
||||
qLast.insert(count, strKeyword);
|
||||
p_qwAnalyzer1->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);
|
||||
p_qwAnalyzer1->m_mapViewResult.insert(strDate, qMedium);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(QMap<QString, int>::iterator iterPos = p_qwAnalyzer1->m_TotalResult.begin(); iterPos != p_qwAnalyzer1->m_TotalResult.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(p_qwAnalyzer1->m_mapViewResult.contains(strMorphere))
|
||||
{
|
||||
if(p_qwAnalyzer1->m_mapViewResult.value(strMorphere).contains(strDate))
|
||||
{
|
||||
p_qwAnalyzer1->m_mapViewResult[(strMorphere)][(strDate)].insertMulti(count, strKeyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMap<int, QString> qLast;
|
||||
qLast.insert(count, strKeyword);
|
||||
p_qwAnalyzer1->m_mapViewResult[(strMorphere)].insert(strDate, qLast);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMap<int, QString> qLast;
|
||||
qLast.insert(count , strKeyword);
|
||||
QMap<QString, QMap<int, QString> > qMedium;
|
||||
qMedium.insert(strDate, qLast);
|
||||
p_qwAnalyzer1->m_mapViewResult.insert(strMorphere, qMedium);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ViewResult()
|
||||
{
|
||||
|
||||
foreach(STable* ptable, m_lTable)
|
||||
{
|
||||
ptable->clear();
|
||||
delete ptable;
|
||||
}
|
||||
m_lTable.clear();
|
||||
|
||||
foreach(QTabWidget* pwidget, m_lTabWidget)
|
||||
{
|
||||
pwidget->clear();
|
||||
delete pwidget;
|
||||
}
|
||||
m_lTabWidget.clear();
|
||||
|
||||
|
||||
m_ptwTable = p_qwAnalyzer1->getQTabWidget();
|
||||
m_ptwTable->clear();
|
||||
|
||||
for( QMap<QString,QMap<QString,QMap<int, QString> > >::iterator iterPos = p_qwAnalyzer1->m_mapViewResult.begin(); iterPos != p_qwAnalyzer1->m_mapViewResult.end(); iterPos++)
|
||||
{
|
||||
QTabWidget* temp = new QTabWidget;
|
||||
for(QMap<QString, QMap<int, QString> >::iterator iterPos2 = iterPos.value().begin(); iterPos2 != iterPos.value().end(); iterPos2++)
|
||||
{
|
||||
int ncRow = 0;
|
||||
|
||||
STable *pNew = new STable;
|
||||
pNew->setColumnCount(2);
|
||||
pNew->setRowCount(p_qwAnalyzer1->m_mapViewResult[iterPos.key()][iterPos2.key()].size());
|
||||
pNew->setHorizontalHeaderItem(0 ,new QTableWidgetItem("Keyword"));
|
||||
pNew->setHorizontalHeaderItem(1 ,new QTableWidgetItem("Count"));
|
||||
|
||||
QMapIterator<int, QString> i(p_qwAnalyzer1->m_mapViewResult[iterPos.key()][iterPos2.key()]);
|
||||
i.toBack();
|
||||
while(i.hasPrevious())
|
||||
{
|
||||
i.previous();
|
||||
pNew->setItem(ncRow,0,new QTableWidgetItem(QString(i.value())));
|
||||
pNew->setItem(ncRow,1,new QTableWidgetItem(QString::number(i.key())));
|
||||
ncRow++;
|
||||
}
|
||||
temp->addTab(pNew, iterPos2.key());
|
||||
m_lTable << pNew;
|
||||
}
|
||||
m_ptwTable->addTab(temp, iterPos.key());
|
||||
m_lTabWidget << temp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,10 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTabWidget>
|
||||
#include "sanalyzer.h"
|
||||
#include "widget.h"
|
||||
#include "sanaly1.h"
|
||||
#include "sanaly2.h"
|
||||
|
||||
#include <QList>
|
||||
#include "sdictionary.h"
|
||||
|
||||
@@ -63,37 +64,12 @@ class MainWindow : public QMainWindow
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
void ExecThread(int _setBodyTitle);
|
||||
void EmergeThreadResult();
|
||||
void SortViewResult();
|
||||
void ViewResult();
|
||||
protected:
|
||||
//void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
|
||||
//! [0]
|
||||
|
||||
//! [1]
|
||||
private slots:
|
||||
/*
|
||||
void newFile();
|
||||
void open();
|
||||
void save();
|
||||
void print();
|
||||
void undo();
|
||||
void redo();
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void bold();
|
||||
void italic();
|
||||
void leftAlign();
|
||||
void rightAlign();
|
||||
void justify();
|
||||
void center();
|
||||
void setLineSpacing();
|
||||
void setParagraphSpacing();
|
||||
void about();
|
||||
void aboutQt();
|
||||
*/
|
||||
void newDB();
|
||||
void importDB();
|
||||
void exportDB();
|
||||
@@ -117,34 +93,7 @@ private:
|
||||
//! [3]
|
||||
//!
|
||||
//!
|
||||
/*
|
||||
* QMenu *fileMenu;
|
||||
QMenu *editMenu;
|
||||
QMenu *formatMenu;
|
||||
QMenu *helpMenu;
|
||||
QActionGroup *alignmentGroup;
|
||||
QAction *newAct;
|
||||
QAction *openAct;
|
||||
QAction *saveAct;
|
||||
QAction *printAct;
|
||||
QAction *exitAct;
|
||||
QAction *undoAct;
|
||||
QAction *redoAct;
|
||||
QAction *cutAct;
|
||||
QAction *copyAct;
|
||||
QAction *pasteAct;
|
||||
QAction *boldAct;
|
||||
QAction *italicAct;
|
||||
QAction *leftAlignAct;
|
||||
QAction *rightAlignAct;
|
||||
QAction *justifyAct;
|
||||
QAction *centerAct;
|
||||
QAction *setLineSpacingAct;
|
||||
QAction *setParagraphSpacingAct;
|
||||
QAction *aboutAct;
|
||||
QAction *aboutQtAct;
|
||||
QLabel *infoLabel;
|
||||
*/
|
||||
|
||||
QTabWidget *m_ptwSource;
|
||||
QTabWidget *m_ptwResult;
|
||||
QWidget *m_qwMain;
|
||||
@@ -156,7 +105,7 @@ private:
|
||||
SDictionary *p_qwDict;
|
||||
|
||||
SAnaly1 *p_qwAnalyzer1;
|
||||
QWidget *p_qwAnalyzer2;
|
||||
SAnaly2 *p_qwAnalyzer2;
|
||||
|
||||
|
||||
QAction *actDBNew;
|
||||
@@ -173,12 +122,14 @@ private:
|
||||
QMenu *menuFile;
|
||||
QMenu *menuAnalyze;
|
||||
QMenu *menuDictionary;
|
||||
|
||||
//AnalyzerThread m_pThread[16];
|
||||
/*
|
||||
QMutex mutex;
|
||||
AnalyzerThread **m_pThread;
|
||||
//AnalyzerThread m_pThread[16];
|
||||
QList<STable*> m_lTable;
|
||||
QList<QTabWidget*> m_lTabWidget;
|
||||
|
||||
*/
|
||||
QTabWidget* m_ptwTable;
|
||||
};
|
||||
//! [3]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,5 @@
|
||||
#ifndef SANALY1
|
||||
#define SANALY1
|
||||
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
#include <QCalendarWidget>
|
||||
#include <QDateEdit>
|
||||
@@ -21,7 +18,9 @@
|
||||
#include <QSqlDatabase>
|
||||
#include <QListWidgetItem>
|
||||
#include "stable.h"
|
||||
|
||||
#include "widget.h"
|
||||
#include "sanalyzer.h"
|
||||
#include <QMutex>
|
||||
class SAnaly1 : public QWidget
|
||||
{
|
||||
enum E_COLUMN
|
||||
@@ -49,7 +48,7 @@ public:
|
||||
QStringList getMorphereList();
|
||||
bool getDateAll();
|
||||
QString getUserDictList();
|
||||
|
||||
void Exec(int setBodyTitle);
|
||||
|
||||
private:
|
||||
// Data
|
||||
@@ -60,40 +59,13 @@ private:
|
||||
QDateEdit *m_pdeEnd;
|
||||
//QPushButton *m_ppbInsertCalc;
|
||||
//QComboBox *m_pcbDateCatalog;
|
||||
int m_nColumn;
|
||||
// Keyword
|
||||
QComboBox *m_pcbCatalog;
|
||||
QComboBox *m_pcbKeyword;
|
||||
QComboBox *m_pcbMethod;
|
||||
QLineEdit *m_pleString;
|
||||
//QPushButton *m_ppbInsertSearch;
|
||||
// Length
|
||||
QComboBox *m_pcbLengthCatalog;
|
||||
QComboBox *m_pcbLengthComp;
|
||||
QComboBox *m_pcbLengthInsDel;
|
||||
QLineEdit *m_pleLength;
|
||||
// Filter
|
||||
QListWidget *m_plwFilterGroup;
|
||||
|
||||
QListWidget *m_plwFilter;
|
||||
QLineEdit *m_pleFilterGroup;
|
||||
QGroupBox *m_pgbFilter;
|
||||
// Replace
|
||||
QComboBox *m_pcbReplaceCatalog;
|
||||
QComboBox *m_pcbReplaceFind;
|
||||
QLineEdit *m_pleReplaceFind;
|
||||
QLineEdit *m_pleReplace;
|
||||
|
||||
// Count
|
||||
QComboBox *m_pcbCountCatalog;
|
||||
|
||||
//
|
||||
QTabWidget *m_ptwData;
|
||||
//
|
||||
QProgressBar *m_pProgress;
|
||||
// Column
|
||||
QVector <QStringList> m_vecColumn;
|
||||
|
||||
AnalyzerThread **m_pThread;
|
||||
// MorphereList
|
||||
QListWidget *m_plwMorphereList;
|
||||
QListWidget *m_plwMorphereAdd;
|
||||
@@ -110,12 +82,16 @@ private:
|
||||
QListWidgetItem **m_plwiMorphere;
|
||||
QStringList m_strlistMorphere;
|
||||
QStringList m_strlistMorphereko;
|
||||
|
||||
Widget *m_pwidget;
|
||||
QRadioButton *m_rbDateMorphere;
|
||||
QRadioButton *m_rbMorphereDate;
|
||||
QButtonGroup *m_bgRadioGroup;
|
||||
|
||||
QComboBox *m_pcbDictionary;
|
||||
QList<STable*> m_lTable;
|
||||
QList<QTabWidget*> m_lTabWidget;
|
||||
QTabWidget* m_ptwTable;
|
||||
QMutex mutex;
|
||||
public:
|
||||
struct m_mapKey
|
||||
{
|
||||
@@ -130,15 +106,6 @@ public:
|
||||
QMap<QString, QMap<QString, QMap<int, QString> > > m_mapViewResult;
|
||||
|
||||
private:
|
||||
QMenuBar *setMenuWidget();
|
||||
QGroupBox *setDataWidgets();
|
||||
QGroupBox *setDateWidgets();
|
||||
QGroupBox *setCountWidgets();
|
||||
QGroupBox *setSearchWidgets();
|
||||
QGroupBox *setLengthWidgets();
|
||||
QGroupBox *setFilterWidgets();
|
||||
QGroupBox *setReplaceWidgets();
|
||||
|
||||
QGroupBox *setMorphereList();
|
||||
QGroupBox *setDate();
|
||||
QGroupBox *setFilter();
|
||||
@@ -146,41 +113,18 @@ private:
|
||||
QGroupBox *setSort();
|
||||
QGroupBox *setDictionary();
|
||||
|
||||
void ExecThread(int _setBodyTitle);
|
||||
void EmergeThreadResult();
|
||||
void SortViewResult();
|
||||
void ViewResult();
|
||||
|
||||
QTableWidget *AddTable(QString _str);
|
||||
void SetTableHead();
|
||||
void InsertCopyRow(int _nRow,QTableWidget *_pCurrent,QTableWidget *_pNew);
|
||||
void DataReload(QString _strTableName,int _nSelect);
|
||||
void InsertFilter(int _nType,QString _strJson,int _nGroup);
|
||||
void InsertTimeFilter(int _nTimeCategory ,QDate _dateStart ,QDate _dateEnd ,int _nGroup);
|
||||
void InsertSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword, QString _str,int _nGroup);
|
||||
void InsertLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup);
|
||||
void InsertReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup);
|
||||
void RefreshFilter(int _nGroup);
|
||||
|
||||
bool ReloadColumn();
|
||||
QString GetArticleType(int _nSelect);
|
||||
public slots:
|
||||
void CloseTab(int index);
|
||||
void DoubleClickTab(int index);
|
||||
void SearchDate();
|
||||
void CountSave();
|
||||
void SearchKeyword();
|
||||
void DataGroupRefresh();
|
||||
void DataGroupItemChanged ( QListWidgetItem * item );
|
||||
void FilterGroupInsert();
|
||||
void FilterGroupDelete();
|
||||
void FilterGroupModify();
|
||||
void FilterGroupRefresh();
|
||||
void currentGroupItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
|
||||
void FilterDelete();
|
||||
void currentFilterItemChanged(QListWidgetItem *_pCurrent, QListWidgetItem *_pPrev=0);
|
||||
void SearchLengthInsert();
|
||||
void SearchReplaceInsert();
|
||||
void FileNew();
|
||||
void FileImport();
|
||||
void FileExport();
|
||||
void FileExit();
|
||||
void RawFileExport();
|
||||
void MemClear();
|
||||
void MorphereListAdd();
|
||||
void MorphereListDel();
|
||||
@@ -188,12 +132,9 @@ public slots:
|
||||
void DelDictionary();
|
||||
bool setListMorphere(QStringList& MorphereEN, QStringList& MorphereKO);
|
||||
QTabWidget* getQTabWidget();
|
||||
|
||||
|
||||
void setWidget(Widget *widget);
|
||||
bool isSortMorphereDateChecked();
|
||||
|
||||
bool isSortDateMorphereChecked();
|
||||
|
||||
};
|
||||
|
||||
#endif // SANALY1
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
#include "sanalyzer.h"
|
||||
#include "sanaly1.h"
|
||||
#include <QFile>
|
||||
AnalyzerThread::AnalyzerThread(QObject *parent) : QThread(parent), m_nThread(1), m_pWidget(NULL), m_nSource(0), m_bPeriod(false), m_nPeriod(0)
|
||||
{
|
||||
@@ -16,7 +17,6 @@ AnalyzerThread::AnalyzerThread(QMutex &_mutex, int _number, int &_nCount)
|
||||
nCount = &_nCount;
|
||||
}
|
||||
|
||||
|
||||
void AnalyzerThread::setThreadNumber(int _nThread)
|
||||
{
|
||||
m_nThread = _nThread;
|
||||
@@ -68,6 +68,7 @@ void AnalyzerThread::setParametersfromWidget(QWidget *_pWidget, int _nSource)
|
||||
setMorphereList(pWidget->getMorphereList());
|
||||
}
|
||||
}
|
||||
|
||||
QStringList AnalyzerThread::getMorphereList()
|
||||
{
|
||||
return m_slMorphereList;
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#ifndef SANALYZER
|
||||
#define SANALYZER
|
||||
|
||||
#endif // SANALYZER
|
||||
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
#include "widget.h"
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
#include "sanaly1.h"
|
||||
#include "mecab.h"
|
||||
#include <QLibrary>
|
||||
|
||||
|
||||
|
||||
class SAnaly1;
|
||||
class AnalyzerThread : public QThread
|
||||
{
|
||||
|
||||
@@ -93,3 +91,4 @@ public:
|
||||
QString getWeeksInMonth(unsigned int _nDate);
|
||||
void setAnalyzerThread(QMutex &_mutex, int number, int &_nCount);
|
||||
};
|
||||
#endif // SANALYZER
|
||||
|
||||
Reference in New Issue
Block a user