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_t pp2_charset_create_a_to_z(void);
static void pp2_charset_destroy(pp2_charset_t pct);
- const char *(*token_next_handler)(pp2_relevance_token_t prt);
- const char *(*get_sort_handler)(pp2_relevance_token_t prt);
- const char *(*get_display_handler)(pp2_relevance_token_t prt);
+ 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_relevance_token_null(pp2_relevance_token_t prt);
-static const char *pp2_relevance_token_a_to_z(pp2_relevance_token_t prt);
-static const char *pp2_get_sort_ascii(pp2_relevance_token_t prt);
-static const char *pp2_get_display_ascii(pp2_relevance_token_t prt);
+static const char *pp2_charset_token_null(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_relevance_token_icu(pp2_relevance_token_t prt);
-static const char *pp2_get_sort_icu(pp2_relevance_token_t prt);
-static const char *pp2_get_display_icu(pp2_relevance_token_t prt);
+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);
const char *cp; /* unnormalized buffer we're tokenizing */
const char *last_cp; /* pointer to last token we're dealing with */
pp2_charset_t pct; /* our main charset handle (type+config) */
const char *cp; /* unnormalized buffer we're tokenizing */
const char *last_cp; /* pointer to last token we're dealing with */
pp2_charset_t pct; /* our main charset handle (type+config) */
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_relevance_token_a_to_z;
- return pct;
-}
-
-pp2_charset_t pp2_charset_create(struct icu_chain *icu_chn)
+pp2_charset_t pp2_charset_create(void)
+#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();
{
struct pp2_charset_entry *pce;
for (pce = pft->list; pce; pce = pce->next)
if (!strcmp(id, pce->name))
{
struct pp2_charset_entry *pce;
for (pce = pft->list; pce; pce = pce->next)
if (!strcmp(id, pce->name))
-void pp2_relevance_first(pp2_relevance_token_t prt,
- const char *buf,
- int skip_article)
-{
+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++ = ' ';
/* original tokenizer with our tokenize interface, but we
add +1 to ensure no '\0' are in our string (except for EOF)
*/
/* 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);