[Subject Prev][Subject Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hts-users:01486] patch for HTS_model.c in hts_engine_API-0.99


Hello,

I made a patch for HTS_model.c:

--- HTS_model.c.orig    2008-05-30 17:12:57.000000000 +0900
+++ HTS_model.c 2008-06-26 19:51:17.000000000 +0900
@@ -63,15 +63,11 @@
       if (HTS_dp_match(string + 1, pattern, pos + 1, max) == 1)
          return TRUE;
       else
-         return HTS_dp_match(string + 1, pattern + 1, pos + 1, max);
+         return HTS_dp_match(string, pattern + 1, pos, max);
    }
    if (string[0] == pattern[0] || pattern[0] == '?') {
       if (HTS_dp_match(string + 1, pattern + 1, pos + 1, max + 1) == 1)
          return TRUE;
-      else {
-         if (pattern[1] == '*')
-            return HTS_dp_match(string + 1, pattern + 2, pos + 1, max + 1);
-      }
    }

    return FALSE;


=== Background ===

I created a simple test program 'matchtest.c':

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#define HTS_Boolean int
#define FALSE 0
#define TRUE 1
#define HTS_MAXBUFLEN 1024

/* HTS_dp_match: recursive matching */
static HTS_Boolean HTS_dp_match(const char *string, const char *pattern,
                                const int pos, const int max)
{
    ...
}

/* HTS_pattern_match: pattern matching function */
static HTS_Boolean HTS_pattern_match(const char *string, const char *pattern)
{
    ...
}

int main(int argc, char *argv[])
{
    printf("%d\n", HTS_pattern_match(argv[1], argv[2]));

    return 0;
}

(EOF)

and compiled as follows:

gcc -o matchtest matchtest.c


I think that the following results of matchtest

$ ./matchtest abcdefg '*bcd*'
1

$ ./matchtest abcdefg '*fgh*'
0

$ ./matchtest abcdefg '*abcdef*'
1

$ ./matchtest abcdefg 'ab?de?g'
1

$ ./matchtest abcdefg 'ab?def?g'
0

are OK, but the following results


$ ./matchtest abcdefg '*ab?def*'
0

$ ./matchtest abcdefg '*ab*def*'
0

are not good.


Thanks,

Nobuyuki NISHIZAWA
KDDI R&D Labs.
no-nishizawa@xxxxxxxxxxx


Follow-Ups
[hts-users:01487] Re: patch for HTS_model.c in hts_engine_API-0.99, Heiga ZEN (Byung Ha CHUN)