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