+yaz_stemmer_p yaz_stemmer_clone(yaz_stemmer_p stemmer) {
+ UErrorCode error = U_ZERO_ERROR;
+ if (stemmer == 0)
+ return 0;
+ return yaz_stemmer_create(stemmer->locale, stemmer->rule, &error);
+}
+
+void yaz_stemmer_stem(yaz_stemmer_p stemmer, struct icu_buf_utf16 *dst, struct icu_buf_utf16* src, UErrorCode *status)
+{
+ switch(stemmer->implementation) {
+ case yaz_snowball: {
+ struct icu_buf_utf8 *utf8_buf = icu_buf_utf8_create(0);
+ icu_utf16_to_utf8(utf8_buf, src, status);
+ if (*status == U_ZERO_ERROR) {
+ const sb_symbol *cstr = (const sb_symbol*) icu_buf_utf8_to_cstr(utf8_buf);
+ const sb_symbol *sb_symbol = sb_stemmer_stem(stemmer->sb_stemmer, cstr, utf8_buf->utf8_len);
+ if (sb_symbol == 0) {
+ icu_buf_utf16_copy(dst, src);
+ }
+ else {
+ const char *cstr = (const char *) sb_symbol;
+ icu_utf16_from_utf8_cstr(dst, cstr , status);
+ }
+ }
+ icu_buf_utf8_destroy(utf8_buf);
+ return ;
+ break;
+ }
+ case yaz_no_operation:
+ yaz_log(YLOG_DEBUG, "Stemmer (No operation) called");
+ default: {
+ // Default return the same as given.
+ icu_buf_utf16_copy(dst, src);
+ }
+ }
+}