sdsykes-ferret 0.11.6.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. data/CHANGELOG +24 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +102 -0
  4. data/Rakefile +338 -0
  5. data/TODO +17 -0
  6. data/TUTORIAL +231 -0
  7. data/bin/ferret-browser +79 -0
  8. data/ext/analysis.c +1555 -0
  9. data/ext/analysis.h +219 -0
  10. data/ext/api.c +69 -0
  11. data/ext/api.h +27 -0
  12. data/ext/array.c +123 -0
  13. data/ext/array.h +53 -0
  14. data/ext/bitvector.c +540 -0
  15. data/ext/bitvector.h +272 -0
  16. data/ext/compound_io.c +383 -0
  17. data/ext/config.h +42 -0
  18. data/ext/document.c +156 -0
  19. data/ext/document.h +53 -0
  20. data/ext/except.c +120 -0
  21. data/ext/except.h +168 -0
  22. data/ext/extconf.rb +14 -0
  23. data/ext/ferret.c +402 -0
  24. data/ext/ferret.h +91 -0
  25. data/ext/filter.c +156 -0
  26. data/ext/fs_store.c +483 -0
  27. data/ext/global.c +418 -0
  28. data/ext/global.h +117 -0
  29. data/ext/hash.c +567 -0
  30. data/ext/hash.h +473 -0
  31. data/ext/hashset.c +170 -0
  32. data/ext/hashset.h +187 -0
  33. data/ext/header.h +58 -0
  34. data/ext/helper.c +62 -0
  35. data/ext/helper.h +13 -0
  36. data/ext/inc/lang.h +48 -0
  37. data/ext/inc/threading.h +31 -0
  38. data/ext/index.c +6425 -0
  39. data/ext/index.h +961 -0
  40. data/ext/lang.h +66 -0
  41. data/ext/libstemmer.c +92 -0
  42. data/ext/libstemmer.h +79 -0
  43. data/ext/mempool.c +87 -0
  44. data/ext/mempool.h +35 -0
  45. data/ext/modules.h +162 -0
  46. data/ext/multimapper.c +310 -0
  47. data/ext/multimapper.h +51 -0
  48. data/ext/posh.c +1006 -0
  49. data/ext/posh.h +1007 -0
  50. data/ext/priorityqueue.c +151 -0
  51. data/ext/priorityqueue.h +143 -0
  52. data/ext/q_boolean.c +1608 -0
  53. data/ext/q_const_score.c +161 -0
  54. data/ext/q_filtered_query.c +209 -0
  55. data/ext/q_fuzzy.c +268 -0
  56. data/ext/q_match_all.c +148 -0
  57. data/ext/q_multi_term.c +677 -0
  58. data/ext/q_parser.c +2825 -0
  59. data/ext/q_phrase.c +1126 -0
  60. data/ext/q_prefix.c +100 -0
  61. data/ext/q_range.c +350 -0
  62. data/ext/q_span.c +2402 -0
  63. data/ext/q_term.c +337 -0
  64. data/ext/q_wildcard.c +171 -0
  65. data/ext/r_analysis.c +2575 -0
  66. data/ext/r_index.c +3472 -0
  67. data/ext/r_qparser.c +585 -0
  68. data/ext/r_search.c +4105 -0
  69. data/ext/r_store.c +513 -0
  70. data/ext/r_utils.c +963 -0
  71. data/ext/ram_store.c +471 -0
  72. data/ext/search.c +1741 -0
  73. data/ext/search.h +885 -0
  74. data/ext/similarity.c +150 -0
  75. data/ext/similarity.h +82 -0
  76. data/ext/sort.c +983 -0
  77. data/ext/stem_ISO_8859_1_danish.c +338 -0
  78. data/ext/stem_ISO_8859_1_danish.h +16 -0
  79. data/ext/stem_ISO_8859_1_dutch.c +635 -0
  80. data/ext/stem_ISO_8859_1_dutch.h +16 -0
  81. data/ext/stem_ISO_8859_1_english.c +1156 -0
  82. data/ext/stem_ISO_8859_1_english.h +16 -0
  83. data/ext/stem_ISO_8859_1_finnish.c +792 -0
  84. data/ext/stem_ISO_8859_1_finnish.h +16 -0
  85. data/ext/stem_ISO_8859_1_french.c +1276 -0
  86. data/ext/stem_ISO_8859_1_french.h +16 -0
  87. data/ext/stem_ISO_8859_1_german.c +512 -0
  88. data/ext/stem_ISO_8859_1_german.h +16 -0
  89. data/ext/stem_ISO_8859_1_italian.c +1091 -0
  90. data/ext/stem_ISO_8859_1_italian.h +16 -0
  91. data/ext/stem_ISO_8859_1_norwegian.c +296 -0
  92. data/ext/stem_ISO_8859_1_norwegian.h +16 -0
  93. data/ext/stem_ISO_8859_1_porter.c +776 -0
  94. data/ext/stem_ISO_8859_1_porter.h +16 -0
  95. data/ext/stem_ISO_8859_1_portuguese.c +1035 -0
  96. data/ext/stem_ISO_8859_1_portuguese.h +16 -0
  97. data/ext/stem_ISO_8859_1_spanish.c +1119 -0
  98. data/ext/stem_ISO_8859_1_spanish.h +16 -0
  99. data/ext/stem_ISO_8859_1_swedish.c +307 -0
  100. data/ext/stem_ISO_8859_1_swedish.h +16 -0
  101. data/ext/stem_KOI8_R_russian.c +701 -0
  102. data/ext/stem_KOI8_R_russian.h +16 -0
  103. data/ext/stem_UTF_8_danish.c +344 -0
  104. data/ext/stem_UTF_8_danish.h +16 -0
  105. data/ext/stem_UTF_8_dutch.c +653 -0
  106. data/ext/stem_UTF_8_dutch.h +16 -0
  107. data/ext/stem_UTF_8_english.c +1176 -0
  108. data/ext/stem_UTF_8_english.h +16 -0
  109. data/ext/stem_UTF_8_finnish.c +808 -0
  110. data/ext/stem_UTF_8_finnish.h +16 -0
  111. data/ext/stem_UTF_8_french.c +1296 -0
  112. data/ext/stem_UTF_8_french.h +16 -0
  113. data/ext/stem_UTF_8_german.c +526 -0
  114. data/ext/stem_UTF_8_german.h +16 -0
  115. data/ext/stem_UTF_8_italian.c +1113 -0
  116. data/ext/stem_UTF_8_italian.h +16 -0
  117. data/ext/stem_UTF_8_norwegian.c +302 -0
  118. data/ext/stem_UTF_8_norwegian.h +16 -0
  119. data/ext/stem_UTF_8_porter.c +794 -0
  120. data/ext/stem_UTF_8_porter.h +16 -0
  121. data/ext/stem_UTF_8_portuguese.c +1055 -0
  122. data/ext/stem_UTF_8_portuguese.h +16 -0
  123. data/ext/stem_UTF_8_russian.c +709 -0
  124. data/ext/stem_UTF_8_russian.h +16 -0
  125. data/ext/stem_UTF_8_spanish.c +1137 -0
  126. data/ext/stem_UTF_8_spanish.h +16 -0
  127. data/ext/stem_UTF_8_swedish.c +313 -0
  128. data/ext/stem_UTF_8_swedish.h +16 -0
  129. data/ext/stopwords.c +401 -0
  130. data/ext/store.c +692 -0
  131. data/ext/store.h +777 -0
  132. data/ext/term_vectors.c +352 -0
  133. data/ext/threading.h +31 -0
  134. data/ext/utilities.c +446 -0
  135. data/ext/win32.h +54 -0
  136. data/lib/ferret.rb +29 -0
  137. data/lib/ferret/browser.rb +246 -0
  138. data/lib/ferret/browser/s/global.js +192 -0
  139. data/lib/ferret/browser/s/style.css +148 -0
  140. data/lib/ferret/browser/views/document/list.rhtml +49 -0
  141. data/lib/ferret/browser/views/document/show.rhtml +27 -0
  142. data/lib/ferret/browser/views/error/index.rhtml +7 -0
  143. data/lib/ferret/browser/views/help/index.rhtml +8 -0
  144. data/lib/ferret/browser/views/home/index.rhtml +29 -0
  145. data/lib/ferret/browser/views/layout.rhtml +22 -0
  146. data/lib/ferret/browser/views/term-vector/index.rhtml +4 -0
  147. data/lib/ferret/browser/views/term/index.rhtml +199 -0
  148. data/lib/ferret/browser/views/term/termdocs.rhtml +1 -0
  149. data/lib/ferret/browser/webrick.rb +14 -0
  150. data/lib/ferret/document.rb +130 -0
  151. data/lib/ferret/field_infos.rb +44 -0
  152. data/lib/ferret/index.rb +786 -0
  153. data/lib/ferret/number_tools.rb +157 -0
  154. data/lib/ferret_version.rb +3 -0
  155. data/setup.rb +1555 -0
  156. data/test/test_all.rb +5 -0
  157. data/test/test_helper.rb +24 -0
  158. data/test/threading/number_to_spoken.rb +132 -0
  159. data/test/threading/thread_safety_index_test.rb +79 -0
  160. data/test/threading/thread_safety_read_write_test.rb +76 -0
  161. data/test/threading/thread_safety_test.rb +133 -0
  162. data/test/unit/analysis/tc_analyzer.rb +548 -0
  163. data/test/unit/analysis/tc_token_stream.rb +646 -0
  164. data/test/unit/index/tc_index.rb +762 -0
  165. data/test/unit/index/tc_index_reader.rb +699 -0
  166. data/test/unit/index/tc_index_writer.rb +437 -0
  167. data/test/unit/index/th_doc.rb +315 -0
  168. data/test/unit/largefile/tc_largefile.rb +46 -0
  169. data/test/unit/query_parser/tc_query_parser.rb +238 -0
  170. data/test/unit/search/tc_filter.rb +135 -0
  171. data/test/unit/search/tc_fuzzy_query.rb +147 -0
  172. data/test/unit/search/tc_index_searcher.rb +61 -0
  173. data/test/unit/search/tc_multi_searcher.rb +128 -0
  174. data/test/unit/search/tc_multiple_search_requests.rb +58 -0
  175. data/test/unit/search/tc_search_and_sort.rb +179 -0
  176. data/test/unit/search/tc_sort.rb +49 -0
  177. data/test/unit/search/tc_sort_field.rb +27 -0
  178. data/test/unit/search/tc_spans.rb +190 -0
  179. data/test/unit/search/tm_searcher.rb +384 -0
  180. data/test/unit/store/tc_fs_store.rb +77 -0
  181. data/test/unit/store/tc_ram_store.rb +35 -0
  182. data/test/unit/store/tm_store.rb +34 -0
  183. data/test/unit/store/tm_store_lock.rb +68 -0
  184. data/test/unit/tc_document.rb +81 -0
  185. data/test/unit/ts_analysis.rb +2 -0
  186. data/test/unit/ts_index.rb +2 -0
  187. data/test/unit/ts_largefile.rb +4 -0
  188. data/test/unit/ts_query_parser.rb +2 -0
  189. data/test/unit/ts_search.rb +2 -0
  190. data/test/unit/ts_store.rb +2 -0
  191. data/test/unit/ts_utils.rb +2 -0
  192. data/test/unit/utils/tc_bit_vector.rb +295 -0
  193. data/test/unit/utils/tc_number_tools.rb +117 -0
  194. data/test/unit/utils/tc_priority_queue.rb +106 -0
  195. metadata +285 -0
@@ -0,0 +1,66 @@
1
+ #ifndef FRT_LANG_H
2
+ #define FRT_LANG_H
3
+
4
+ #define RUBY_BINDINGS 1
5
+
6
+ #include <stdarg.h>
7
+ #include <ruby.h>
8
+
9
+ #undef close
10
+ #undef rename
11
+ #undef read
12
+
13
+ #define frt_malloc xmalloc
14
+ #define frt_calloc(n) xcalloc(n, 1)
15
+ #define frt_realloc xrealloc
16
+
17
+
18
+ #ifdef FRT_HAS_ISO_VARARGS
19
+ /* C99-compliant compiler */
20
+
21
+ # define FRT_EXIT(...) frt_rb_raise(__FILE__, __LINE__, __func__, __VA_ARGS__)
22
+ extern void frt_rb_raise(const char *file, int line_num, const char *func,
23
+ const char *err_type, const char *fmt, ...);
24
+
25
+ # define V_FRT_EXIT(err_type, fmt, args) \
26
+ vfrt_rb_raise(__FILE__, __LINE__, __func__, err_type, fmt, args)
27
+ extern void vfrt_rb_raise(const char *file, int line_num, const char *func,
28
+ const char *err_type, const char *fmt, va_list args);
29
+
30
+ #elif defined(FRT_HAS_GNUC_VARARGS)
31
+ /* gcc has an extension */
32
+
33
+ # define FRT_EXIT(args...) frt_rb_raise(__FILE__, __LINE__, __func__, ##args)
34
+ extern void frt_rb_raise(const char *file, int line_num, const char *func,
35
+ const char *err_type, const char *fmt, ...);
36
+
37
+ # define V_FRT_EXIT(err_type, fmt, args) \
38
+ vfrt_rb_raise(__FILE__, __LINE__, __func__, err_type, fmt, args)
39
+ extern void vfrt_rb_raise(const char *file, int line_num, const char *func,
40
+ const char *err_type, const char *fmt, va_list args);
41
+ #else
42
+ /* Can't do VARARGS */
43
+
44
+ extern void FRT_EXIT(const char *err_type, const char *fmt, ...);
45
+ extern void V_FRT_EXIT(const char *err_type, const char *fmt, va_list args);
46
+ #endif
47
+
48
+ #ifdef RUBY_RUBY_H
49
+ # define FRT_RUBY_VERSION_1_9
50
+ #endif
51
+
52
+ // ruby 1.8 compat with 1.9 to avoid ifdefs
53
+ #if !defined RSTRING_LEN
54
+ #define RSTRING_LEN(a) RSTRING(a)->len
55
+ #endif
56
+ #if !defined RSTRING_PTR
57
+ #define RSTRING_PTR(a) RSTRING(a)->ptr
58
+ #endif
59
+ #if !defined RARRAY_LEN
60
+ #define RARRAY_LEN(a) RARRAY(a)->len
61
+ #endif
62
+ #if !defined RARRAY_PTR
63
+ #define RARRAY_PTR(a) RARRAY(a)->ptr
64
+ #endif
65
+
66
+ #endif
@@ -0,0 +1,92 @@
1
+
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+ #include "libstemmer.h"
5
+ #include "api.h"
6
+ #include "modules.h"
7
+
8
+ struct sb_stemmer {
9
+ struct SN_env * (*create)(void);
10
+ void (*close)(struct SN_env *);
11
+ int (*stem)(struct SN_env *);
12
+
13
+ struct SN_env * env;
14
+ };
15
+
16
+ extern const char **
17
+ sb_stemmer_list(void)
18
+ {
19
+ return algorithm_names;
20
+ }
21
+
22
+ static stemmer_encoding sb_getenc(const char * charenc)
23
+ {
24
+ struct stemmer_encoding * encoding;
25
+ if (charenc == NULL) return ENC_UTF_8;
26
+ for (encoding = encodings; encoding->name != 0; encoding++) {
27
+ if (strcmp(encoding->name, charenc) == 0) break;
28
+ }
29
+ if (encoding->name == NULL) return ENC_UNKNOWN;
30
+ return encoding->enc;
31
+ }
32
+
33
+ extern struct sb_stemmer *
34
+ sb_stemmer_new(const char * algorithm, const char * charenc)
35
+ {
36
+ stemmer_encoding enc;
37
+ struct stemmer_modules * module;
38
+ struct sb_stemmer * stemmer =
39
+ (struct sb_stemmer *) malloc(sizeof(struct sb_stemmer));
40
+ if (stemmer == NULL) return NULL;
41
+ enc = sb_getenc(charenc);
42
+ if (enc == ENC_UNKNOWN) return NULL;
43
+
44
+ for (module = modules; module->name != 0; module++) {
45
+ if (strcmp(module->name, algorithm) == 0 && module->enc == enc) break;
46
+ }
47
+ if (module->name == NULL) return NULL;
48
+
49
+ stemmer->create = module->create;
50
+ stemmer->close = module->close;
51
+ stemmer->stem = module->stem;
52
+
53
+ stemmer->env = stemmer->create();
54
+ if (stemmer->env == NULL)
55
+ {
56
+ sb_stemmer_delete(stemmer);
57
+ return NULL;
58
+ }
59
+
60
+ return stemmer;
61
+ }
62
+
63
+ void
64
+ sb_stemmer_delete(struct sb_stemmer * stemmer)
65
+ {
66
+ if (stemmer == 0) return;
67
+ if (stemmer->close == 0) return;
68
+ stemmer->close(stemmer->env);
69
+ stemmer->close = 0;
70
+ free(stemmer);
71
+ }
72
+
73
+ const sb_symbol *
74
+ sb_stemmer_stem(struct sb_stemmer * stemmer, const sb_symbol * word, int size)
75
+ {
76
+ int ret;
77
+ if (SN_set_current(stemmer->env, size, (const symbol *)(word)))
78
+ {
79
+ stemmer->env->l = 0;
80
+ return NULL;
81
+ }
82
+ ret = stemmer->stem(stemmer->env);
83
+ if (ret < 0) return NULL;
84
+ stemmer->env->p[stemmer->env->l] = 0;
85
+ return (const sb_symbol *)(stemmer->env->p);
86
+ }
87
+
88
+ int
89
+ sb_stemmer_length(struct sb_stemmer * stemmer)
90
+ {
91
+ return stemmer->env->l;
92
+ }
@@ -0,0 +1,79 @@
1
+
2
+ /* Make header file work when included from C++ */
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ struct sb_stemmer;
8
+ typedef unsigned char sb_symbol;
9
+
10
+ /* FIXME - should be able to get a version number for each stemming
11
+ * algorithm (which will be incremented each time the output changes). */
12
+
13
+ /** Returns an array of the names of the available stemming algorithms.
14
+ * Note that these are the canonical names - aliases (ie, other names for
15
+ * the same algorithm) will not be included in the list.
16
+ * The list is terminated with a null pointer.
17
+ *
18
+ * The list must not be modified in any way.
19
+ */
20
+ const char ** sb_stemmer_list(void);
21
+
22
+ /** Create a new stemmer object, using the specified algorithm, for the
23
+ * specified character encoding.
24
+ *
25
+ * All algorithms will usually be available in UTF-8, but may also be
26
+ * available in other character encodings.
27
+ *
28
+ * @param algorithm The algorithm name. This is either the english
29
+ * name of the algorithm, or the 2 or 3 letter ISO 639 codes for the
30
+ * language. Note that case is significant in this parameter - the
31
+ * value should be supplied in lower case.
32
+ *
33
+ * @param charenc The character encoding. NULL may be passed as
34
+ * this value, in which case UTF-8 encoding will be assumed. Otherwise,
35
+ * the argument may be one of "UTF_8", "ISO_8859_1" (ie, Latin 1),
36
+ * "CP850" (ie, MS-DOS Latin 1) or "KOI8_R" (Russian). Note that
37
+ * case is significant in this parameter.
38
+ *
39
+ * @return NULL if the specified algorithm is not recognised, or the
40
+ * algorithm is not available for the requested encoding. Otherwise,
41
+ * returns a pointer to a newly created stemmer for the requested algorithm.
42
+ * The returned pointer must be deleted by calling sb_stemmer_delete().
43
+ *
44
+ * @note NULL will also be returned if an out of memory error occurs.
45
+ */
46
+ struct sb_stemmer * sb_stemmer_new(const char * algorithm, const char * charenc);
47
+
48
+ /** Delete a stemmer object.
49
+ *
50
+ * This frees all resources allocated for the stemmer. After calling
51
+ * this function, the supplied stemmer may no longer be used in any way.
52
+ *
53
+ * It is safe to pass a null pointer to this function - this will have
54
+ * no effect.
55
+ */
56
+ void sb_stemmer_delete(struct sb_stemmer * stemmer);
57
+
58
+ /** Stem a word.
59
+ *
60
+ * The return value is owned by the stemmer - it must not be freed or
61
+ * modified, and it will become invalid when the stemmer is called again,
62
+ * or if the stemmer is freed.
63
+ *
64
+ * The length of the return value can be obtained using sb_stemmer_length().
65
+ *
66
+ * If an out-of-memory error occurs, this will return NULL.
67
+ */
68
+ const sb_symbol * sb_stemmer_stem(struct sb_stemmer * stemmer,
69
+ const sb_symbol * word, int size);
70
+
71
+ /** Get the length of the result of the last stemmed word.
72
+ * This should not be called before sb_stemmer_stem() has been called.
73
+ */
74
+ int sb_stemmer_length(struct sb_stemmer * stemmer);
75
+
76
+ #ifdef __cplusplus
77
+ }
78
+ #endif
79
+
@@ -0,0 +1,87 @@
1
+ #include "global.h"
2
+ #include "mempool.h"
3
+ #include <string.h>
4
+
5
+ MemoryPool *mp_new_capa(int chuck_size, int init_buf_capa)
6
+ {
7
+ MemoryPool *mp = ALLOC(MemoryPool);
8
+ mp->chunk_size = chuck_size;
9
+ mp->buf_capa = init_buf_capa;
10
+ mp->buffers = ALLOC_N(char *, init_buf_capa);
11
+
12
+ mp->buffers[0] = mp->curr_buffer = emalloc(mp->chunk_size);
13
+ mp->buf_alloc = 1;
14
+ mp->buf_pointer = 0;
15
+ mp->pointer = 0;
16
+ return mp;
17
+ }
18
+
19
+ MemoryPool *mp_new()
20
+ {
21
+ return mp_new_capa(MP_BUF_SIZE, MP_INIT_CAPA);
22
+ }
23
+
24
+ INLINE void *mp_alloc(MemoryPool *mp, int size)
25
+ {
26
+ char *p;
27
+ p = mp->curr_buffer + mp->pointer;
28
+ #if defined POSH_OS_SOLARIS || defined POSH_OS_SUNOS
29
+ size = (((size - 1) >> 3) + 1) << 3;
30
+ #endif
31
+ mp->pointer += size;
32
+
33
+ if (mp->pointer > mp->chunk_size) {
34
+ mp->buf_pointer++;
35
+ if (mp->buf_pointer >= mp->buf_alloc) {
36
+ mp->buf_alloc++;
37
+ if (mp->buf_alloc >= mp->buf_capa) {
38
+ mp->buf_capa <<= 1;
39
+ REALLOC_N(mp->buffers, char *, mp->buf_capa);
40
+ }
41
+ mp->buffers[mp->buf_pointer] = emalloc(mp->chunk_size);
42
+ }
43
+ p = mp->curr_buffer = mp->buffers[mp->buf_pointer];
44
+ mp->pointer = size;
45
+ }
46
+ return p;
47
+ }
48
+
49
+ char *mp_strdup(MemoryPool *mp, const char *str)
50
+ {
51
+ int len = strlen(str) + 1;
52
+ return memcpy(mp_alloc(mp, len), str, len);
53
+ }
54
+
55
+ char *mp_strndup(MemoryPool *mp, const char *str, int len)
56
+ {
57
+ char *s = memcpy(mp_alloc(mp, len + 1), str, len);
58
+ s[len] = '\0';
59
+ return s;
60
+ }
61
+
62
+ void *mp_memdup(MemoryPool *mp, const void *p, int len)
63
+ {
64
+ return memcpy(mp_alloc(mp, len), p, len);
65
+ }
66
+
67
+ int mp_used(MemoryPool *mp)
68
+ {
69
+ return mp->buf_pointer * mp->chunk_size + mp->pointer;
70
+ }
71
+
72
+ void mp_reset(MemoryPool *mp)
73
+ {
74
+ mp->buf_pointer = 0;
75
+ mp->pointer = 0;
76
+ mp->curr_buffer = mp->buffers[0];
77
+ }
78
+
79
+ void mp_destroy(MemoryPool *mp)
80
+ {
81
+ int i;
82
+ for (i = 0; i < mp->buf_alloc; i++) {
83
+ free(mp->buffers[i]);
84
+ }
85
+ free(mp->buffers);
86
+ free(mp);
87
+ }
@@ -0,0 +1,35 @@
1
+ #ifndef FRT_MEM_POOL_H
2
+ #define FRT_MEM_POOL_H
3
+
4
+ #define MP_BUF_SIZE 65536
5
+ #define MP_INIT_CAPA 4
6
+
7
+ typedef struct MemoryPool {
8
+ int buf_alloc;
9
+ int buf_capa;
10
+ int buf_pointer;
11
+ int pointer;
12
+ int chunk_size;
13
+ char *curr_buffer;
14
+ char **buffers;
15
+ } MemoryPool;
16
+
17
+ extern MemoryPool *mp_new();
18
+ extern MemoryPool *mp_new_capa(int chunk_size, int init_capa);
19
+ extern INLINE void *mp_alloc(MemoryPool *mp, int size);
20
+ extern void mp_reset(MemoryPool *mp);
21
+ extern void mp_destroy(MemoryPool *mp);
22
+ extern char *mp_strdup(MemoryPool *mp, const char *str);
23
+ extern char *mp_strndup(MemoryPool *mp, const char *str, int len);
24
+ extern void *mp_memdup(MemoryPool *mp, const void *p, int len);
25
+ extern int mp_used(MemoryPool *mp);
26
+
27
+ #define MP_ALLOC_N(mp,type,n) (type *)mp_alloc(mp, sizeof(type)*(n))
28
+ #define MP_ALLOC(mp,type) (type *)mp_alloc(mp, sizeof(type))
29
+
30
+ #define MP_ALLOC_AND_ZERO(mp,type)\
31
+ (type*)memset(mp_alloc(mp, sizeof(type)), 0, sizeof(type))
32
+ #define MP_ALLOC_AND_ZERO_N(mp,type,n)\
33
+ (type*)ZEROSET_N(mp_alloc(mp, sizeof(type)*(n)), type, n)
34
+
35
+ #endif
@@ -0,0 +1,162 @@
1
+ /* libstemmer/modules.h: List of stemming modules.
2
+ *
3
+ * This file is generated by mkmodules.pl from a list of module names.
4
+ * Do not edit manually.
5
+ *
6
+ * Modules included by this file are: danish, dutch, english, finnish, french,
7
+ * german, italian, norwegian, porter, portuguese, russian, spanish, swedish
8
+ */
9
+
10
+ #include "stem_ISO_8859_1_danish.h"
11
+ #include "stem_UTF_8_danish.h"
12
+ #include "stem_ISO_8859_1_dutch.h"
13
+ #include "stem_UTF_8_dutch.h"
14
+ #include "stem_ISO_8859_1_english.h"
15
+ #include "stem_UTF_8_english.h"
16
+ #include "stem_ISO_8859_1_finnish.h"
17
+ #include "stem_UTF_8_finnish.h"
18
+ #include "stem_ISO_8859_1_french.h"
19
+ #include "stem_UTF_8_french.h"
20
+ #include "stem_ISO_8859_1_german.h"
21
+ #include "stem_UTF_8_german.h"
22
+ #include "stem_ISO_8859_1_italian.h"
23
+ #include "stem_UTF_8_italian.h"
24
+ #include "stem_ISO_8859_1_norwegian.h"
25
+ #include "stem_UTF_8_norwegian.h"
26
+ #include "stem_ISO_8859_1_porter.h"
27
+ #include "stem_UTF_8_porter.h"
28
+ #include "stem_ISO_8859_1_portuguese.h"
29
+ #include "stem_UTF_8_portuguese.h"
30
+ #include "stem_KOI8_R_russian.h"
31
+ #include "stem_UTF_8_russian.h"
32
+ #include "stem_ISO_8859_1_spanish.h"
33
+ #include "stem_UTF_8_spanish.h"
34
+ #include "stem_ISO_8859_1_swedish.h"
35
+ #include "stem_UTF_8_swedish.h"
36
+
37
+ typedef enum {
38
+ ENC_UNKNOWN,
39
+ ENC_ISO_8859_1,
40
+ ENC_KOI8_R,
41
+ ENC_UTF_8
42
+ } stemmer_encoding;
43
+
44
+ struct stemmer_encoding {
45
+ const char * name;
46
+ stemmer_encoding enc;
47
+ };
48
+ static struct stemmer_encoding encodings[] = {
49
+ {"ISO_8859_1", ENC_ISO_8859_1},
50
+ {"KOI8_R", ENC_KOI8_R},
51
+ {"UTF_8", ENC_UTF_8},
52
+ {0,0}
53
+ };
54
+
55
+ struct stemmer_modules {
56
+ const char * name;
57
+ stemmer_encoding enc;
58
+ struct SN_env * (*create)(void);
59
+ void (*close)(struct SN_env *);
60
+ int (*stem)(struct SN_env *);
61
+ };
62
+ static struct stemmer_modules modules[] = {
63
+ {"da", ENC_ISO_8859_1, danish_ISO_8859_1_create_env, danish_ISO_8859_1_close_env, danish_ISO_8859_1_stem},
64
+ {"da", ENC_UTF_8, danish_UTF_8_create_env, danish_UTF_8_close_env, danish_UTF_8_stem},
65
+ {"dan", ENC_ISO_8859_1, danish_ISO_8859_1_create_env, danish_ISO_8859_1_close_env, danish_ISO_8859_1_stem},
66
+ {"dan", ENC_UTF_8, danish_UTF_8_create_env, danish_UTF_8_close_env, danish_UTF_8_stem},
67
+ {"danish", ENC_ISO_8859_1, danish_ISO_8859_1_create_env, danish_ISO_8859_1_close_env, danish_ISO_8859_1_stem},
68
+ {"danish", ENC_UTF_8, danish_UTF_8_create_env, danish_UTF_8_close_env, danish_UTF_8_stem},
69
+ {"de", ENC_ISO_8859_1, german_ISO_8859_1_create_env, german_ISO_8859_1_close_env, german_ISO_8859_1_stem},
70
+ {"de", ENC_UTF_8, german_UTF_8_create_env, german_UTF_8_close_env, german_UTF_8_stem},
71
+ {"deu", ENC_ISO_8859_1, german_ISO_8859_1_create_env, german_ISO_8859_1_close_env, german_ISO_8859_1_stem},
72
+ {"deu", ENC_UTF_8, german_UTF_8_create_env, german_UTF_8_close_env, german_UTF_8_stem},
73
+ {"dut", ENC_ISO_8859_1, dutch_ISO_8859_1_create_env, dutch_ISO_8859_1_close_env, dutch_ISO_8859_1_stem},
74
+ {"dut", ENC_UTF_8, dutch_UTF_8_create_env, dutch_UTF_8_close_env, dutch_UTF_8_stem},
75
+ {"dutch", ENC_ISO_8859_1, dutch_ISO_8859_1_create_env, dutch_ISO_8859_1_close_env, dutch_ISO_8859_1_stem},
76
+ {"dutch", ENC_UTF_8, dutch_UTF_8_create_env, dutch_UTF_8_close_env, dutch_UTF_8_stem},
77
+ {"en", ENC_ISO_8859_1, english_ISO_8859_1_create_env, english_ISO_8859_1_close_env, english_ISO_8859_1_stem},
78
+ {"en", ENC_UTF_8, english_UTF_8_create_env, english_UTF_8_close_env, english_UTF_8_stem},
79
+ {"eng", ENC_ISO_8859_1, english_ISO_8859_1_create_env, english_ISO_8859_1_close_env, english_ISO_8859_1_stem},
80
+ {"eng", ENC_UTF_8, english_UTF_8_create_env, english_UTF_8_close_env, english_UTF_8_stem},
81
+ {"english", ENC_ISO_8859_1, english_ISO_8859_1_create_env, english_ISO_8859_1_close_env, english_ISO_8859_1_stem},
82
+ {"english", ENC_UTF_8, english_UTF_8_create_env, english_UTF_8_close_env, english_UTF_8_stem},
83
+ {"es", ENC_ISO_8859_1, spanish_ISO_8859_1_create_env, spanish_ISO_8859_1_close_env, spanish_ISO_8859_1_stem},
84
+ {"es", ENC_UTF_8, spanish_UTF_8_create_env, spanish_UTF_8_close_env, spanish_UTF_8_stem},
85
+ {"esl", ENC_ISO_8859_1, spanish_ISO_8859_1_create_env, spanish_ISO_8859_1_close_env, spanish_ISO_8859_1_stem},
86
+ {"esl", ENC_UTF_8, spanish_UTF_8_create_env, spanish_UTF_8_close_env, spanish_UTF_8_stem},
87
+ {"fi", ENC_ISO_8859_1, finnish_ISO_8859_1_create_env, finnish_ISO_8859_1_close_env, finnish_ISO_8859_1_stem},
88
+ {"fi", ENC_UTF_8, finnish_UTF_8_create_env, finnish_UTF_8_close_env, finnish_UTF_8_stem},
89
+ {"fin", ENC_ISO_8859_1, finnish_ISO_8859_1_create_env, finnish_ISO_8859_1_close_env, finnish_ISO_8859_1_stem},
90
+ {"fin", ENC_UTF_8, finnish_UTF_8_create_env, finnish_UTF_8_close_env, finnish_UTF_8_stem},
91
+ {"finnish", ENC_ISO_8859_1, finnish_ISO_8859_1_create_env, finnish_ISO_8859_1_close_env, finnish_ISO_8859_1_stem},
92
+ {"finnish", ENC_UTF_8, finnish_UTF_8_create_env, finnish_UTF_8_close_env, finnish_UTF_8_stem},
93
+ {"fr", ENC_ISO_8859_1, french_ISO_8859_1_create_env, french_ISO_8859_1_close_env, french_ISO_8859_1_stem},
94
+ {"fr", ENC_UTF_8, french_UTF_8_create_env, french_UTF_8_close_env, french_UTF_8_stem},
95
+ {"fra", ENC_ISO_8859_1, french_ISO_8859_1_create_env, french_ISO_8859_1_close_env, french_ISO_8859_1_stem},
96
+ {"fra", ENC_UTF_8, french_UTF_8_create_env, french_UTF_8_close_env, french_UTF_8_stem},
97
+ {"fre", ENC_ISO_8859_1, french_ISO_8859_1_create_env, french_ISO_8859_1_close_env, french_ISO_8859_1_stem},
98
+ {"fre", ENC_UTF_8, french_UTF_8_create_env, french_UTF_8_close_env, french_UTF_8_stem},
99
+ {"french", ENC_ISO_8859_1, french_ISO_8859_1_create_env, french_ISO_8859_1_close_env, french_ISO_8859_1_stem},
100
+ {"french", ENC_UTF_8, french_UTF_8_create_env, french_UTF_8_close_env, french_UTF_8_stem},
101
+ {"ger", ENC_ISO_8859_1, german_ISO_8859_1_create_env, german_ISO_8859_1_close_env, german_ISO_8859_1_stem},
102
+ {"ger", ENC_UTF_8, german_UTF_8_create_env, german_UTF_8_close_env, german_UTF_8_stem},
103
+ {"german", ENC_ISO_8859_1, german_ISO_8859_1_create_env, german_ISO_8859_1_close_env, german_ISO_8859_1_stem},
104
+ {"german", ENC_UTF_8, german_UTF_8_create_env, german_UTF_8_close_env, german_UTF_8_stem},
105
+ {"it", ENC_ISO_8859_1, italian_ISO_8859_1_create_env, italian_ISO_8859_1_close_env, italian_ISO_8859_1_stem},
106
+ {"it", ENC_UTF_8, italian_UTF_8_create_env, italian_UTF_8_close_env, italian_UTF_8_stem},
107
+ {"ita", ENC_ISO_8859_1, italian_ISO_8859_1_create_env, italian_ISO_8859_1_close_env, italian_ISO_8859_1_stem},
108
+ {"ita", ENC_UTF_8, italian_UTF_8_create_env, italian_UTF_8_close_env, italian_UTF_8_stem},
109
+ {"italian", ENC_ISO_8859_1, italian_ISO_8859_1_create_env, italian_ISO_8859_1_close_env, italian_ISO_8859_1_stem},
110
+ {"italian", ENC_UTF_8, italian_UTF_8_create_env, italian_UTF_8_close_env, italian_UTF_8_stem},
111
+ {"nl", ENC_ISO_8859_1, dutch_ISO_8859_1_create_env, dutch_ISO_8859_1_close_env, dutch_ISO_8859_1_stem},
112
+ {"nl", ENC_UTF_8, dutch_UTF_8_create_env, dutch_UTF_8_close_env, dutch_UTF_8_stem},
113
+ {"nld", ENC_ISO_8859_1, dutch_ISO_8859_1_create_env, dutch_ISO_8859_1_close_env, dutch_ISO_8859_1_stem},
114
+ {"nld", ENC_UTF_8, dutch_UTF_8_create_env, dutch_UTF_8_close_env, dutch_UTF_8_stem},
115
+ {"no", ENC_ISO_8859_1, norwegian_ISO_8859_1_create_env, norwegian_ISO_8859_1_close_env, norwegian_ISO_8859_1_stem},
116
+ {"no", ENC_UTF_8, norwegian_UTF_8_create_env, norwegian_UTF_8_close_env, norwegian_UTF_8_stem},
117
+ {"nor", ENC_ISO_8859_1, norwegian_ISO_8859_1_create_env, norwegian_ISO_8859_1_close_env, norwegian_ISO_8859_1_stem},
118
+ {"nor", ENC_UTF_8, norwegian_UTF_8_create_env, norwegian_UTF_8_close_env, norwegian_UTF_8_stem},
119
+ {"norwegian", ENC_ISO_8859_1, norwegian_ISO_8859_1_create_env, norwegian_ISO_8859_1_close_env, norwegian_ISO_8859_1_stem},
120
+ {"norwegian", ENC_UTF_8, norwegian_UTF_8_create_env, norwegian_UTF_8_close_env, norwegian_UTF_8_stem},
121
+ {"por", ENC_ISO_8859_1, portuguese_ISO_8859_1_create_env, portuguese_ISO_8859_1_close_env, portuguese_ISO_8859_1_stem},
122
+ {"por", ENC_UTF_8, portuguese_UTF_8_create_env, portuguese_UTF_8_close_env, portuguese_UTF_8_stem},
123
+ {"porter", ENC_ISO_8859_1, porter_ISO_8859_1_create_env, porter_ISO_8859_1_close_env, porter_ISO_8859_1_stem},
124
+ {"porter", ENC_UTF_8, porter_UTF_8_create_env, porter_UTF_8_close_env, porter_UTF_8_stem},
125
+ {"portuguese", ENC_ISO_8859_1, portuguese_ISO_8859_1_create_env, portuguese_ISO_8859_1_close_env, portuguese_ISO_8859_1_stem},
126
+ {"portuguese", ENC_UTF_8, portuguese_UTF_8_create_env, portuguese_UTF_8_close_env, portuguese_UTF_8_stem},
127
+ {"pt", ENC_ISO_8859_1, portuguese_ISO_8859_1_create_env, portuguese_ISO_8859_1_close_env, portuguese_ISO_8859_1_stem},
128
+ {"pt", ENC_UTF_8, portuguese_UTF_8_create_env, portuguese_UTF_8_close_env, portuguese_UTF_8_stem},
129
+ {"ru", ENC_KOI8_R, russian_KOI8_R_create_env, russian_KOI8_R_close_env, russian_KOI8_R_stem},
130
+ {"ru", ENC_UTF_8, russian_UTF_8_create_env, russian_UTF_8_close_env, russian_UTF_8_stem},
131
+ {"rus", ENC_KOI8_R, russian_KOI8_R_create_env, russian_KOI8_R_close_env, russian_KOI8_R_stem},
132
+ {"rus", ENC_UTF_8, russian_UTF_8_create_env, russian_UTF_8_close_env, russian_UTF_8_stem},
133
+ {"russian", ENC_KOI8_R, russian_KOI8_R_create_env, russian_KOI8_R_close_env, russian_KOI8_R_stem},
134
+ {"russian", ENC_UTF_8, russian_UTF_8_create_env, russian_UTF_8_close_env, russian_UTF_8_stem},
135
+ {"spa", ENC_ISO_8859_1, spanish_ISO_8859_1_create_env, spanish_ISO_8859_1_close_env, spanish_ISO_8859_1_stem},
136
+ {"spa", ENC_UTF_8, spanish_UTF_8_create_env, spanish_UTF_8_close_env, spanish_UTF_8_stem},
137
+ {"spanish", ENC_ISO_8859_1, spanish_ISO_8859_1_create_env, spanish_ISO_8859_1_close_env, spanish_ISO_8859_1_stem},
138
+ {"spanish", ENC_UTF_8, spanish_UTF_8_create_env, spanish_UTF_8_close_env, spanish_UTF_8_stem},
139
+ {"sv", ENC_ISO_8859_1, swedish_ISO_8859_1_create_env, swedish_ISO_8859_1_close_env, swedish_ISO_8859_1_stem},
140
+ {"sv", ENC_UTF_8, swedish_UTF_8_create_env, swedish_UTF_8_close_env, swedish_UTF_8_stem},
141
+ {"swe", ENC_ISO_8859_1, swedish_ISO_8859_1_create_env, swedish_ISO_8859_1_close_env, swedish_ISO_8859_1_stem},
142
+ {"swe", ENC_UTF_8, swedish_UTF_8_create_env, swedish_UTF_8_close_env, swedish_UTF_8_stem},
143
+ {"swedish", ENC_ISO_8859_1, swedish_ISO_8859_1_create_env, swedish_ISO_8859_1_close_env, swedish_ISO_8859_1_stem},
144
+ {"swedish", ENC_UTF_8, swedish_UTF_8_create_env, swedish_UTF_8_close_env, swedish_UTF_8_stem},
145
+ {0,0,0,0,0}
146
+ };
147
+ static const char * algorithm_names[] = {
148
+ "danish",
149
+ "dutch",
150
+ "english",
151
+ "finnish",
152
+ "french",
153
+ "german",
154
+ "italian",
155
+ "norwegian",
156
+ "porter",
157
+ "portuguese",
158
+ "russian",
159
+ "spanish",
160
+ "swedish",
161
+ 0
162
+ };