/**
 * The name of the link is set to be the GCD of the names of
 * its two endpoints. Must be called after each extract_links(),
 * etc. since that call issues a brand-new set of links into
 * parse_info.
 */
void compute_link_names(Linkage lkg, String_set *sset)
{
	size_t i;
	for (i = 0; i < lkg->num_links; i++)
	{
		lkg->link_array[i].link_name = intersect_strings(sset,
			connector_get_string(lkg->link_array[i].lc),
			connector_get_string(lkg->link_array[i].rc));
	}
}
/**
 * The name of the link is set to be the GCD of the names of
 * its two endpoints.
 */
static void compute_link_names(Sentence sent)
{
	int i;
	Parse_info pi = sent->parse_info;

	for (i=0; i<pi->N_links; i++) {
		pi->link_array[i].name = intersect_strings(sent,
		   pi->link_array[i].lc->string, pi->link_array[i].rc->string);
	}
}
/**
 * This fills in the sublinkage->link[].name field.  We assume that
 * link_array[].name have already been filled in.  As above, in the
 * standard case, the name is just the GCD of the two end points.
 * If pluralization has occurred, then we want to use the name
 * already in link_array[].name.  We detect this in two ways.
 * If the endpoints don't match, then we know pluralization
 * has occured.  If they do, but the name in link_array[].name
 * is *less* restrictive, then pluralization must have occured.
 */
static void compute_pp_link_names(Sentence sent, Sublinkage *sublinkage)
{
	int i;
	const char * s;
	Parse_info pi = sent->parse_info;

	for (i=0; i<pi->N_links; i++)
	  {
		if (sublinkage->link[i]->l == -1) continue;
		if (!x_match(sublinkage->link[i]->lc, sublinkage->link[i]->rc))
		  replace_link_name(sublinkage->link[i], pi->link_array[i].name);
		else
		  {
			s = intersect_strings(sent, sublinkage->link[i]->lc->string,
								  sublinkage->link[i]->rc->string);
			if (strictly_smaller_name(s, pi->link_array[i].name))
			  replace_link_name(sublinkage->link[i], pi->link_array[i].name);
			else replace_link_name(sublinkage->link[i], s);
		  }
	}
}