Module: Wapiti::Native
- Defined in:
- ext/wapiti/native.c
Constant Summary collapse
- VERSION =
rb_str_new2(VERSION)
Class Method Summary collapse
-
.label ⇒ Object
— Top-Level Utility Methods —.
-
.wapiti ⇒ Object
This function is a proxy for Wapiti’s main entry point.
Class Method Details
.label ⇒ Object
— Top-Level Utility Methods —
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
# File 'ext/wapiti/native.c', line 1182
static VALUE label(VALUE self __attribute__((__unused__)), VALUE rb_options) {
if (strncmp("Wapiti::Options", rb_obj_classname(rb_options), 15) != 0) {
rb_raise(cNativeError, "argument must be a native options instance");
}
opt_t *options = get_options(rb_options);
if (options->mode != 1) {
rb_raise(cNativeError, "invalid options argument: mode should be set to 1 for labelling");
}
mdl_t *model = mdl_new(rdr_new(options->maxent));
model->opt = options;
dolabel(model);
mdl_free(model);
return Qnil;
}
|
.wapiti ⇒ Object
This function is a proxy for Wapiti’s main entry point.
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 |
# File 'ext/wapiti/native.c', line 1225
static VALUE wapiti(VALUE self __attribute__((__unused__)), VALUE arguments) {
int result = -1, argc = 0;
char **ap, *argv[18], *input, *tmp;
Check_Type(arguments, T_STRING);
tmp = StringValueCStr(arguments);
// allocate space for argument vector
input = (char*)malloc(strlen(tmp) + 8);
// prepend command name
strncpy(input, "wapiti ", 8);
strncat(input, tmp, strlen(input) - 8);
// remember allocation pointer
tmp = input;
// turn input string into argument vector (using
// only the first seventeen tokens from input)
for (ap = argv; (*ap = strsep(&input, " \t")) != (char*)0; ++argc) {
if ((**ap != '\0') && (++ap >= &argv[18])) break;
}
// call main entry point
result = wapiti_main(argc, argv);
// free allocated memory
free(tmp);
return INT2FIX(result);
}
|