コード例 #1
0
ファイル: extract-links.c プロジェクト: lagleki/jorne
/**
 * Generate the list of all links of the index'th parsing of the
 * sentence.  For this to work, you must have already called parse, and
 * already built the whole_set.
 */
void extract_links(Linkage lkg, Parse_info pi)
{
    int index = lkg->lifo.index;
    if (index < 0) {
        pi->rand_state = index;
        list_random_links(lkg, pi, pi->parse_set);
    }
    else {
        list_links(lkg, pi->parse_set, index);
    }
}
コード例 #2
0
ファイル: extract-links.c プロジェクト: Anusaaraka/anusaaraka
/**
 * Generate the list of all links of the index'th parsing of the
 * sentence.  For this to work, you must have already called parse, and
 * already built the whole_set.
 */
void extract_links(int index, int cost, Parse_info pi)
{
	initialize_links(pi);
	pi->rand_state = index;
	if (index < 0) {
		list_random_links(pi, pi->parse_set);
	}
	else {
		list_links(pi, pi->parse_set, index);
	}
}
コード例 #3
0
ファイル: extract-links.c プロジェクト: Legend5/level-1-1st
void extract_links(int index, int cost, Parse_info * pi) {
/* Generate the list of all links of the indexth parsing of the
   sentence.  For this to work, you must have already called parse, and
   already built the whole_set. */
    initialize_links(pi);
    if (index < 0) {
	my_random_initialize(index);
	list_random_links(pi, pi->parse_set);
	my_random_finalize();
    }
    else {
	list_links(pi, pi->parse_set, index);
    }
}
コード例 #4
0
ファイル: extract-links.c プロジェクト: Legend5/level-1-1st
void list_random_links(Parse_info * pi, Parse_set * set) {
     Parse_choice *pc;
     int num_pc, new_index;

     if (set == NULL || set->first == NULL) return;
     num_pc = 0;
     for (pc = set->first; pc != NULL; pc = pc->next) {
	  num_pc++;
     }

     new_index = my_random() % num_pc;
     
     num_pc = 0;
     for (pc = set->first; pc != NULL; pc = pc->next) {
	  if (new_index == num_pc) break;
	  num_pc++;
     }

     assert(pc != NULL, "Couldn't get a random parse choice");
     issue_links_for_choice(pi, pc);
     list_random_links(pi, pc->set[0]);
     list_random_links(pi, pc->set[1]);
}
コード例 #5
0
ファイル: extract-links.c プロジェクト: lagleki/jorne
static void list_random_links(Linkage lkg, Parse_info pi, Parse_set * set)
{
    Parse_choice *pc;
    int num_pc, new_index;

    if (set == NULL || set->first == NULL) return;
    num_pc = 0;
    for (pc = set->first; pc != NULL; pc = pc->next) {
        num_pc++;
    }

    new_index = rand_r(&pi->rand_state) % num_pc;

    num_pc = 0;
    for (pc = set->first; pc != NULL; pc = pc->next) {
        if (new_index == num_pc) break;
        num_pc++;
    }

    assert(pc != NULL, "Couldn't get a random parse choice");
    issue_links_for_choice(lkg, pc);
    list_random_links(lkg, pi, pc->set[0]);
    list_random_links(lkg, pi, pc->set[1]);
}