Show
Ignore:
Timestamp:
07/31/08 23:10:16 (4 months ago)
Author:
karpet
Message:

fix the bump_word feature so that ->pos for Word or Token reflects TOKENPOS_BUMP

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libswish3/trunk/src/libswish3/libswish3.h

    r2150 r2153  
    304304struct swish_Token 
    305305{ 
    306     unsigned int        pos; 
     306    unsigned int        pos;            // this token's position in document 
    307307    swish_MetaName     *meta; 
    308308    xmlChar            *value; 
     
    316316{ 
    317317    unsigned int        n; 
     318    unsigned int        pos;            // track position in document 
    318319    xmlBufferPtr        buf; 
    319320    swish_Token**       tokens; 
     
    325326    swish_TokenList     *tl; 
    326327    swish_Config        *config; 
    327     unsigned int         pos; 
     328    unsigned int         pos;           // position in iteration 
    328329    int                  ref_cnt; 
    329330}; 
  • libswish3/trunk/src/libswish3/parser.c

    r2150 r2153  
    328328        if (xmlStrEqual(swishtag, (xmlChar *)"br") 
    329329            || xmlStrEqual(swishtag, (xmlChar *)"img")) { 
     330             
     331            if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     332                SWISH_DEBUG_MSG("found html tag '%s' ... bump_word = 1", swishtag); 
    330333            parser_data->bump_word = 1; 
    331334        } 
     
    342345* elements  
    343346*/ 
     347                if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     348                    SWISH_DEBUG_MSG("found html !inline tag '%s' ... bump_word = 1", swishtag); 
    344349                parser_data->bump_word = 1; 
    345350 
     
    347352            else { 
    348353             
     354                if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     355                    SWISH_DEBUG_MSG("found html inline tag '%s' ... bump_word = 0", swishtag); 
    349356                parser_data->bump_word = 0; 
    350357             
     
    391398* do not match across metas  
    392399*/ 
     400                if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     401                    SWISH_DEBUG_MSG("found html meta tag '%s' ... bump_word = 1", metaname); 
    393402                parser_data->bump_word = 1; 
    394403                open_tag(parser_data, metaname, NULL); 
     
    415424*/ 
    416425 
     426        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     427            SWISH_DEBUG_MSG("found xml tag '%s' ... bump_word = 1", swishtag); 
    417428        parser_data->bump_word = 1; 
    418429 
     
    20652076 
    20662077    swish_WordList *tmplist; 
    2067  
     2078     
    20682079    if (parser_data->s3->analyzer->tokenlist) { 
    20692080 
     
    20762087                                                     parser_data->token_iterator->tl, 
    20772088                                                     meta, context); 
    2078  
    20792089        return; 
    20802090 
  • libswish3/trunk/src/libswish3/tokenizer.c

    r2148 r2153  
    316316    tl->buf = xmlBufferCreateSize((size_t) SWISH_BUFFER_CHUNK_SIZE); 
    317317    tl->n = 0; 
     318    tl->pos = 0; 
    318319    tl->ref_cnt = 0; 
    319320    tl->tokens = swish_xmalloc(sizeof(swish_Token *) * SWISH_TOKEN_LIST_SIZE); 
     
    372373    stoken->start_byte = xmlBufferLength(tl->buf); 
    373374    stoken->len = token_len - 1;        /*  TODO do we even need NULL? */ 
    374     stoken->pos = tl->n + 1
     375    stoken->pos = ++tl->pos
    375376    stoken->meta = meta; 
    376377    stoken->meta->ref_cnt++; 
     
    615616 
    616617        } 
    617  
     618         
    618619        prev_pos = byte_pos; 
    619620 
     
    645646 
    646647                token = copy;   /*  restore to top of array so we do not leak */ 
     648 
     649                if (cp == SWISH_TOKENPOS_BUMPER[0]) { 
     650                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     651                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", tl->pos); 
     652                    tl->pos++; 
     653                } 
    647654 
    648655                continue; 
     
    652659                if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
    653660                    SWISH_DEBUG_MSG("ignoring chr '%s'", chr); 
     661 
     662                if (cp == SWISH_TOKENPOS_BUMPER[0]) { 
     663                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     664                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", tl->pos); 
     665                    tl->pos++; 
     666                } 
    654667 
    655668                continue; 
     
    695708                    token = copy;       /*  restore to top of array */ 
    696709 
     710                } 
     711 
     712                if (cp == SWISH_TOKENPOS_BUMPER[0]) { 
     713                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     714                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", tl->pos); 
     715                    tl->pos++; 
    697716                } 
    698717 
     
    718737                } 
    719738 
     739                if (cp == SWISH_TOKENPOS_BUMPER[0]) { 
     740                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     741                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", tl->pos); 
     742                    tl->pos++; 
     743                } 
     744 
    720745                continue; 
    721746 
     
    761786            SWISH_DEBUG_MSG(" char: %c lower: %c  int: %d %#x (next is %c)", buf[i], c, 
    762787                            (int)c, (unsigned int)c, nextc); 
    763  
     788                             
    764789        if (!ascii_word_table[(int)c]) { 
    765790 
     
    783808 
    784809                token = copy; 
     810                 
     811                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     812                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     813                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", tl->pos); 
     814                    tl->pos++; 
     815                } 
     816 
    785817 
    786818                continue; 
     
    790822                if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
    791823                    SWISH_DEBUG_MSG("ignoring char '%c'", c); 
     824 
     825                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     826                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     827                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", tl->pos); 
     828                    tl->pos++; 
     829                } 
    792830 
    793831                continue; 
     
    826864                    token = copy; 
    827865 
     866                } 
     867 
     868                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     869                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     870                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", tl->pos); 
     871                    tl->pos++; 
    828872                } 
    829873 
     
    846890                    swish_add_token(tl, token, token_len, meta, context); 
    847891                } 
     892                 
     893                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     894                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     895                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", tl->pos); 
     896                    tl->pos++; 
     897                } 
     898 
    848899                continue; 
    849900 
  • libswish3/trunk/src/libswish3/words.c

    r2148 r2153  
    327327 
    328328                swish_xfree(utf8_str); 
     329                 
     330                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     331                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     332                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", word_pos); 
     333                    word_pos++; 
     334                } 
    329335 
    330336                continue; 
     
    334340                if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
    335341                    SWISH_DEBUG_MSG("ignoring char '%lc'", (wint_t) c); 
     342                     
     343                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     344                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     345                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", word_pos); 
     346                    word_pos++; 
     347                } 
    336348 
    337349                continue; 
     
    377389                } 
    378390 
     391                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     392                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     393                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", word_pos); 
     394                    word_pos++; 
     395                } 
     396                 
    379397                continue; 
    380398 
     
    388406                in_word = 1; 
    389407                word[w++] = c; 
     408                 
     409                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     410                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     411                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", word_pos); 
     412                    word_pos++; 
     413                } 
     414                 
    390415                continue; 
    391416 
     
    514539                } 
    515540 
     541                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     542                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     543                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", word_pos); 
     544                    word_pos++; 
     545                } 
     546                 
    516547                continue; 
    517548 
     
    520551                if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
    521552                    SWISH_DEBUG_MSG("ignoring char '%c'", c); 
    522  
     553                 
     554                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     555                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     556                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", word_pos); 
     557                    word_pos++; 
     558                } 
     559                 
    523560                continue; 
    524561            } 
     
    560597                } 
    561598 
     599                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     600                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     601                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", word_pos); 
     602                    word_pos++; 
     603                } 
     604                 
    562605                continue; 
    563606 
     
    572615                in_word = 1; 
    573616                word[w++] = c; 
     617                 
     618                if (c == SWISH_TOKENPOS_BUMPER[0]) { 
     619                    if (SWISH_DEBUG & SWISH_DEBUG_TOKENIZER) 
     620                        SWISH_DEBUG_MSG("found tokenpos bumper byte at pos %d", word_pos); 
     621                    word_pos++; 
     622                } 
     623                 
    574624                continue; 
    575625