0

Hi i am using sqlite FTS4 and my .sqlite file is in the main Bundle, i implemented this function mentioned here How to deal with accented characters in iOS SQLite?

void unaccented(sqlite3_context *context, int argc, sqlite3_value **argv)
{
    if (argc != 1 || sqlite3_value_type(argv[0]) != SQLITE_TEXT) {
        sqlite3_result_null(context);
        return;
    }
    @autoreleasepool {
        NSMutableString *string = [NSMutableString stringWithUTF8String:(const char *)sqlite3_value_text(argv[0])];
        CFStringTransform((__bridge CFMutableStringRef)string, NULL, kCFStringTransformStripCombiningMarks, NO);
        sqlite3_result_text(context, [string UTF8String], -1, SQLITE_TRANSIENT);
    }
}

- (void)createUnaccentedFunction
{
    if (sqlite3_create_function_v2(euph, "unaccented", 1, SQLITE_ANY, NULL, &unaccented, NULL, NULL, NULL) != SQLITE_OK)
        NSLog(@"%s: sqlite3_create_function_v2 error: %s", __FUNCTION__, sqlite3_errmsg(euph));
}

the following query that i need does not work (query OK but no results),

SELECT term_id,eng_term, ara_term, type_id FROM mainporter where unaccented(ara_term) MATCH '%@' 

But when using an old column that i removed accentuation from manually, i can get results unaccented. so the functions is working fine

SELECT term_id,eng_term, unaccented(ara_term), type_id FROM mainporter where ara_term_2 MATCH '%@' 

Any suggestions ? Sorry i had to start a new question but i can't comment as i don't have 50+ reputation (thumbs up) !!

Community
  • 1
  • 1
Hakim
  • 1,242
  • 1
  • 10
  • 22

1 Answers1

1

FTS matching works only on columns of a FTS table; you cannot apply MATCH to the result of a function.

To remove accents, try the UNICODE61 tokenizer, or implement your own custom tokenizer.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • Thank you just two quick questions, can i use UNICODE61 and porter becuase what i understood is that unicode61 is based on the simple tokenizer, and do you know of a good tutorial on how to implement a custom tokenizer, maybe my only option is a to modify porter to recognizes arabic accentuation. ? – Hakim Feb 14 '14 at 20:12