1 /* -*- c-basic-offset: 2 -*- */ 2 /* 3 Copyright(C) 2015-2016 Brazil 4 Copyright(C) 2020 Sutou Kouhei <kou@clear-code.com> 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public 8 License version 2.1 as published by the Free Software Foundation. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 module groonga_d.scorer; 20 21 22 private static import groonga_d.groonga; 23 24 extern(C): 25 nothrow @nogc: 26 27 /+ 28 #include <groonga/plugin.h> 29 +/ 30 31 extern struct _grn_scorer_matched_record; 32 alias grn_scorer_matched_record = _grn_scorer_matched_record; 33 34 //GRN_API 35 groonga_d.groonga.grn_obj* grn_scorer_matched_record_get_table(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 36 37 //GRN_API 38 groonga_d.groonga.grn_obj* grn_scorer_matched_record_get_lexicon(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 39 40 //GRN_API 41 groonga_d.groonga.grn_id grn_scorer_matched_record_get_id(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 42 43 //GRN_API 44 groonga_d.groonga.grn_obj* grn_scorer_matched_record_get_terms(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 45 46 //GRN_API 47 groonga_d.groonga.grn_obj* grn_scorer_matched_record_get_term_weights(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 48 49 //GRN_API 50 uint grn_scorer_matched_record_get_total_term_weights(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 51 52 //GRN_API 53 ulong grn_scorer_matched_record_get_n_documents(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 54 55 //GRN_API 56 uint grn_scorer_matched_record_get_n_occurrences(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 57 58 //GRN_API 59 ulong grn_scorer_matched_record_get_n_candidates(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 60 61 //GRN_API 62 uint grn_scorer_matched_record_get_n_tokens(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 63 64 //GRN_API 65 int grn_scorer_matched_record_get_weight(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 66 67 //GRN_API 68 groonga_d.groonga.grn_obj* grn_scorer_matched_record_get_arg(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record, uint i); 69 70 //GRN_API 71 uint grn_scorer_matched_record_get_n_args(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 72 73 74 //typedef double grn_scorer_score_func(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 75 alias grn_scorer_score_func = extern (C) nothrow @nogc double function(groonga_d.groonga.grn_ctx* ctx, grn_scorer_matched_record* record); 76 77 /* 78 grn_scorer_register() registers a plugin to the database which is 79 associated with `ctx'. `scorer_name_ptr' and `scorer_name_length' specify the 80 plugin name. Alphabetic letters ('A'-'Z' and 'a'-'z'), digits ('0'-'9') and 81 an underscore ('_') are capable characters. 82 83 `score' is called for scoring matched records one by one. 84 85 grn_scorer_register() returns GRN_SUCCESS on success, an error 86 code on failure. 87 */ 88 89 //GRN_PLUGIN_EXPORT 90 export groonga_d.groonga.grn_rc grn_scorer_register(groonga_d.groonga.grn_ctx* ctx, const (char)* scorer_name_ptr, int scorer_name_length, grn_scorer_score_func* score);