Exemplo n.º 1
0
static int read_conllx(FILE* fp)
{
    int num_sent = 0;
    unsigned int line_num = 0;
    char buff[BUF_SIZE];
    const char* sep = "\t";
    char *t, *line, *tofree;
    size_t len;

    const char** seq = xmalloc(sizeof(char *) * CONLLX_TOKEN_NUM_FIELDS);
    struct blocks* blocks = new_blocks(256);
    struct sentence* sent = sentence_new();

    while (fgets(buff, sizeof(buff), fp)) {
        line_num++;
        if (buff[0] == '\n') {
            latex_print_dep_tree(sent);
            sentence_destroy(sent);
            sent = sentence_new();
            num_sent++;
            continue;
        }
        len = strnlen(buff, BUF_SIZE);
        tofree = line = strndup(buff, len-1);
        blocks_add_elem(blocks, tofree);

        int i = 0;
        while ((t = strsep(&line, sep)) != NULL) {
            seq[i] = t;
            i++;
        }
        sentence_add_token(sent, token_new(seq, CONLLX_TOKEN_NUM_FIELDS));
    }
    destroy_blocks(blocks);
    sentence_destroy(sent);
    free(seq);
    fprintf(stderr, "INFO: Number of sentences = %d\n", num_sent);

    return 0;
}
Exemplo n.º 2
0
struct big_bdescr* new_big_blocks(struct s_arena* arena, unsigned int count){
	void* new_block = new_blocks(arena,count);
	debug("new big block at %08x\n",(unsigned int)new_block);
	init_big_block(new_block,count);
	return (struct big_bdescr*)new_block;
}
Exemplo n.º 3
0
struct single_bdescr* new_single_block(struct s_arena* arena){
	struct single_bdescr* new_block = new_blocks(arena,1);
	init_single_block(new_block);
	debug("new single block at %08x\n",(unsigned int)new_block);
	return new_block;
}