Pazpar2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Pazpar2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
typedef struct pp2_charset_s *pp2_charset_t;
static pp2_charset_t pp2_charset_create_xml(xmlNode *xml_node);
typedef struct pp2_charset_s *pp2_charset_t;
static pp2_charset_t pp2_charset_create_xml(xmlNode *xml_node);
static pp2_charset_t pp2_charset_create_a_to_z(void);
static void pp2_charset_destroy(pp2_charset_t pct);
static pp2_charset_token_t pp2_charset_tokenize(pp2_charset_t pct);
static pp2_charset_t pp2_charset_create_a_to_z(void);
static void pp2_charset_destroy(pp2_charset_t pct);
static pp2_charset_token_t pp2_charset_tokenize(pp2_charset_t pct);
/* charset handle */
struct pp2_charset_s {
const char *(*token_next_handler)(pp2_charset_token_t prt);
const char *(*get_sort_handler)(pp2_charset_token_t prt);
const char *(*get_display_handler)(pp2_charset_token_t prt);
/* charset handle */
struct pp2_charset_s {
const char *(*token_next_handler)(pp2_charset_token_t prt);
const char *(*get_sort_handler)(pp2_charset_token_t prt);
const char *(*get_display_handler)(pp2_charset_token_t prt);
static const char *pp2_charset_token_a_to_z(pp2_charset_token_t prt);
static const char *pp2_get_sort_ascii(pp2_charset_token_t prt);
static const char *pp2_get_display_ascii(pp2_charset_token_t prt);
static const char *pp2_charset_token_a_to_z(pp2_charset_token_t prt);
static const char *pp2_get_sort_ascii(pp2_charset_token_t prt);
static const char *pp2_get_display_ascii(pp2_charset_token_t prt);
#if YAZ_HAVE_ICU
static const char *pp2_charset_token_icu(pp2_charset_token_t prt);
static const char *pp2_get_sort_icu(pp2_charset_token_t prt);
static const char *pp2_get_display_icu(pp2_charset_token_t prt);
#if YAZ_HAVE_ICU
static const char *pp2_charset_token_icu(pp2_charset_token_t prt);
static const char *pp2_get_sort_icu(pp2_charset_token_t prt);
static const char *pp2_get_display_icu(pp2_charset_token_t prt);
pp2_charset_fact_add(pft, pp2_charset_create_a_to_z(), "relevance");
pp2_charset_fact_add(pft, pp2_charset_create_a_to_z(), "sort");
pp2_charset_fact_add(pft, pp2_charset_create_a_to_z(), "mergekey");
pp2_charset_fact_add(pft, pp2_charset_create_a_to_z(), "relevance");
pp2_charset_fact_add(pft, pp2_charset_create_a_to_z(), "sort");
pp2_charset_fact_add(pft, pp2_charset_create_a_to_z(), "mergekey");
- yaz_log(YLOG_WARN, "Missing id for icu_chain");
- pp2_charset_destroy(pct);
- return -1;
+ id = xmlGetProp(xml_node, (xmlChar*) "id");
+ if (!id)
+ {
+ yaz_log(YLOG_WARN, "Missing id for icu_chain");
+ pp2_charset_destroy(pct);
+ return -1;
+ }
+ default_id = (const char *) id;
yaz_log(YLOG_FATAL, "Could not parse ICU chain config:\n"
"<%s>\n ... \n</%s>",
xml_node->name, xml_node->name);
return 0;
}
yaz_log(YLOG_FATAL, "Could not parse ICU chain config:\n"
"<%s>\n ... \n</%s>",
xml_node->name, xml_node->name);
return 0;
}
#else // YAZ_HAVE_ICU
yaz_log(YLOG_FATAL, "Error: ICU support requested with element:\n"
"<%s>\n ... \n</%s>",
xml_node->name, xml_node->name);
#else // YAZ_HAVE_ICU
yaz_log(YLOG_FATAL, "Error: ICU support requested with element:\n"
"<%s>\n ... \n</%s>",
xml_node->name, xml_node->name);
-pp2_charset_t pp2_charset_create_a_to_z(void)
-{
- pp2_charset_t pct = pp2_charset_create(0);
- pct->token_next_handler = pp2_charset_token_a_to_z;
- return pct;
-}
-
-pp2_charset_t pp2_charset_create(struct icu_chain *icu_chn)
+pp2_charset_t pp2_charset_create(void)
{
pp2_charset_t pct = xmalloc(sizeof(*pct));
pct->token_next_handler = pp2_charset_token_null;
pct->get_sort_handler = pp2_get_sort_ascii;
pct->get_display_handler = pp2_get_display_ascii;
{
pp2_charset_t pct = xmalloc(sizeof(*pct));
pct->token_next_handler = pp2_charset_token_null;
pct->get_sort_handler = pp2_get_sort_ascii;
pct->get_display_handler = pp2_get_display_ascii;
+#endif // YAZ_HAVE_ICU
+ return pct;
+}
+
+pp2_charset_t pp2_charset_create_a_to_z(void)
+{
+ pp2_charset_t pct = pp2_charset_create();
+ pct->token_next_handler = pp2_charset_token_a_to_z;
+ return pct;
+}
+
+#if YAZ_HAVE_ICU
+pp2_charset_t pp2_charset_create_icu(struct icu_chain *icu_chn)
+{
+ pp2_charset_t pct = pp2_charset_create();
pct->token_next_handler = pp2_charset_token_icu;
pct->get_sort_handler = pp2_get_sort_icu;
pct->get_display_handler = pp2_get_display_icu;
pct->token_next_handler = pp2_charset_token_icu;
pct->get_sort_handler = pp2_get_sort_icu;
pct->get_display_handler = pp2_get_display_icu;
return prt;
}
void pp2_charset_token_first(pp2_charset_token_t prt,
const char *buf, int skip_article)
return prt;
}
void pp2_charset_token_first(pp2_charset_token_t prt,
const char *buf, int skip_article)
for (; *p && *p != ' ' && pout - firstword < (sizeof(firstword)-2); p++)
*pout++ = tolower(*(unsigned char *)p);
*pout++ = ' ';
for (; *p && *p != ' ' && pout - firstword < (sizeof(firstword)-2); p++)
*pout++ = tolower(*(unsigned char *)p);
*pout++ = ' ';
#define raw_char(c) (((c) >= 'a' && (c) <= 'z') ? (c) : -1)
/* original tokenizer with our tokenize interface, but we
add +1 to ensure no '\0' are in our string (except for EOF)
#define raw_char(c) (((c) >= 'a' && (c) <= 'z') ? (c) : -1)
/* original tokenizer with our tokenize interface, but we
add +1 to ensure no '\0' are in our string (except for EOF)
wrbuf_rewind(prt->sort_str);
wrbuf_puts(prt->sort_str, result);
xfree(tmp);
wrbuf_rewind(prt->sort_str);
wrbuf_puts(prt->sort_str, result);
xfree(tmp);