X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcclfind.c;h=12dca7923a32a0fdb69bd6f36d82fdc96640f8b2;hp=38b6cad0b165daeb202bca787c90c843ddea5b44;hb=f60a3fd863c6a5a8ec97c4918f5cad4a117a8f7d;hpb=70b6eca73431e3cec68c93096de4fb02378c7ae6 diff --git a/src/cclfind.c b/src/cclfind.c index 38b6cad..12dca79 100644 --- a/src/cclfind.c +++ b/src/cclfind.c @@ -334,6 +334,7 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, struct ccl_rpn_node *p_top = 0; struct ccl_token *lookahead = cclp->look_token; int and_list = 0; + int auto_group = 0; int or_list = 0; char *attset; const char **truncation_aliases; @@ -350,13 +351,15 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, if (qual_val_type(qa, CCL_BIB1_STR, CCL_BIB1_STR_AND_LIST, 0)) and_list = 1; + if (qual_val_type(qa, CCL_BIB1_STR, CCL_BIB1_STR_AUTO_GROUP, 0)) + auto_group = 1; if (qual_val_type(qa, CCL_BIB1_STR, CCL_BIB1_STR_OR_LIST, 0)) or_list = 1; while (1) { struct ccl_rpn_node *p; size_t no, i; - int no_spaces = 0; + int is_phrase = 0; int relation_value = -1; int position_value = -1; int structure_value = -1; @@ -378,14 +381,21 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, ADVANCE; continue; } - /* go through each TERM token. If no truncation attribute is yet - met, then look for left/right truncation markers (?) and - set left_trunc/right_trunc/mid_trunc accordingly */ for (no = 0; no < max && is_term_ok(lookahead->kind, term_list); no++) { + int this_is_phrase = 0; for (i = 0; ilen; i++) if (lookahead->name[i] == ' ') - no_spaces++; + this_is_phrase = 1; + + if (auto_group) + { + if (no > 0 && (is_phrase || is_phrase != this_is_phrase)) + break; + is_phrase = this_is_phrase; + } + else if (this_is_phrase || no > 0) + is_phrase = 1; len += 1+lookahead->len+lookahead->ws_prefix_len; lookahead = lookahead->next; } @@ -452,14 +462,13 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, } } } - /* len now holds the number of characters in the RPN term */ - /* no holds the number of CCL tokens (1 or more) */ - - if (structure_value == -1 && - qual_val_type(qa, CCL_BIB1_STR, CCL_BIB1_STR_WP, &attset)) - { /* no structure attribute met. Apply either structure attribute - WORD or PHRASE depending on number of CCL tokens */ - if (no == 1 && no_spaces == 0) + attset = 0; + if (structure_value == -1 && ( + auto_group || + qual_val_type(qa, CCL_BIB1_STR, CCL_BIB1_STR_WP, &attset)) + ) + { + if (!is_phrase) ccl_add_attr_numeric(p, attset, CCL_BIB1_STR, 2); else ccl_add_attr_numeric(p, attset, CCL_BIB1_STR, 1);