chaine 3.13.1__cp313-cp313-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chaine might be problematic. Click here for more details.
- chaine/__init__.py +2 -0
- chaine/_core/crf.cp313-win32.pyd +0 -0
- chaine/_core/crf.cpp +19854 -0
- chaine/_core/crf.pyx +271 -0
- chaine/_core/crfsuite/COPYING +27 -0
- chaine/_core/crfsuite/README +183 -0
- chaine/_core/crfsuite/include/crfsuite.h +1077 -0
- chaine/_core/crfsuite/include/crfsuite.hpp +649 -0
- chaine/_core/crfsuite/include/crfsuite_api.hpp +406 -0
- chaine/_core/crfsuite/include/os.h +65 -0
- chaine/_core/crfsuite/lib/cqdb/COPYING +28 -0
- chaine/_core/crfsuite/lib/cqdb/include/cqdb.h +518 -0
- chaine/_core/crfsuite/lib/cqdb/src/cqdb.c +639 -0
- chaine/_core/crfsuite/lib/cqdb/src/lookup3.c +1271 -0
- chaine/_core/crfsuite/lib/cqdb/src/main.c +184 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d.h +354 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_context.c +788 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_encode.c +1020 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_feature.c +382 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_model.c +1085 -0
- chaine/_core/crfsuite/lib/crf/src/crf1d_tag.c +582 -0
- chaine/_core/crfsuite/lib/crf/src/crfsuite.c +500 -0
- chaine/_core/crfsuite/lib/crf/src/crfsuite_internal.h +233 -0
- chaine/_core/crfsuite/lib/crf/src/crfsuite_train.c +302 -0
- chaine/_core/crfsuite/lib/crf/src/dataset.c +115 -0
- chaine/_core/crfsuite/lib/crf/src/dictionary.c +127 -0
- chaine/_core/crfsuite/lib/crf/src/holdout.c +83 -0
- chaine/_core/crfsuite/lib/crf/src/json.c +1497 -0
- chaine/_core/crfsuite/lib/crf/src/json.h +120 -0
- chaine/_core/crfsuite/lib/crf/src/logging.c +85 -0
- chaine/_core/crfsuite/lib/crf/src/logging.h +49 -0
- chaine/_core/crfsuite/lib/crf/src/params.c +370 -0
- chaine/_core/crfsuite/lib/crf/src/params.h +84 -0
- chaine/_core/crfsuite/lib/crf/src/quark.c +180 -0
- chaine/_core/crfsuite/lib/crf/src/quark.h +46 -0
- chaine/_core/crfsuite/lib/crf/src/rumavl.c +1178 -0
- chaine/_core/crfsuite/lib/crf/src/rumavl.h +144 -0
- chaine/_core/crfsuite/lib/crf/src/train_arow.c +409 -0
- chaine/_core/crfsuite/lib/crf/src/train_averaged_perceptron.c +237 -0
- chaine/_core/crfsuite/lib/crf/src/train_l2sgd.c +491 -0
- chaine/_core/crfsuite/lib/crf/src/train_lbfgs.c +323 -0
- chaine/_core/crfsuite/lib/crf/src/train_passive_aggressive.c +442 -0
- chaine/_core/crfsuite/lib/crf/src/vecmath.h +360 -0
- chaine/_core/crfsuite/swig/crfsuite.cpp +1 -0
- chaine/_core/crfsuite_api.pxd +67 -0
- chaine/_core/liblbfgs/COPYING +22 -0
- chaine/_core/liblbfgs/README +71 -0
- chaine/_core/liblbfgs/include/lbfgs.h +745 -0
- chaine/_core/liblbfgs/lib/arithmetic_ansi.h +142 -0
- chaine/_core/liblbfgs/lib/arithmetic_sse_double.h +303 -0
- chaine/_core/liblbfgs/lib/arithmetic_sse_float.h +312 -0
- chaine/_core/liblbfgs/lib/lbfgs.c +1531 -0
- chaine/_core/tagger_wrapper.hpp +58 -0
- chaine/_core/trainer_wrapper.cpp +32 -0
- chaine/_core/trainer_wrapper.hpp +26 -0
- chaine/crf.py +505 -0
- chaine/logging.py +214 -0
- chaine/optimization/__init__.py +10 -0
- chaine/optimization/metrics.py +129 -0
- chaine/optimization/spaces.py +394 -0
- chaine/optimization/trial.py +103 -0
- chaine/optimization/utils.py +119 -0
- chaine/training.py +184 -0
- chaine/typing.py +18 -0
- chaine/validation.py +43 -0
- chaine-3.13.1.dist-info/METADATA +348 -0
- chaine-3.13.1.dist-info/RECORD +68 -0
- chaine-3.13.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Quark object.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2007-2010, Naoaki Okazaki
|
|
5
|
+
* All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
|
8
|
+
* modification, are permitted provided that the following conditions are met:
|
|
9
|
+
* * Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* * Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
|
14
|
+
* * Neither the names of the authors nor the names of its contributors
|
|
15
|
+
* may be used to endorse or promote products derived from this
|
|
16
|
+
* software without specific prior written permission.
|
|
17
|
+
*
|
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
19
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
20
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
21
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
22
|
+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
23
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
24
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
25
|
+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
26
|
+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
27
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
28
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/* $Id$ */
|
|
32
|
+
|
|
33
|
+
#include "os.h"
|
|
34
|
+
#include <stdlib.h>
|
|
35
|
+
#include <string.h>
|
|
36
|
+
#include "rumavl.h"
|
|
37
|
+
#include "quark.h"
|
|
38
|
+
|
|
39
|
+
typedef struct
|
|
40
|
+
{
|
|
41
|
+
char *str;
|
|
42
|
+
int qid;
|
|
43
|
+
} record_t;
|
|
44
|
+
|
|
45
|
+
struct tag_quark
|
|
46
|
+
{
|
|
47
|
+
int num;
|
|
48
|
+
int max;
|
|
49
|
+
RUMAVL *string_to_id;
|
|
50
|
+
char **id_to_string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
static int keycmp(const void *_x, const void *_y, size_t n, void *udata)
|
|
54
|
+
{
|
|
55
|
+
const record_t *x = (const record_t *)_x;
|
|
56
|
+
const record_t *y = (const record_t *)_y;
|
|
57
|
+
return strcmp(x->str, y->str);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static int owcb(RUMAVL *tree, RUMAVL_NODE *n, void *_x, const void *_y, void *udata)
|
|
61
|
+
{
|
|
62
|
+
record_t *x = (record_t *)_x;
|
|
63
|
+
free(x->str);
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static int delcb(RUMAVL *tree, RUMAVL_NODE *n, void *_record, void *udata)
|
|
68
|
+
{
|
|
69
|
+
record_t *record = (record_t *)_record;
|
|
70
|
+
free(record->str);
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
quark_t *quark_new()
|
|
75
|
+
{
|
|
76
|
+
quark_t *qrk = (quark_t *)malloc(sizeof(quark_t));
|
|
77
|
+
if (qrk != NULL)
|
|
78
|
+
{
|
|
79
|
+
qrk->num = 0;
|
|
80
|
+
qrk->max = 0;
|
|
81
|
+
qrk->string_to_id = rumavl_new(sizeof(record_t), keycmp, NULL, NULL);
|
|
82
|
+
if (qrk->string_to_id != NULL)
|
|
83
|
+
{
|
|
84
|
+
*rumavl_delcb(qrk->string_to_id) = delcb;
|
|
85
|
+
*rumavl_owcb(qrk->string_to_id) = owcb;
|
|
86
|
+
}
|
|
87
|
+
qrk->id_to_string = NULL;
|
|
88
|
+
}
|
|
89
|
+
return qrk;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void quark_delete(quark_t *qrk)
|
|
93
|
+
{
|
|
94
|
+
if (qrk != NULL)
|
|
95
|
+
{
|
|
96
|
+
rumavl_destroy(qrk->string_to_id);
|
|
97
|
+
free(qrk->id_to_string);
|
|
98
|
+
free(qrk);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
int quark_get(quark_t *qrk, const char *str)
|
|
103
|
+
{
|
|
104
|
+
record_t key, *record = NULL;
|
|
105
|
+
|
|
106
|
+
key.str = (char *)str;
|
|
107
|
+
record = (record_t *)rumavl_find(qrk->string_to_id, &key);
|
|
108
|
+
if (record == NULL)
|
|
109
|
+
{
|
|
110
|
+
char *newstr = (char *)malloc(strlen(str) + 1);
|
|
111
|
+
if (newstr != NULL)
|
|
112
|
+
{
|
|
113
|
+
strcpy(newstr, str);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (qrk->max <= qrk->num)
|
|
117
|
+
{
|
|
118
|
+
qrk->max = (qrk->max + 1) * 2;
|
|
119
|
+
qrk->id_to_string = (char **)realloc(qrk->id_to_string, sizeof(char *) * qrk->max);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
qrk->id_to_string[qrk->num] = newstr;
|
|
123
|
+
key.str = newstr;
|
|
124
|
+
key.qid = qrk->num;
|
|
125
|
+
rumavl_insert(qrk->string_to_id, &key);
|
|
126
|
+
|
|
127
|
+
++qrk->num;
|
|
128
|
+
return key.qid;
|
|
129
|
+
}
|
|
130
|
+
else
|
|
131
|
+
{
|
|
132
|
+
return record->qid;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
int quark_to_id(quark_t *qrk, const char *str)
|
|
137
|
+
{
|
|
138
|
+
record_t key, *record = NULL;
|
|
139
|
+
|
|
140
|
+
key.str = (char *)str;
|
|
141
|
+
record = (record_t *)rumavl_find(qrk->string_to_id, &key);
|
|
142
|
+
return (record != NULL) ? record->qid : -1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const char *quark_to_string(quark_t *qrk, int qid)
|
|
146
|
+
{
|
|
147
|
+
return (qid < qrk->num) ? qrk->id_to_string[qid] : NULL;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
int quark_num(quark_t *qrk)
|
|
151
|
+
{
|
|
152
|
+
return qrk->num;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#if 0
|
|
156
|
+
int main(int argc, char *argv[])
|
|
157
|
+
{
|
|
158
|
+
quark_t *qrk = quark_new();
|
|
159
|
+
int qid = 0;
|
|
160
|
+
|
|
161
|
+
qid = quark_get(qrk, "zero");
|
|
162
|
+
qid = quark_get(qrk, "one");
|
|
163
|
+
qid = quark_get(qrk, "zero");
|
|
164
|
+
qid = quark_to_id(qrk, "three");
|
|
165
|
+
qid = quark_get(qrk, "two");
|
|
166
|
+
qid = quark_get(qrk, "three");
|
|
167
|
+
qid = quark_to_id(qrk, "three");
|
|
168
|
+
qid = quark_get(qrk, "zero");
|
|
169
|
+
qid = quark_get(qrk, "one");
|
|
170
|
+
|
|
171
|
+
printf("%s\n", quark_to_string(qrk, 0));
|
|
172
|
+
printf("%s\n", quark_to_string(qrk, 1));
|
|
173
|
+
printf("%s\n", quark_to_string(qrk, 2));
|
|
174
|
+
printf("%s\n", quark_to_string(qrk, 3));
|
|
175
|
+
|
|
176
|
+
quark_delete(qrk);
|
|
177
|
+
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
#endif
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Quark object.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2007-2010, Naoaki Okazaki
|
|
5
|
+
* All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
|
8
|
+
* modification, are permitted provided that the following conditions are met:
|
|
9
|
+
* * Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* * Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
|
14
|
+
* * Neither the names of the authors nor the names of its contributors
|
|
15
|
+
* may be used to endorse or promote products derived from this
|
|
16
|
+
* software without specific prior written permission.
|
|
17
|
+
*
|
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
19
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
20
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
21
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
22
|
+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
23
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
24
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
25
|
+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
26
|
+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
27
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
28
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/* $Id$ */
|
|
32
|
+
|
|
33
|
+
#ifndef __QUARK_H__
|
|
34
|
+
#define __QUARK_H__
|
|
35
|
+
|
|
36
|
+
struct tag_quark;
|
|
37
|
+
typedef struct tag_quark quark_t;
|
|
38
|
+
|
|
39
|
+
quark_t *quark_new();
|
|
40
|
+
void quark_delete(quark_t *qrk);
|
|
41
|
+
int quark_get(quark_t *qrk, const char *str);
|
|
42
|
+
int quark_to_id(quark_t *qrk, const char *str);
|
|
43
|
+
const char *quark_to_string(quark_t *qrk, int qid);
|
|
44
|
+
int quark_num(quark_t *qrk);
|
|
45
|
+
|
|
46
|
+
#endif /*__QUARK_H__*/
|