Beispiel #1
0
std::map<std::string, size_t> Server::conjecture (
    const std::string & diverge_out,
    const std::string & equal_out,
    size_t max_count)
{
    POMAGMA_ASSERT_LT(0, max_count);
    crop();

    std::vector<float> probs;
    std::vector<std::string> routes;
    auto language = load_language(m_language_file);
    {
        Router router(m_structure.signature(), language);
        probs = router.measure_probs();
        routes = router.find_routes();
    }

    std::map<std::string, size_t> counts;
    counts["diverge"] = pomagma::conjecture_diverge(
        m_structure,
        probs,
        routes,
        diverge_out.c_str());
    counts["equal"] = pomagma::conjecture_equal(
        m_structure,
        probs,
        routes,
        equal_out.c_str(),
        max_count);

    return counts;
}
Beispiel #2
0
void
gsview_language(int new_language)
{
    if (load_language(new_language)) {
        check_menu_item(IDM_LANGMENU, option.language, FALSE);
        option.language = new_language;
        check_menu_item(IDM_LANGMENU, option.language, TRUE);
        change_language();
    }
}
Beispiel #3
0
void StringsEditor::on_languageSelector_comboBox_currentTextChanged(const QString &arg1)
{
    if (data_loading) { return; }
    save_data();
    current_lang = arg1.toStdString();
    data_loading = true;
    std::string path_new = FILEPATH + std::string("/lang/strings_ingame_") + arg1.toStdString() + std::string(".dat");
    load_language(path_new);
    fill_translation();
    data_loading = false;
}
Beispiel #4
0
void StringsEditor::on_addLanguage_pushButton_clicked()
{
    data_loading = true;
    std::string path_old = FILEPATH + std::string("/strings_ingame_v4.dat");
    std::string path_new = FILEPATH + std::string("/lang/strings_ingame_") + ui->languageName_lineEdit->text().toStdString() + std::string(".dat");
    QFile::copy(path_old.c_str(), path_new.c_str());
    load_language(path_new);
    ui->languageSelector_comboBox->addItem(ui->languageName_lineEdit->text().toStdString().c_str());
    ui->languageSelector_comboBox->setEnabled(true);
    data_loading = false;
}
Beispiel #5
0
size_t conjecture_diverge(Structure& structure, const char* language_file,
                          const char* conjectures_file) {
    std::vector<float> probs;
    std::vector<std::string> routes;
    auto language = load_language(language_file);
    {
        Router router(structure.signature(), language);
        probs = router.measure_probs();
        routes = router.find_routes();
    }

    return conjecture_diverge(structure, probs, routes, conjectures_file);
}
Beispiel #6
0
Server::Server (
        const char * structure_file,
        const char * language_file)
    : m_structure(structure_file),
      m_approximator(m_structure),
      m_probs(),
      m_routes(),
      m_simplifier(m_structure.signature(), m_routes)
{
    if (POMAGMA_DEBUG_LEVEL > 1) {
        m_structure.validate();
    }

    auto language = load_language(language_file);
    Router router(m_structure.signature(), language);
    m_probs = router.measure_probs();
    m_routes = router.find_routes();
}
Beispiel #7
0
Server::Server(const char* structure_file, const char* language_file)
    : m_language(load_language(language_file)),
      m_structure(structure_file),
      m_return(m_structure.carrier()),
      m_nreturn(m_structure.carrier()),
      m_dense_set_store(m_structure.carrier().item_dim()),
      m_worker_pool(),
      m_intervals_approximator(m_structure, m_dense_set_store, m_worker_pool),
      m_approximator(m_structure),
      m_approximate_parser(m_approximator),
      m_probs(),
      m_routes(),
      m_simplifier(m_structure.signature(), m_routes, m_error_log),
      m_corpus(m_structure.signature()),
      m_validator(m_approximator),
      m_parser(),
      m_virtual_machine() {
    // parser and virtual_machine must be loaded after RETURN is delclared.
    Signature& signature = m_structure.signature();
    POMAGMA_ASSERT(not signature.unary_relation("RETURN"),
                   "reserved name RETURN is defined in loaded structure");
    POMAGMA_ASSERT(not signature.unary_relation("NRETURN"),
                   "reserved name NRETURN is defined in loaded structure");
    signature.declare("RETURN", m_return);
    signature.declare("NRETURN", m_nreturn);
    m_parser.load(signature);
    m_virtual_machine.load(signature);

    if (POMAGMA_DEBUG_LEVEL > 1) {
        m_structure.validate();
    }

    Router router(m_structure.signature(), m_language);
    m_probs = router.measure_probs();
    m_routes = router.find_routes();
}
Beispiel #8
0
StringsEditor::StringsEditor(QWidget *parent, bool pick_mode) : QDialog(parent), ui(new Ui::StringsEditor), string_edit_model(this), target_qline(NULL), target_property(NULL)
{
    pick_mode_enabled = pick_mode;
    string_list = fio_str.load_game_strings();
    ui->setupUi(this);

    data_loading = true;


    // ==================== GAME STRINGS ==================== //
    fill_data();

    QObject::connect(&signal_mapper, SIGNAL(mapped(const int &)), this, SLOT(on_text_changed(const int &)));

    for (int i=0; i<string_list.size(); i++) {
        QLabel* line_text = new QLabel();
        line_text->setText(QString(string_list.at(i).c_str()));
        ui->tabGame_gridLayout->addWidget(line_text, i, 0);

        QLineEdit* line_editor = new QLineEdit();
        editor_line_list.push_back(line_editor);
        line_editor->setEnabled(false);
        ui->tabGame_gridLayout->addWidget(line_editor, i, 1);
        signal_mapper.setMapping(line_editor, i);
        QObject::connect(line_editor, SIGNAL(textChanged(QString)), &signal_mapper, SLOT(map()));
    }

    if (ui->languageSelector_comboBox->count() > 0) {
        current_lang = ui->languageSelector_comboBox->currentText().toStdString();
        std::string path_new = FILEPATH + std::string("/lang/strings_ingame_") + current_lang + std::string(".dat");
        load_language(path_new);
    }

    // ==================== COMMON STRINGS ==================== //

    std::vector<std::string> common_string_list = fio_str.get_common_strings();
    /*
    common_string_list.push_back(CURRENT_FILE_FORMAT::st_file_common_string("NOME #1", "VALOR #1"));
    common_string_list.push_back(CURRENT_FILE_FORMAT::st_file_common_string("NOME #2", "VALOR #2"));
    common_string_list.push_back(CURRENT_FILE_FORMAT::st_file_common_string("NOME #3", "VALOR #3"));
    */

    string_edit_model.set_data(common_string_list);
    string_edit_model.set_pick_mode(pick_mode_enabled);
    ui->commonStrings_tableView->setModel(&string_edit_model);

#if QT_VERSION >= 0x050000
    ui->commonStrings_tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); // Qt5
#else
    ui->commonStrings_tableView->horizontalHeader()->setStretchLastSection(true); // Qt4
#endif


    data_loading = false;

    if (pick_mode_enabled == true) {
        ui->tabWidget->setTabEnabled(0, false);
        ui->addLanguage_pushButton->setVisible(false);
        ui->languageName_lineEdit->setVisible(false);
        ui->addCommonString_pushButton->setVisible(false);
        ui->tabWidget->setCurrentIndex(1);
    }
}