Ticket #296: scriptindex.cc.spelling.diff
File scriptindex.cc.spelling.diff, 2.8 KB (added by , 16 years ago) |
---|
-
scriptindex.cc
old new 95 95 const char * action_names[] = { 96 96 "bad", "new", 97 97 "boolean", "date", "field", "hash", "index", "indexnopos", "load", "lower", 98 " truncate", "unhtml", "unique", "value", "weight"98 "spell", "truncate", "unhtml", "unique", "value", "weight" 99 99 }; 100 100 101 101 // For debugging: … … 106 106 typedef enum { 107 107 BAD, NEW, 108 108 BOOLEAN, DATE, FIELD, HASH, INDEX, INDEXNOPOS, LOAD, LOWER, 109 TRUNCATE, UNHTML, UNIQUE, VALUE, WEIGHT109 SPELL, TRUNCATE, UNHTML, UNIQUE, VALUE, WEIGHT 110 110 } type; 111 111 private: 112 112 type action; … … 233 233 code = Action::LOAD; 234 234 } 235 235 break; 236 case 's': 237 if (action == "spell") { 238 code = Action::SPELL; 239 } 240 break; 236 241 case 't': 237 242 if (action == "truncate") { 238 243 code = Action::TRUNCATE; … … 374 379 switch (action) { 375 380 case Action::HASH: 376 381 case Action::LOWER: 382 case Action::SPELL: 377 383 case Action::TRUNCATE: 378 384 case Action::UNHTML: 379 385 done = false; … … 429 435 Xapian::docid docid = 0; 430 436 map<string, list<string> > fields; 431 437 bool seen_content = false; 438 bool add_spelling = false; 432 439 while (!line.empty()) { 433 440 // Cope with files from MS Windows (\r\n end of lines). 434 441 // Trim multiple \r characters, since that seems the best way … … 458 465 line.resize(last + 1); 459 466 value += line; 460 467 } 468 // don't add words to the spelling dictionary by default, so clear this flag if it was set in a previous iteration 469 add_spelling = false; 470 if(indexer.set_flags((Xapian::TermGenerator::flags)0, (Xapian::TermGenerator::flags)(~0)) & indexer.FLAG_SPELLING) 471 indexer.set_flags((Xapian::TermGenerator::flags)0, (Xapian::TermGenerator::flags)(~indexer.FLAG_SPELLING)); 461 472 462 473 const vector<Action> &v = index_spec[field]; 463 474 string old_value = value; … … 486 497 } 487 498 break; 488 499 case Action::INDEX: 500 if(add_spelling) 501 { 502 indexer.set_database(database); 503 indexer.set_flags(indexer.FLAG_SPELLING, (Xapian::TermGenerator::flags)(~indexer.FLAG_SPELLING)); 504 } 489 505 indexer.index_text(value, 490 506 i->get_num_arg(), 491 507 i->get_string_arg()); 492 508 break; 493 509 case Action::INDEXNOPOS: 510 if(add_spelling) 511 { 512 indexer.set_database(database); 513 indexer.set_flags(indexer.FLAG_SPELLING, (Xapian::TermGenerator::flags)(~indexer.FLAG_SPELLING)); 514 } 494 515 // No positional information so phrase searching 495 516 // won't work. However, the database will use much 496 517 // less diskspace. … … 534 555 case Action::TRUNCATE: 535 556 utf8_truncate(value, i->get_num_arg()); 536 557 break; 558 case Action::SPELL: 559 add_spelling = true; 560 break; 537 561 case Action::UNHTML: { 538 562 MyHtmlParser p; 539 563 try {