VALUE method_levenshtein(cls,strb) 
{
  VALUE stra = cls;
  if (FIX2INT(rb_str_length(stra))>FIX2INT(rb_str_length(strb))) {
    VALUE strt = stra;
    stra = strb;
    strb = strt;
  }
  int distance = FIX2INT(rb_str_length(strb))-FIX2INT(rb_str_length(stra));
  char* cstra = StringValuePtr(stra);
  char* cstrb = StringValuePtr(strb);
  int i=0;
  for (i=0;i<strlen(cstra);i++) {
    if (cstrb[i]==cstra[i]) continue;
    distance++;
  }
  return INT2FIX(distance);
}
Beispiel #2
0
VALUE parse_string(VALUE self, VALUE string) {

  return build_matrix(RSTRING_PTR(string), NUM2INT(rb_str_length(string)));

}
Beispiel #3
0
VALUE string_spec_rb_str_length(VALUE self, VALUE str) {
  return rb_str_length(str);
}