Exemplo n.º 1
0
double
numeric_distance (array<string> a1, array<string> a2, string attr, double m) {
  string v1= find_attribute_value (a1, attr);
  string v2= find_attribute_value (a2, attr);
  if (v1 == "" || v2 == "") return 1.0;
  return min (db_abs (as_double (v1) - as_double (v2)) / m, 1.0);
}
Exemplo n.º 2
0
double
discrete_distance (array<string> a1, array<string> a2, string attr) {
  string v1= find_attribute_value (a1, attr);
  string v2= find_attribute_value (a2, attr);
  if (v1 == "" || v2 == "" || v1 != v2) return 1.0;
  return 0.0;
}
Exemplo n.º 3
0
double
relative_distance (array<string> a1, array<string> a2, string attr, double m) {
  string v1= find_attribute_value (a1, attr);
  string v2= find_attribute_value (a2, attr);
  if (v1 == "" || v2 == "") return 1.0;
  double l1= log (1.0 + db_abs ((double) as_int (v1)));
  double l2= log (1.0 + db_abs ((double) as_int (v2)));
  return db_abs (l1 - l2) / log (m);
}
Exemplo n.º 4
0
static int
get_ex (string family, string variant, string series, string shape,
	int attempt) {
  array<string> lfn= logical_font (family, variant, series, shape);
  array<string> pfn= search_font (lfn, attempt);
  array<string> chs= font_database_characteristics (pfn[0], pfn[1]);
  string ex= find_attribute_value (chs, "ex");
  if (ex == "") return 0;
  else return as_int (ex);
}
Exemplo n.º 5
0
static void copy_attribute_override(char **tgt, const char **attrs, const char *name)
{
	const char *new_value;

	new_value = find_attribute_value(attrs, name);
	if (new_value != NULL) {
		if (*tgt != NULL) {
			free(*tgt);
		}
		*tgt = strdup(new_value);
	}
}
Exemplo n.º 6
0
static void handle_navigation_link(struct feed *feed, const char **attrs)
{
	const char *rel;
	int field;

	rel = find_attribute_value(attrs, "rel");
	if (rel != NULL) {
		if (strcmp(rel, "next") == 0) {
			field = F_LINK_NEXT;
		} else if (strcmp(rel, "previous") == 0) {
			field = F_LINK_PREVIOUS;
		} else {
			field = -1;
		}

		if (field != -1) {
			copy_attribute_keep_old(&feed->fields[field], attrs, "href");
		}
	}
}
Exemplo n.º 7
0
double
vector_distance (array<string> a1, array<string> a2, string attr, double m) {
  string v1= find_attribute_value (a1, attr);
  string v2= find_attribute_value (a2, attr);
  return trace_distance (v1, v2, m);
}