|
| 1 | +#include "clusterusers.h" |
| 2 | +#include "ui_clusterusers.h" |
| 3 | +#include <QDebug> |
| 4 | +#include <QFile> |
| 5 | +#include <QTextStream> |
| 6 | +#include <QListWidget> |
| 7 | +#include <QListWidgetItem> |
| 8 | + |
| 9 | +clusterusers::clusterusers(QWidget *parent) : |
| 10 | + QWidget(parent), |
| 11 | + ui(new Ui::clusterusers) |
| 12 | +{ |
| 13 | + ui->setupUi(this); |
| 14 | + proc=new QProcess(); |
| 15 | + showproc=new QProcess(); |
| 16 | + connect(ui->next,SIGNAL(clicked()),this,SLOT(movenext())); |
| 17 | + connect(ui->back,SIGNAL(clicked()),this,SLOT(moveback())); |
| 18 | + connect(ui->clusteruser,SIGNAL(clicked()),this,SLOT(clusterclick())); |
| 19 | + connect(ui->show,SIGNAL(clicked()),this,SLOT(showclick())); |
| 20 | + connect(proc,SIGNAL(finished(int)),this,SLOT(clusterended())); |
| 21 | + connect(showproc,SIGNAL(finished(int)),this,SLOT(showprocended())); |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + QFile file("/home/rakesh/Qt/Reco/python/db.txt"); |
| 27 | + file.open(QIODevice::ReadOnly | QIODevice::Text); |
| 28 | + |
| 29 | + QString path; |
| 30 | + |
| 31 | + QTextStream in1(&file); |
| 32 | + path= in1.readLine(); |
| 33 | + path=path+"/movielens_1m_userlist.json"; |
| 34 | + qDebug()<<path; |
| 35 | + QFile fileopen(path); |
| 36 | + fileopen.open(QIODevice::ReadOnly | QIODevice::Text); |
| 37 | + QTextStream in(&fileopen); |
| 38 | + ui->userid->clear(); |
| 39 | + while(!in.atEnd()) { |
| 40 | + QString item = in.readLine(); |
| 41 | + ui->userid->addItem(item); |
| 42 | + qDebug()<<item; |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +} |
| 47 | +} |
| 48 | + |
| 49 | +clusterusers::~clusterusers() |
| 50 | +{ |
| 51 | + delete ui; |
| 52 | +} |
| 53 | + |
| 54 | +void clusterusers::movenext() |
| 55 | +{ |
| 56 | + |
| 57 | + emit movetorecommend(); |
| 58 | +} |
| 59 | + |
| 60 | +void clusterusers::moveback() |
| 61 | +{ |
| 62 | + emit movebacktocommputesimilarity(); |
| 63 | +} |
| 64 | + |
| 65 | +void clusterusers::clusterclick() |
| 66 | +{ |
| 67 | + |
| 68 | + QFile file("/home/rakesh/Qt/Reco/python/db.txt"); |
| 69 | + file.open(QIODevice::ReadOnly | QIODevice::Text); |
| 70 | + |
| 71 | + QString path; |
| 72 | + QTextStream in(&file); |
| 73 | + path= in.readLine(); |
| 74 | + |
| 75 | + |
| 76 | + QFile file1("/home/rakesh/Qt/Reco/filename.txt"); |
| 77 | + file1.open(QIODevice::ReadOnly | QIODevice::Text); |
| 78 | + QTextStream in1(&file1); |
| 79 | + |
| 80 | + QString item = in1.readLine(); |
| 81 | + |
| 82 | + |
| 83 | + path="python "+path+"/6_clusterUsers.py "+item; |
| 84 | + qDebug()<<path; |
| 85 | + proc->start(path); |
| 86 | + |
| 87 | + ui->status_scrollarea->setWidget(new QLabel("running...")); |
| 88 | + |
| 89 | + |
| 90 | +} |
| 91 | + |
| 92 | +void clusterusers::showclick() |
| 93 | +{ |
| 94 | + QFile file("/home/rakesh/Qt/Reco/python/db.txt"); |
| 95 | + file.open(QIODevice::ReadOnly | QIODevice::Text); |
| 96 | + |
| 97 | + QString path; |
| 98 | + QTextStream in(&file); |
| 99 | + path= in.readLine(); |
| 100 | + |
| 101 | + |
| 102 | + QFile file1("/home/rakesh/Qt/Reco/filename.txt"); |
| 103 | + file1.open(QIODevice::ReadOnly | QIODevice::Text); |
| 104 | + QTextStream in1(&file1); |
| 105 | + |
| 106 | + QString item = in1.readLine(); |
| 107 | + |
| 108 | + |
| 109 | + path="python "+path+"/6_userCluster.py "+item+" "+ui->userid->currentText(); |
| 110 | + qDebug()<<path; |
| 111 | + showproc->start(path); |
| 112 | + |
| 113 | + ui->status_scrollarea->setWidget(new QLabel("running...")); |
| 114 | +} |
| 115 | + |
| 116 | +void clusterusers::showprocended() |
| 117 | +{ |
| 118 | + ui->status_scrollarea->setWidget(new QLabel("ended")); |
| 119 | + QFile file("/home/rakesh/Qt/Reco/python/db.txt"); |
| 120 | + file.open(QIODevice::ReadOnly | QIODevice::Text); |
| 121 | + |
| 122 | + QString path; |
| 123 | + |
| 124 | + QTextStream in1(&file); |
| 125 | + path= in1.readLine(); |
| 126 | + path=path+"/movielens_1m_userClusters.json"; |
| 127 | + qDebug()<<path; |
| 128 | + QFile fileopen(path); |
| 129 | + fileopen.open(QIODevice::ReadOnly | QIODevice::Text); |
| 130 | + QTextStream in(&fileopen); |
| 131 | + QListWidget *list=new QListWidget(); |
| 132 | + ui->scrollArea->setWidget(list); |
| 133 | + while(!in.atEnd()) { |
| 134 | + QString item = in.readLine(); |
| 135 | + QListWidgetItem *t=new QListWidgetItem(item,list); |
| 136 | + |
| 137 | + qDebug()<<item; |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + } |
| 142 | + |
| 143 | + |
| 144 | +} |
| 145 | + |
| 146 | +void clusterusers::clusterended() |
| 147 | +{ |
| 148 | + ui->status_scrollarea->setWidget(new QLabel("completed...press show to display image")); |
| 149 | +} |
0 commit comments