Esempio n. 1
0
File: sally.c Progetto: yangke/sally
/**
 * Init the Sally tool
 * @param argc number of arguments
 * @param argv arguments
 */
static void sally_init()
{
    int ehash;
    const char *cfg_str;

    if (verbose > 1)
        config_print(&cfg);

    /* Set delimiters */
    config_lookup_string(&cfg, "features.ngram_delim", &cfg_str);
    if (strlen(cfg_str) > 0) 
        fvec_delim_set(cfg_str);

    /* Check for TFIDF weighting */
    config_lookup_string(&cfg, "features.vect_embed", &cfg_str);
    if (!strcasecmp(cfg_str, "tfidf"))
        idf_create(input);

    /* Load stop words */
    config_lookup_string(&cfg, "input.stopword_file", &cfg_str);
    if (strlen(cfg_str) > 0)
        stopwords_load(cfg_str);

    /* Check for feature hash table */
    config_lookup_int(&cfg, "features.explicit_hash", &ehash);
    config_lookup_string(&cfg, "features.hash_file", &cfg_str);
    if (ehash || strlen(cfg_str) > 0) {
        info_msg(1, "Enabling feature hash table.");
        fhash_init();
    }

    /* Open input */
    config_lookup_string(&cfg, "input.input_format", &cfg_str);
    input_config(cfg_str);
    info_msg(1, "Opening '%0.40s' with input module '%s'.", input, cfg_str);
    entries = input_open(input);
    if (entries < 0)
        fatal("Could not open input source");

    /* Open output */
    config_lookup_string(&cfg, "output.output_format", &cfg_str);
    output_config(cfg_str);
    info_msg(1, "Opening '%0.40s' with output module '%s'.", output, cfg_str);
    if (!output_open(output))
        fatal("Could not open output destination");
}
Esempio n. 2
0
/**
 * Main function
 */
int main(int argc, char **argv)
{
    int err = FALSE;

    /* Create config */
    config_init(&cfg);
    config_check(&cfg);

    fhash_init();

    err |= test_sorted_ngrams();
    err |= test_blended_ngrams();
    err |= test_pos_ngrams();

    fhash_destroy();

    config_destroy(&cfg);
    return err;
}