Update of /cvsroot/monetdb/MonetDB4/src/modules/contrib
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15459
Modified Files:
txtsim.mx
Log Message:
fixed stringdiff
Index: txtsim.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/txtsim.mx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- txtsim.mx 4 Oct 2007 10:35:14 -0000 1.4
+++ txtsim.mx 18 Dec 2007 22:34:26 -0000 1.5
@@ -50,6 +50,9 @@
.COMMAND soundex(str) : str = soundex_impl;
"Soundex function for phonetic matching"
+ .COMMAND stringdiff(str s1, str s2) : int = stringdiff_impl;
+ "calculate the soundexed editdistance"
+
.COMMAND qgramnormalize(str): str = CMDqgramnormalize;
"'Normalizes' strings (eg. toUpper and replaces non-alphanumerics with one
space"
@@ -155,10 +158,12 @@
n = (int) strlen(s); /* 64bit: assume strings are less than 2 GB */
m = (int) strlen(t);
if (n == 0) {
- return m;
+ *result = m;
+ return GDK_SUCCEED;
}
if (m == 0) {
- return n;
+ *result = n;
+ return GDK_SUCCEED;
}
sz = (n + 1) * (m + 1) * sizeof(int);
d = (int *) GDKmalloc(sz);
@@ -309,6 +314,19 @@
return GDK_SUCCEED;
}
+int
+stringdiff_impl(int *res, str s1, str s2)
+{
+ int r = GDK_SUCCEED;
+ char *S1 = NULL, *S2 = NULL;
+
+ soundex_impl(&S1, s1);
+ soundex_impl(&S2, s2);
+ r = levenshteinbasic_impl(res, S1, S2);
+ GDKfree(S1);
+ GDKfree(S2);
+ return r;
+}
/******************************
* QGRAMNORMALIZE
@@ -943,12 +961,6 @@
@mil
-proc stringdiff( str s1, str s1 ) : int {
- var sd1 := soundex(s1);
- var sd2 := soundex(s2);
- return editdistance(sd1,sd2);
-}
-
proc str2qgrams(str s) : bat[oid,str]
{
s := qgramnormalize(s);
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins