2083 lines
60 KiB
C++
2083 lines
60 KiB
C++
#include "ychildrenthread.h"
|
|
#include <QDebug>
|
|
#include "mecab.h"
|
|
#include <QLibrary>
|
|
#include <QDate>
|
|
#include <QDateTime>
|
|
|
|
YMorphereThread* ThreadFactory::getThread(QMap<QString, QString> mapParam)
|
|
{
|
|
if(mapParam.value("Algorithm").trimmed().compare("basic", Qt::CaseInsensitive) == 0)
|
|
{
|
|
return new YBasicMThread();
|
|
}
|
|
else if(mapParam.value("Algorithm").trimmed().compare("onedepth", Qt::CaseInsensitive) == 0)
|
|
{
|
|
return new YOneDepthMThread();
|
|
}
|
|
else if(mapParam.value("Algorithm").trimmed().compare("twodepth", Qt::CaseInsensitive) == 0)
|
|
{
|
|
return new YTwoDepthMThread();
|
|
}
|
|
else if(mapParam.value("Algorithm").trimmed().compare("platformone", Qt::CaseInsensitive) == 0)
|
|
{
|
|
return new YPlatformOneMThread();
|
|
}
|
|
else if(mapParam.value("Algorithm").trimmed().compare("platform", Qt::CaseInsensitive) == 0)
|
|
{
|
|
return new YPlatformMThread();
|
|
}
|
|
else if(mapParam.value("Algorithm").trimmed().compare("id", Qt::CaseInsensitive) == 0)
|
|
{
|
|
return new YIDMThread();
|
|
}
|
|
else if(mapParam.value("Algorithm").trimmed().compare("nxnmatrix", Qt::CaseInsensitive) == 0)
|
|
{
|
|
return new YNNMatrixMThread();
|
|
}
|
|
else
|
|
{
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
void YBasicMThread::run()
|
|
{
|
|
typedef mecab_t* (*mecab_new_fun)(int,char**);
|
|
typedef const char* (*mecab_sparse_tostr_fun)(mecab_t *mecab, const char *str);
|
|
typedef void (*mecab_destroy_fun)(mecab_t *mecab);
|
|
|
|
mecab_t *mecab;
|
|
mecab_new_fun mecab_new = (mecab_new_fun)QLibrary::resolve("libmecab.dll","mecab_new");
|
|
mecab_sparse_tostr_fun mecab_sparse_tostr = (mecab_sparse_tostr_fun)QLibrary::resolve("libmecab.dll","mecab_sparse_tostr");
|
|
|
|
parseParam();
|
|
|
|
if(userdict.length() < 1)
|
|
{
|
|
/*
|
|
char *t[] = {"RRR","-d","dic"};
|
|
int int_t = 3;
|
|
*/
|
|
|
|
char a[] = "RRR";
|
|
char b[] = "-d";
|
|
char c[] = "dic";
|
|
char *t[3];
|
|
t[0] = a;
|
|
t[1] = b;
|
|
t[2] = c;
|
|
int int_t = 3;
|
|
|
|
mecab = mecab_new(int_t, t);
|
|
}
|
|
else
|
|
{
|
|
char *cstr = new char[userdict.toStdString().length() + 1];
|
|
strcpy(cstr, userdict.toStdString().c_str());
|
|
/*
|
|
char **t = {"RRR","-d","dic","-u",cstr};
|
|
int int_t = 5;
|
|
*/
|
|
char a[] = "RRR";
|
|
char b[] = "-d";
|
|
char c[] = "dic";
|
|
char d[] = "-u";
|
|
|
|
char *t[5];
|
|
t[0] = a;
|
|
t[1] = b;
|
|
t[2] = c;
|
|
t[3] = d;
|
|
t[4] = cstr;
|
|
int int_t = 5;
|
|
|
|
mecab = mecab_new(int_t, t);
|
|
delete[] cstr;
|
|
}
|
|
mecab_destroy_fun mecab_destroy = (mecab_destroy_fun)QLibrary::resolve("libmecab.dll","mecab_destroy");
|
|
|
|
|
|
|
|
//qDebug() << num;
|
|
|
|
int nDate = 0;
|
|
while(true)
|
|
{
|
|
QString strTitle;
|
|
QString strBody;
|
|
QString strDate;
|
|
QString strData;
|
|
QString strPlatformTitle;
|
|
QString strArticle;
|
|
{
|
|
mutex->lock();
|
|
if(!m_pDAInterface->hasNext())
|
|
{
|
|
mutex->unlock();
|
|
break;
|
|
}
|
|
strTitle = m_pDAInterface->getArticleTitle();
|
|
strDate = m_pDAInterface->getArticleDate();
|
|
strPlatformTitle = m_pDAInterface->getPlatformTitle();
|
|
strBody = m_pDAInterface->getArticleData();
|
|
strArticle = m_pDAInterface->getArticleForm();
|
|
m_pDAInterface->next();
|
|
mutex->unlock();
|
|
}
|
|
//qDebug() << strArticle;
|
|
//qDebug() << m_nArticle;
|
|
bool bContinue = true;
|
|
{
|
|
switch(m_nArticle)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
{
|
|
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) != 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) != 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!bContinue)
|
|
continue;
|
|
|
|
|
|
{
|
|
switch(m_nTitleBody)
|
|
{
|
|
case 0:
|
|
{
|
|
strData = strTitle;
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
strData = strBody;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
strData = strTitle + "\n" + strBody;
|
|
break;
|
|
}
|
|
case 3:
|
|
strData = strPlatformTitle;
|
|
break;
|
|
}
|
|
strTitle.clear();
|
|
strBody.clear();
|
|
strPlatformTitle.clear();
|
|
}
|
|
|
|
if(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> mapResult;
|
|
|
|
foreach(QString strLine, strListAll)
|
|
{
|
|
QStringList strListLine = strLine.split("\t");
|
|
if(strListLine.size() < 2)
|
|
continue;
|
|
QStringList strpumsa = strListLine.at(1).trimmed().split(",");
|
|
foreach(QString strMorphere, m_slMorphereList)
|
|
{
|
|
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
|
{
|
|
m_strKeyword = strListLine.at(0).toLower();
|
|
m_strMorphere = strMorphere;
|
|
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
|
if(mapResult.contains(strkey))
|
|
{
|
|
(mapResult)[strkey]++;
|
|
}
|
|
|
|
else
|
|
{
|
|
mapResult.insert(strkey,1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!m_bDuplicate)
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
mapResult[iterPos.key()] = 1;
|
|
}
|
|
}
|
|
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
if(m_mapResult.contains(iterPos.key()))
|
|
{
|
|
m_mapResult[iterPos.key()] += iterPos.value();
|
|
}
|
|
else
|
|
{
|
|
m_mapResult.insert(iterPos.key(), iterPos.value());
|
|
}
|
|
}
|
|
|
|
|
|
//if(m_bDateAll)
|
|
|
|
//qDebug() << num << " : " << strData;
|
|
}
|
|
|
|
mecab_destroy(mecab);
|
|
|
|
}
|
|
|
|
void YBasicMThread::parseParam()
|
|
{
|
|
userdict = m_mapParam.value("UserDict");
|
|
m_nArticle = m_mapParam.value("Article").toInt();
|
|
|
|
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
|
|
m_nPeriod = m_mapParam.value("Period").toInt();
|
|
|
|
m_nDateStart = m_mapParam.value("DateStart").toInt();
|
|
m_nDateEnd = m_mapParam.value("DateEnd").toInt();
|
|
|
|
m_bDateAll = true;
|
|
|
|
if(m_mapParam.value("DateALL") == "true")
|
|
m_bDateAll = true;
|
|
else
|
|
m_bDateAll = false;
|
|
|
|
m_slMorphereList = m_mapParam.value("MorphereList").split(" ");
|
|
if(m_mapParam.value("CountMethod") == "Duplicate")
|
|
m_bDuplicate = true;
|
|
else
|
|
m_bDuplicate = false;
|
|
|
|
|
|
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
|
|
|
|
//qDebug() << m_strRecentPeriod;
|
|
|
|
|
|
if(m_strRecentPeriod == "None")
|
|
{
|
|
|
|
}
|
|
else if(m_strRecentPeriod == "Days")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Weeks")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate*7));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Months")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addMonths(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").replace("-","").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Years")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addYears(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
}
|
|
|
|
|
|
void YOneDepthMThread::run()
|
|
{
|
|
typedef mecab_t* (*mecab_new_fun)(int,char**);
|
|
typedef const char* (*mecab_sparse_tostr_fun)(mecab_t *mecab, const char *str);
|
|
typedef void (*mecab_destroy_fun)(mecab_t *mecab);
|
|
|
|
mecab_t *mecab;
|
|
mecab_new_fun mecab_new = (mecab_new_fun)QLibrary::resolve("libmecab.dll","mecab_new");
|
|
mecab_sparse_tostr_fun mecab_sparse_tostr = (mecab_sparse_tostr_fun)QLibrary::resolve("libmecab.dll","mecab_sparse_tostr");
|
|
|
|
parseParam();
|
|
|
|
if(userdict.length() < 1)
|
|
{
|
|
/*
|
|
char *t[] = {"RRR","-d","dic"};
|
|
int int_t = 3;
|
|
*/
|
|
|
|
char a[] = "RRR";
|
|
char b[] = "-d";
|
|
char c[] = "dic";
|
|
char *t[3];
|
|
t[0] = a;
|
|
t[1] = b;
|
|
t[2] = c;
|
|
int int_t = 3;
|
|
|
|
mecab = mecab_new(int_t, t);
|
|
}
|
|
else
|
|
{
|
|
char *cstr = new char[userdict.toStdString().length() + 1];
|
|
strcpy(cstr, userdict.toStdString().c_str());
|
|
/*
|
|
char **t = {"RRR","-d","dic","-u",cstr};
|
|
int int_t = 5;
|
|
*/
|
|
char a[] = "RRR";
|
|
char b[] = "-d";
|
|
char c[] = "dic";
|
|
char d[] = "-u";
|
|
|
|
char *t[5];
|
|
t[0] = a;
|
|
t[1] = b;
|
|
t[2] = c;
|
|
t[3] = d;
|
|
t[4] = cstr;
|
|
int int_t = 5;
|
|
|
|
mecab = mecab_new(int_t, t);
|
|
delete[] cstr;
|
|
}
|
|
mecab_destroy_fun mecab_destroy = (mecab_destroy_fun)QLibrary::resolve("libmecab.dll","mecab_destroy");
|
|
|
|
|
|
|
|
//qDebug() << num;
|
|
|
|
int nDate = 0;
|
|
while(true)
|
|
{
|
|
QString strTitle;
|
|
QString strBody;
|
|
QString strDate;
|
|
QString strData;
|
|
QString strPlatformTitle;
|
|
QString strArticle;
|
|
{
|
|
mutex->lock();
|
|
if(!m_pDAInterface->hasNext())
|
|
{
|
|
mutex->unlock();
|
|
break;
|
|
}
|
|
strTitle = m_pDAInterface->getArticleTitle();
|
|
strDate = m_pDAInterface->getArticleDate();
|
|
strPlatformTitle = m_pDAInterface->getPlatformTitle();
|
|
strBody = m_pDAInterface->getArticleData();
|
|
strArticle = m_pDAInterface->getArticleForm();
|
|
m_pDAInterface->next();
|
|
mutex->unlock();
|
|
}
|
|
|
|
|
|
bool bContinue = true;
|
|
{
|
|
switch(m_nArticle)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
{
|
|
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!bContinue)
|
|
continue;
|
|
|
|
|
|
{
|
|
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> mapResult;
|
|
|
|
foreach(QString strLine, strListAll)
|
|
{
|
|
QStringList strListLine = strLine.split("\t");
|
|
if(strListLine.size() < 2)
|
|
continue;
|
|
QStringList strpumsa = strListLine.at(1).trimmed().split(",");
|
|
foreach(QString strMorphere, m_slMorphereList)
|
|
{
|
|
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
|
{
|
|
m_strKeyword = strListLine.at(0).toLower();
|
|
m_strMorphere = strMorphere;
|
|
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
|
if(mapResult.contains(strkey))
|
|
{
|
|
(mapResult)[strkey]++;
|
|
}
|
|
|
|
else
|
|
{
|
|
mapResult.insert(strkey,1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!m_bDuplicate)
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
mapResult[iterPos.key()] = 1;
|
|
}
|
|
}
|
|
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
if(m_mapResult.contains(iterPos.key()))
|
|
{
|
|
m_mapResult[iterPos.key()] += iterPos.value();
|
|
}
|
|
else
|
|
{
|
|
m_mapResult.insert(iterPos.key(), iterPos.value());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//if(m_bDateAll)
|
|
|
|
//qDebug() << num << " : " << strData;
|
|
}
|
|
|
|
mecab_destroy(mecab);
|
|
|
|
}
|
|
|
|
void YOneDepthMThread::parseParam()
|
|
{
|
|
|
|
userdict = m_mapParam.value("UserDict");
|
|
|
|
m_nArticle = m_mapParam.value("Article").toInt();
|
|
|
|
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
|
|
m_nPeriod = m_mapParam.value("Period").toInt();
|
|
|
|
m_nDateStart = m_mapParam.value("DateStart").toInt();
|
|
m_nDateEnd = m_mapParam.value("DateEnd").toInt();
|
|
|
|
m_bDateAll = true;
|
|
|
|
if(m_mapParam.value("DateALL") == "true")
|
|
m_bDateAll = true;
|
|
else
|
|
m_bDateAll = false;
|
|
|
|
m_slMorphereList = m_mapParam.value("MorphereList").split(" ");
|
|
|
|
m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed();
|
|
if(m_mapParam.value("CountMethod") == "Duplicate")
|
|
m_bDuplicate = true;
|
|
else
|
|
m_bDuplicate = false;
|
|
|
|
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
|
|
|
|
if(m_strRecentPeriod == "None")
|
|
{
|
|
|
|
}
|
|
else if(m_strRecentPeriod == "Days")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Weeks")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate*7));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Months")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addMonths(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Years")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addYears(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
}
|
|
|
|
|
|
void 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;
|
|
QString strArticle;
|
|
{
|
|
mutex->lock();
|
|
if(!m_pDAInterface->hasNext())
|
|
{
|
|
mutex->unlock();
|
|
break;
|
|
}
|
|
strTitle = m_pDAInterface->getArticleTitle();
|
|
strDate = m_pDAInterface->getArticleDate();
|
|
strPlatformTitle = m_pDAInterface->getPlatformTitle();
|
|
strBody = m_pDAInterface->getArticleData();
|
|
strArticle = m_pDAInterface->getArticleForm();
|
|
m_pDAInterface->next();
|
|
mutex->unlock();
|
|
}
|
|
|
|
bool bContinue = true;
|
|
{
|
|
switch(m_nArticle)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
{
|
|
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!bContinue)
|
|
continue;
|
|
|
|
|
|
{
|
|
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> mapResult;
|
|
|
|
foreach(QString strLine, strListAll)
|
|
{
|
|
QStringList strListLine = strLine.split("\t");
|
|
if(strListLine.size() < 2)
|
|
continue;
|
|
QStringList strpumsa = strListLine.at(1).trimmed().split(",");
|
|
foreach(QString strMorphere, m_slMorphereList)
|
|
{
|
|
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
|
{
|
|
m_strKeyword = strListLine.at(0).toLower();
|
|
m_strMorphere = strMorphere;
|
|
QString strkey = m_strDate + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
|
if(mapResult.contains(strkey))
|
|
{
|
|
(mapResult)[strkey]++;
|
|
}
|
|
|
|
else
|
|
{
|
|
mapResult.insert(strkey,1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!m_bDuplicate)
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
mapResult[iterPos.key()] = 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
foreach(QString str, m_slOneDepthKeys)
|
|
{
|
|
if(mapResult.contains(str))
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
if(iterPos.key() == str)
|
|
continue;
|
|
QString key = iterPos.key();
|
|
QStringList slkey = key.split("~!@", QString::SkipEmptyParts);
|
|
int nLength = slkey.length();
|
|
QString strkey = str + "~!@" + slkey.at(nLength - 2) + "~!@" + slkey.at(nLength - 1);
|
|
if(m_mapResult.contains(strkey))
|
|
{
|
|
m_mapResult[strkey] += iterPos.value();
|
|
}
|
|
else
|
|
{
|
|
m_mapResult.insert(strkey, iterPos.value());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
mecab_destroy(mecab);
|
|
}
|
|
|
|
void YTwoDepthMThread::parseParam()
|
|
{
|
|
userdict = m_mapParam.value("UserDict");
|
|
|
|
m_nArticle = m_mapParam.value("Article").toInt();
|
|
|
|
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
|
|
m_nPeriod = m_mapParam.value("Period").toInt();
|
|
|
|
m_nDateStart = m_mapParam.value("DateStart").toInt();
|
|
m_nDateEnd = m_mapParam.value("DateEnd").toInt();
|
|
|
|
m_bDateAll = true;
|
|
|
|
if(m_mapParam.value("DateALL") == "true")
|
|
m_bDateAll = true;
|
|
else
|
|
m_bDateAll = false;
|
|
|
|
m_slMorphereList = m_mapParam.value("MorphereList").split(" ");
|
|
|
|
m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed();
|
|
|
|
m_slOneDepthKeys = m_mapParam.value("OneDepthKeys").split(" ");
|
|
if(m_mapParam.value("CountMethod") == "Duplicate")
|
|
m_bDuplicate = true;
|
|
else
|
|
m_bDuplicate = false;
|
|
|
|
|
|
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
|
|
|
|
if(m_strRecentPeriod == "None")
|
|
{
|
|
|
|
}
|
|
else if(m_strRecentPeriod == "Days")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Weeks")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate*7));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Months")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addMonths(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Years")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addYears(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void YIDMThread::run()
|
|
{
|
|
|
|
}
|
|
|
|
void YIDMThread::parseParam()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
void YNNMatrixMThread::run()
|
|
{
|
|
parseParam();
|
|
|
|
|
|
int nDate = 0;
|
|
while(true)
|
|
{
|
|
QString strTitle;
|
|
QString strBody;
|
|
QString strDate;
|
|
QString strData;
|
|
QString strPlatformTitle;
|
|
QString strArticle;
|
|
{
|
|
mutex->lock();
|
|
if(!m_pDAInterface->hasNext())
|
|
{
|
|
mutex->unlock();
|
|
break;
|
|
}
|
|
strTitle = m_pDAInterface->getArticleTitle();
|
|
strDate = m_pDAInterface->getArticleDate();
|
|
strPlatformTitle = m_pDAInterface->getPlatformTitle();
|
|
strBody = m_pDAInterface->getArticleData();
|
|
strArticle = m_pDAInterface->getArticleForm();
|
|
m_pDAInterface->next();
|
|
mutex->unlock();
|
|
}
|
|
|
|
bool bContinue = true;
|
|
{
|
|
switch(m_nArticle)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
{
|
|
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!bContinue)
|
|
continue;
|
|
|
|
{
|
|
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(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;
|
|
|
|
switch(m_nPeriod)
|
|
{
|
|
case 0:
|
|
{
|
|
m_strDate = "ALL";
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
m_strDate = "D" + QString::number(nDate);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
m_strDate = getWeeksInMonth(nDate);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
m_strDate = "M";
|
|
if((nDate/100) < 10)
|
|
m_strDate += "0";
|
|
m_strDate += QString::number(nDate/100);
|
|
break;
|
|
}
|
|
}
|
|
|
|
QMap<QString, int> mapTemp;
|
|
|
|
foreach(QString strtmp, m_strMKeyword)
|
|
{
|
|
QString strkeyword = strtmp.trimmed();
|
|
mapTemp.insert(strkeyword, 0);
|
|
mapTemp[strkeyword] = strData.count(strkeyword, Qt::CaseInsensitive);
|
|
}
|
|
|
|
|
|
if(!m_bDuplicate)
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = mapTemp.begin(); iterPos != mapTemp.end(); iterPos++)
|
|
{
|
|
if(iterPos.value() > 0)
|
|
{
|
|
mapTemp[iterPos.key()] = 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
for(QMap<QString, int>::iterator iterPos1 = mapTemp.begin(); iterPos1 != mapTemp.end(); iterPos1++)
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos2 = mapTemp.begin(); iterPos2 != mapTemp.end(); iterPos2++)
|
|
{
|
|
if((iterPos1.value() > 0) && (iterPos2.value() > 0))
|
|
{
|
|
QString strkey = m_strDate + "~!@" + iterPos1.key() + "~!@" + iterPos2.key();
|
|
if(m_mapResult.contains(strkey))
|
|
{
|
|
m_mapResult[strkey] += iterPos2.value();
|
|
}
|
|
else
|
|
{
|
|
m_mapResult.insert(strkey, iterPos2.value());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
QString strkey = m_strDate + "~!@" + iterPos1.key() + "~!@" + iterPos2.key();
|
|
if(m_mapResult.contains(strkey))
|
|
{
|
|
m_mapResult[strkey] += 0;
|
|
}
|
|
else
|
|
{
|
|
m_mapResult.insert(strkey, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void YNNMatrixMThread::parseParam()
|
|
{
|
|
userdict = m_mapParam.value("UserDict");
|
|
|
|
m_nArticle = m_mapParam.value("Article").toInt();
|
|
|
|
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
|
|
m_nPeriod = m_mapParam.value("Period").toInt();
|
|
|
|
m_nDateStart = m_mapParam.value("DateStart").toInt();
|
|
m_nDateEnd = m_mapParam.value("DateEnd").toInt();
|
|
|
|
m_bDateAll = true;
|
|
|
|
if(m_mapParam.value("DateALL") == "true")
|
|
m_bDateAll = true;
|
|
else
|
|
m_bDateAll = false;
|
|
|
|
QRegExp re("[\\s,.;]");
|
|
|
|
m_strMKeyword = m_mapParam.value("MatrixKeyword").trimmed().split(re, QString::SkipEmptyParts);
|
|
if(m_mapParam.value("CountMethod") == "Duplicate")
|
|
m_bDuplicate = true;
|
|
else
|
|
m_bDuplicate = false;
|
|
|
|
|
|
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
|
|
|
|
if(m_strRecentPeriod == "None")
|
|
{
|
|
|
|
}
|
|
else if(m_strRecentPeriod == "Days")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Weeks")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate*7));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Months")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addMonths(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Years")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addYears(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void YPlatformOneMThread::parseParam()
|
|
{
|
|
|
|
userdict = m_mapParam.value("UserDict");
|
|
|
|
m_nArticle = m_mapParam.value("Article").toInt();
|
|
|
|
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
|
|
m_nPeriod = m_mapParam.value("Period").toInt();
|
|
|
|
m_nDateStart = m_mapParam.value("DateStart").toInt();
|
|
m_nDateEnd = m_mapParam.value("DateEnd").toInt();
|
|
|
|
m_bDateAll = true;
|
|
|
|
if(m_mapParam.value("DateALL") == "true")
|
|
m_bDateAll = true;
|
|
else
|
|
m_bDateAll = false;
|
|
|
|
m_slMorphereList = m_mapParam.value("MorphereList").split(" ");
|
|
|
|
m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed();
|
|
if(m_mapParam.value("CountMethod") == "Duplicate")
|
|
m_bDuplicate = true;
|
|
else
|
|
m_bDuplicate = false;
|
|
|
|
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
|
|
|
|
if(m_strRecentPeriod == "None")
|
|
{
|
|
|
|
}
|
|
else if(m_strRecentPeriod == "Days")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Weeks")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate*7));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Months")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addMonths(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Years")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addYears(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void YPlatformOneMThread::run()
|
|
{
|
|
typedef mecab_t* (*mecab_new_fun)(int,char**);
|
|
typedef const char* (*mecab_sparse_tostr_fun)(mecab_t *mecab, const char *str);
|
|
typedef void (*mecab_destroy_fun)(mecab_t *mecab);
|
|
|
|
mecab_t *mecab;
|
|
mecab_new_fun mecab_new = (mecab_new_fun)QLibrary::resolve("libmecab.dll","mecab_new");
|
|
mecab_sparse_tostr_fun mecab_sparse_tostr = (mecab_sparse_tostr_fun)QLibrary::resolve("libmecab.dll","mecab_sparse_tostr");
|
|
|
|
parseParam();
|
|
|
|
if(userdict.length() < 1)
|
|
{
|
|
/*
|
|
char *t[] = {"RRR","-d","dic"};
|
|
int int_t = 3;
|
|
*/
|
|
|
|
char a[] = "RRR";
|
|
char b[] = "-d";
|
|
char c[] = "dic";
|
|
char *t[3];
|
|
t[0] = a;
|
|
t[1] = b;
|
|
t[2] = c;
|
|
int int_t = 3;
|
|
|
|
mecab = mecab_new(int_t, t);
|
|
}
|
|
else
|
|
{
|
|
char *cstr = new char[userdict.toStdString().length() + 1];
|
|
strcpy(cstr, userdict.toStdString().c_str());
|
|
/*
|
|
char **t = {"RRR","-d","dic","-u",cstr};
|
|
int int_t = 5;
|
|
*/
|
|
char a[] = "RRR";
|
|
char b[] = "-d";
|
|
char c[] = "dic";
|
|
char d[] = "-u";
|
|
|
|
char *t[5];
|
|
t[0] = a;
|
|
t[1] = b;
|
|
t[2] = c;
|
|
t[3] = d;
|
|
t[4] = cstr;
|
|
int int_t = 5;
|
|
|
|
mecab = mecab_new(int_t, t);
|
|
delete[] cstr;
|
|
}
|
|
mecab_destroy_fun mecab_destroy = (mecab_destroy_fun)QLibrary::resolve("libmecab.dll","mecab_destroy");
|
|
|
|
|
|
|
|
//qDebug() << num;
|
|
|
|
int nDate = 0;
|
|
while(true)
|
|
{
|
|
QString strTitle;
|
|
QString strBody;
|
|
QString strDate;
|
|
QString strData;
|
|
QString strPlatformTitle;
|
|
QString strArticle;
|
|
QString strPlatformName;
|
|
QString strPlatformForm;
|
|
{
|
|
mutex->lock();
|
|
if(!m_pDAInterface->hasNext())
|
|
{
|
|
mutex->unlock();
|
|
break;
|
|
}
|
|
strTitle = m_pDAInterface->getArticleTitle();
|
|
strDate = m_pDAInterface->getArticleDate();
|
|
strPlatformTitle = m_pDAInterface->getPlatformTitle();
|
|
strBody = m_pDAInterface->getArticleData();
|
|
strArticle = m_pDAInterface->getArticleForm();
|
|
strPlatformName = m_pDAInterface->getPlatformName().trimmed();
|
|
strPlatformForm = m_pDAInterface->getPlatformForm().trimmed();
|
|
|
|
m_pDAInterface->next();
|
|
mutex->unlock();
|
|
}
|
|
|
|
|
|
bool bContinue = true;
|
|
{
|
|
switch(m_nArticle)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
{
|
|
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!bContinue)
|
|
continue;
|
|
|
|
if(strPlatformForm.trimmed().isEmpty())
|
|
continue;
|
|
|
|
if(strPlatformName.trimmed().isEmpty())
|
|
continue;
|
|
|
|
|
|
{
|
|
switch(m_nTitleBody)
|
|
{
|
|
case 0:
|
|
{
|
|
strData = strTitle;
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
strData = strBody;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
strData = strTitle + "\n" + strBody;
|
|
break;
|
|
}
|
|
case 3:
|
|
strData = strPlatformTitle;
|
|
break;
|
|
}
|
|
strTitle.clear();
|
|
strBody.clear();
|
|
strPlatformTitle.clear();
|
|
}
|
|
|
|
//if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive))
|
|
if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive))
|
|
continue;
|
|
|
|
if(strDate.length() < 11)
|
|
continue;
|
|
|
|
strDate = strDate.left(11);
|
|
if(strDate.trimmed().length()<10)
|
|
{
|
|
nDate = 0;
|
|
}
|
|
else
|
|
{
|
|
strDate = strDate.replace("-","").trimmed();
|
|
if(strDate.length() < 8)
|
|
{
|
|
nDate = 0;
|
|
}
|
|
else
|
|
nDate = strDate.toInt();
|
|
}
|
|
|
|
if(!m_bDateAll)
|
|
{
|
|
if(nDate < m_nDateStart || m_nDateEnd < nDate)
|
|
continue;
|
|
}
|
|
|
|
QString m_strDate;
|
|
QString m_strKeyword;
|
|
QString m_strMorphere;
|
|
|
|
switch(m_nPeriod)
|
|
{
|
|
case 0:
|
|
{
|
|
m_strDate = "ALL";
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
m_strDate = "D" + QString::number(nDate);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
/*
|
|
QDate tempdate = QDate(nDate/10000, (nDate%10000)/100, nDate%100);
|
|
mapkey.strDate = "W" + QString::number(nDate/10000);
|
|
if(tempdate.weekNumber() < 10)
|
|
mapkey.strDate += "0";
|
|
mapkey.strDate += QString::number(tempdate.weekNumber());
|
|
*/
|
|
m_strDate = getWeeksInMonth(nDate);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
m_strDate = "M";
|
|
if((nDate/100) < 10)
|
|
m_strDate += "0";
|
|
m_strDate += QString::number(nDate/100);
|
|
break;
|
|
}
|
|
}
|
|
|
|
QString strAnalyzedLine = QString::fromStdString(mecab_sparse_tostr(mecab, strData.toStdString().c_str())) + "\n";
|
|
QStringList strListAll = strAnalyzedLine.split("\n",QString::SkipEmptyParts);
|
|
QMap<QString, int> mapResult;
|
|
|
|
foreach(QString strLine, strListAll)
|
|
{
|
|
QStringList strListLine = strLine.split("\t");
|
|
if(strListLine.size() < 2)
|
|
continue;
|
|
QStringList strpumsa = strListLine.at(1).trimmed().split(",");
|
|
foreach(QString strMorphere, m_slMorphereList)
|
|
{
|
|
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
|
{
|
|
m_strKeyword = strListLine.at(0).toLower();
|
|
m_strMorphere = strMorphere;
|
|
QString strkey = m_strDate + "~!@" + strPlatformName + "~!@" + strPlatformForm + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
|
if(mapResult.contains(strkey))
|
|
{
|
|
(mapResult)[strkey]++;
|
|
}
|
|
|
|
else
|
|
{
|
|
mapResult.insert(strkey,1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!m_bDuplicate)
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
mapResult[iterPos.key()] = 1;
|
|
}
|
|
}
|
|
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
if(m_mapResult.contains(iterPos.key()))
|
|
{
|
|
m_mapResult[iterPos.key()] += iterPos.value();
|
|
}
|
|
else
|
|
{
|
|
m_mapResult.insert(iterPos.key(), iterPos.value());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//if(m_bDateAll)
|
|
|
|
//qDebug() << num << " : " << strData;
|
|
}
|
|
|
|
mecab_destroy(mecab);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void YPlatformMThread::parseParam()
|
|
{
|
|
userdict = m_mapParam.value("UserDict");
|
|
|
|
m_nArticle = m_mapParam.value("Article").toInt();
|
|
|
|
m_nTitleBody = m_mapParam.value("TitleBody").toInt();
|
|
m_nPeriod = m_mapParam.value("Period").toInt();
|
|
|
|
m_nDateStart = m_mapParam.value("DateStart").toInt();
|
|
m_nDateEnd = m_mapParam.value("DateEnd").toInt();
|
|
|
|
m_bDateAll = true;
|
|
|
|
if(m_mapParam.value("DateALL") == "true")
|
|
m_bDateAll = true;
|
|
else
|
|
m_bDateAll = false;
|
|
|
|
m_slMorphereList = m_mapParam.value("MorphereList").split(" ");
|
|
|
|
m_strCKeyword = m_mapParam.value("CenterKeyword").trimmed();
|
|
|
|
m_slOneDepthKeys = m_mapParam.value("OneDepthKeys").split(" ");
|
|
if(m_mapParam.value("CountMethod") == "Duplicate")
|
|
m_bDuplicate = true;
|
|
else
|
|
m_bDuplicate = false;
|
|
|
|
|
|
m_strRecentPeriod = m_mapParam.value("RecentPeriod").trimmed();
|
|
|
|
if(m_strRecentPeriod == "None")
|
|
{
|
|
|
|
}
|
|
else if(m_strRecentPeriod == "Days")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Weeks")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addDays(-(nDate*7));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Months")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addMonths(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
else if(m_strRecentPeriod == "Years")
|
|
{
|
|
int nDate = m_mapParam.value("RecentDate").trimmed().toInt();
|
|
QDateTime today = QDateTime::currentDateTime();
|
|
QDateTime startday = today.addYears(-(nDate));
|
|
startday = startday.addDays(1);
|
|
m_nDateStart = startday.toString("yyyyMMdd").trimmed().toInt();
|
|
m_nDateEnd = today.toString("yyyyMMdd").trimmed().toInt();
|
|
m_bDateAll = false;
|
|
}
|
|
|
|
}
|
|
|
|
void YPlatformMThread::run()
|
|
{
|
|
typedef mecab_t* (*mecab_new_fun)(int,char**);
|
|
typedef const char* (*mecab_sparse_tostr_fun)(mecab_t *mecab, const char *str);
|
|
typedef void (*mecab_destroy_fun)(mecab_t *mecab);
|
|
|
|
mecab_t *mecab;
|
|
mecab_new_fun mecab_new = (mecab_new_fun)QLibrary::resolve("libmecab.dll","mecab_new");
|
|
mecab_sparse_tostr_fun mecab_sparse_tostr = (mecab_sparse_tostr_fun)QLibrary::resolve("libmecab.dll","mecab_sparse_tostr");
|
|
|
|
parseParam();
|
|
|
|
if(userdict.length() < 1)
|
|
{
|
|
/*
|
|
char *t[] = {"RRR","-d","dic"};
|
|
int int_t = 3;
|
|
*/
|
|
|
|
char a[] = "RRR";
|
|
char b[] = "-d";
|
|
char c[] = "dic";
|
|
char *t[3];
|
|
t[0] = a;
|
|
t[1] = b;
|
|
t[2] = c;
|
|
int int_t = 3;
|
|
|
|
mecab = mecab_new(int_t, t);
|
|
}
|
|
else
|
|
{
|
|
char *cstr = new char[userdict.toStdString().length() + 1];
|
|
strcpy(cstr, userdict.toStdString().c_str());
|
|
/*
|
|
char **t = {"RRR","-d","dic","-u",cstr};
|
|
int int_t = 5;
|
|
*/
|
|
char a[] = "RRR";
|
|
char b[] = "-d";
|
|
char c[] = "dic";
|
|
char d[] = "-u";
|
|
|
|
char *t[5];
|
|
t[0] = a;
|
|
t[1] = b;
|
|
t[2] = c;
|
|
t[3] = d;
|
|
t[4] = cstr;
|
|
int int_t = 5;
|
|
|
|
mecab = mecab_new(int_t, t);
|
|
delete[] cstr;
|
|
}
|
|
mecab_destroy_fun mecab_destroy = (mecab_destroy_fun)QLibrary::resolve("libmecab.dll","mecab_destroy");
|
|
|
|
|
|
|
|
//qDebug() << num;
|
|
|
|
int nDate = 0;
|
|
while(true)
|
|
{
|
|
QString strTitle;
|
|
QString strBody;
|
|
QString strDate;
|
|
QString strData;
|
|
QString strPlatformTitle;
|
|
QString strArticle;
|
|
QString strPlatformName;
|
|
QString strPlatformForm;
|
|
{
|
|
mutex->lock();
|
|
if(!m_pDAInterface->hasNext())
|
|
{
|
|
mutex->unlock();
|
|
break;
|
|
}
|
|
strTitle = m_pDAInterface->getArticleTitle();
|
|
strDate = m_pDAInterface->getArticleDate();
|
|
strPlatformTitle = m_pDAInterface->getPlatformTitle();
|
|
strBody = m_pDAInterface->getArticleData();
|
|
strArticle = m_pDAInterface->getArticleForm();
|
|
strPlatformName = m_pDAInterface->getPlatformName().trimmed();
|
|
strPlatformForm = m_pDAInterface->getPlatformForm().trimmed();
|
|
|
|
m_pDAInterface->next();
|
|
mutex->unlock();
|
|
}
|
|
|
|
bool bContinue = true;
|
|
{
|
|
switch(m_nArticle)
|
|
{
|
|
case 0:
|
|
break;
|
|
case 1:
|
|
{
|
|
if(strArticle.trimmed().compare("reply", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
if(strArticle.trimmed().compare("body", Qt::CaseInsensitive) == 0)
|
|
bContinue = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!bContinue)
|
|
continue;
|
|
|
|
|
|
if(strPlatformForm.trimmed().isEmpty())
|
|
continue;
|
|
|
|
if(strPlatformName.trimmed().isEmpty())
|
|
continue;
|
|
|
|
|
|
|
|
|
|
{
|
|
switch(m_nTitleBody)
|
|
{
|
|
case 0:
|
|
{
|
|
strData = strTitle;
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
strData = strBody;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
strData = strTitle + "\n" + strBody;
|
|
break;
|
|
}
|
|
case 3:
|
|
strData = strPlatformTitle;
|
|
break;
|
|
}
|
|
strTitle.clear();
|
|
strBody.clear();
|
|
strPlatformTitle.clear();
|
|
}
|
|
|
|
//if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive))
|
|
if(!strData.contains(m_strCKeyword, Qt::CaseInsensitive))
|
|
continue;
|
|
|
|
if(strDate.length() < 11)
|
|
continue;
|
|
|
|
strDate = strDate.left(11);
|
|
if(strDate.trimmed().length()<10)
|
|
{
|
|
nDate = 0;
|
|
}
|
|
else
|
|
{
|
|
strDate = strDate.replace("-","").trimmed();
|
|
if(strDate.length() < 8)
|
|
{
|
|
nDate = 0;
|
|
}
|
|
else
|
|
nDate = strDate.toInt();
|
|
}
|
|
|
|
if(!m_bDateAll)
|
|
{
|
|
if(nDate < m_nDateStart || m_nDateEnd < nDate)
|
|
continue;
|
|
}
|
|
|
|
QString m_strDate;
|
|
QString m_strKeyword;
|
|
QString m_strMorphere;
|
|
|
|
switch(m_nPeriod)
|
|
{
|
|
case 0:
|
|
{
|
|
m_strDate = "ALL";
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
m_strDate = "D" + QString::number(nDate);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
/*
|
|
QDate tempdate = QDate(nDate/10000, (nDate%10000)/100, nDate%100);
|
|
mapkey.strDate = "W" + QString::number(nDate/10000);
|
|
if(tempdate.weekNumber() < 10)
|
|
mapkey.strDate += "0";
|
|
mapkey.strDate += QString::number(tempdate.weekNumber());
|
|
*/
|
|
m_strDate = getWeeksInMonth(nDate);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
m_strDate = "M";
|
|
if((nDate/100) < 10)
|
|
m_strDate += "0";
|
|
m_strDate += QString::number(nDate/100);
|
|
break;
|
|
}
|
|
}
|
|
|
|
QString strAnalyzedLine = QString::fromStdString(mecab_sparse_tostr(mecab, strData.toStdString().c_str())) + "\n";
|
|
QStringList strListAll = strAnalyzedLine.split("\n",QString::SkipEmptyParts);
|
|
|
|
QMap<QString, int> mapResult;
|
|
|
|
foreach(QString strLine, strListAll)
|
|
{
|
|
QStringList strListLine = strLine.split("\t");
|
|
if(strListLine.size() < 2)
|
|
continue;
|
|
QStringList strpumsa = strListLine.at(1).trimmed().split(",");
|
|
foreach(QString strMorphere, m_slMorphereList)
|
|
{
|
|
if(strpumsa.at(0).trimmed().contains(strMorphere,Qt::CaseInsensitive))
|
|
{
|
|
m_strKeyword = strListLine.at(0).toLower();
|
|
m_strMorphere = strMorphere;
|
|
QString strkey = m_strDate + "~!@" + strPlatformName + "~!@" + strPlatformForm + "~!@" + m_strMorphere + "~!@" + m_strKeyword;
|
|
if(mapResult.contains(strkey))
|
|
{
|
|
(mapResult)[strkey]++;
|
|
}
|
|
|
|
else
|
|
{
|
|
mapResult.insert(strkey,1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!m_bDuplicate)
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
mapResult[iterPos.key()] = 1;
|
|
}
|
|
}
|
|
|
|
|
|
foreach(QString str, m_slOneDepthKeys)
|
|
{
|
|
//qDebug() << "str :" << str;
|
|
if(mapResult.contains(str))
|
|
{
|
|
for(QMap<QString, int>::iterator iterPos = mapResult.begin(); iterPos != mapResult.end(); iterPos++)
|
|
{
|
|
if(iterPos.key() == str)
|
|
continue;
|
|
QString key = iterPos.key();
|
|
QStringList slkey = key.split("~!@", QString::SkipEmptyParts);
|
|
int nLength = slkey.length();
|
|
QString strkey = str + "~!@" + slkey.at(nLength - 2) + "~!@" + slkey.at(nLength - 1);
|
|
if(m_mapResult.contains(strkey))
|
|
{
|
|
m_mapResult[strkey] += iterPos.value();
|
|
//qDebug() << strkey;
|
|
}
|
|
else
|
|
{
|
|
m_mapResult.insert(strkey, iterPos.value());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
mecab_destroy(mecab);
|
|
}
|