예제 #1
0
void MainWindow::selectedModelChanged()
{
    ui->cbAddToModel->clear();
    QString currentModel = ui->lwModelsList->currentItem()->text();
    if(currentModel == "types_of_sentence")
    {
        ui->lineEditTextToPredict->setText("How is it going?");
        ui->textEditDescription->setHtml("This model is to predict if the sentence is <b>Interrogative</b>, <b>Declarative</b> or <b>Exclamation</b>. <br>Enter the sentence in English, and click <b>Predict</b> button.");
        QStringList lst;
        lst << "Interrogative" << "Declarative" << "Exclamation";
        ui->cbAddToModel->addItems(lst);
    }
    else if(currentModel == "lang_identifier")
    {
        ui->lineEditTextToPredict->setText(QString::fromUtf8("En efeto, rematado ya su juicio, vino a dar en el más estraño."));
        ui->textEditDescription->setHtml("This model is to predict if the sentence is in <b>English</b>, <b>Spanish</b> or <b>French</b>. <br>Enter the sentence in any of those languages, and click <b>Predict</b> button.");
        QStringList lst;
        lst << "English" << "French" << "Spanish";
        ui->cbAddToModel->addItems(lst);
    }
    else if(currentModel == "lang_id_russian")
    {
        ui->lineEditTextToPredict->setText(QString::fromUtf8("Добрый вечер, дорогие друзья!"));
        ui->textEditDescription->setHtml("This model is to predict if the sentence is in <b>English</b>, <b>Spanish</b>, <b>French</b> or <b>Russian</b>. <br>Enter the sentence in any of those languages, and click <b>Predict</b> button.");
        QStringList lst;
        lst << "English" << "French" << "Spanish" << "Russian";
        ui->cbAddToModel->addItems(lst);
    }
    else if(currentModel == "moscow_weather")
    {
        ui->lineEditTextToPredict->setText("240, Summer");
        ui->textEditDescription->setHtml("This model is to predict the temperature in <b>Moscow</b> in centigrade. <br>Enter the day of year and the season:<br> <b>240</b>, <b>Summer</b>");
    }
    else if(currentModel == "potential_buyers")
    {
        ui->lineEditTextToPredict->setText("43, m, flat, 1, married, 6");
        ui->textEditDescription->setHtml("This model is to predict if the customer will buy a bike. <br>Enter the following string for prediction:<br> <b>age, sex(m or f), house type (flat or house), number of cars, marital status (married or single), number of children</b>.");
        QStringList lst;
        lst << "yes" << "no";
        ui->cbAddToModel->addItems(lst);
    }
    else
    {
        ui->lineEditTextToPredict->setText("");
        ui->textEditDescription->setHtml("");
    }

    ui->lwPredictResult->clear();
    ui->lPredictResult->setText("unknown");


    updateModelInfo();
}
예제 #2
0
void CoreModel::registerModel(Model *model)
{
    auto assertWhere = QString("Registering new model \"%1\"").arg(model->fullName()).toLocal8Bit();
    auto assertWhat = QByteArray("Model with the same name already exists");

    Q_ASSERT_X(!mRegisteredModels.contains(model->fullName()), assertWhere.data(), assertWhat.data());

    mRegisteredModels[model->fullName()] = model;

    auto createQueries = model->createQueries();
    foreach (auto query, createQueries)
        mBotInterface->executeDatabaseQuery(query);

    if (model->section() != "config")
        updateModelInfo(model);
}
예제 #3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    m_pOAuth2 = new OAuth2(this);
    m_API_key = m_pOAuth2->getSimpleAPIKey();

    connect(m_pOAuth2, SIGNAL(loginDone()), this, SLOT(loginDone()));


    m_managerPrediction.setAPIKey(m_API_key);

    connect(&m_managerPrediction, SIGNAL(replyText(QString)), this, SLOT(addReplyText(QString)));
    connect(&m_managerPrediction, SIGNAL(recvModelsList(QVariantList)), this, SLOT(recvModelsList(QVariantList)));
    connect(&m_managerPrediction, SIGNAL(recvModelDescription(QVariant)), this, SLOT(recvModelDescription(QVariant)));
    connect(&m_managerPrediction, SIGNAL(recvPredictionResult(QVariant)), this, SLOT(recvPredictionResult(QVariant)));
    connect(&m_managerPrediction, SIGNAL(recvAddToModelComplete(bool)), this, SLOT(recvAddToModelComplete(bool)));

    connect(ui->lwModelsList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedModelChanged()));

    connect(ui->actionDeleteModel, SIGNAL(triggered()), this, SLOT(deleteModel()));
    connect(ui->actionNewModel, SIGNAL(triggered()), this, SLOT(newModel()));
    connect(ui->actionUpdateModelsList, SIGNAL(triggered()), this, SLOT(updateModelsList()));
    connect(ui->actionUpdateModelInfo, SIGNAL(triggered()), this, SLOT(updateModelInfo()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->predictButton, SIGNAL(clicked()), this, SLOT(predict()));


    connect(ui->lineEditTextToPredict, SIGNAL(returnPressed()), this, SLOT(predict()));
    connect(ui->actionLogin, SIGNAL(triggered()), this, SLOT(login()));

    connect(&timerTest, SIGNAL(timeout()), this, SLOT(testSendRequest()));

    startLogin(false);
}