home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
txtutl
/
gestalt.arc
/
GESTALT.C
< prev
next >
Wrap
Text File
|
1988-12-06
|
2KB
|
70 lines
/* From 'Pattern Matching: The Gestalt Approach',
p46, Dr. Dobbs Journal, July 1988
I just typed in the code. I'm not a C programmer and don't have a
decent C compiler handy, so this code is not tested (though I proofread
for obvious typos, etc.).
See SIMIL_C.ASM and SIMIL_C.OBJ for the C version of the similarity
function.
Read the comments in the function source (or the article itself
in Dr. Dobbs) for detailed explanation.
David Kirschbaum
Toad Hall
kirsch@braggvax.ARPA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
GESTALT.C
Written by John W. Ratcliff and David E. Metzener
November 10, 1987
Demonstrates the Ratcliff/Obershelp Pattern Recognition Algorithm
Link this with SIMIL[_C].OBJ created from the SIMIL[_C].ASM source file.
The actual similarity function is called as:
int simil(char *str1,char *str2)
where str1 and str2 are the two strings you wish to know their
similarity value. simil returns a percentage match between
0 and 100 percent.
*/
int simil(char *str1,char *str2);
void ucase(char *str);
main()
{
char str1[80];
char str2[80];
int prcnt;
printf("This program demonstrates the Ratcliff/Obershelp pattern\n");
printf("recognition algorithm. Enter series of word pairs to\n");
printf("discover their similarity values.\n");
printf("Enter strings of 'END' and 'END' to exit.\n\n");
do
{
printf("Enter the two strings separated by a space: ");
scanf("%s %s",str1,str2);
ucase(str1);
ucase(str2);
prcnt = simil(str1,str2);
printf("%s and %s are %d\% alike.\n\n",str1,str2,prcnt);
} while (strcmp(str1,"END"));
}
void ucase(str)
char *str;
{
while (*str)
{
*str=toupper(*str);
str++;
}
}