CWB-CL
view release on metacpan or search on metacpan
INIT:
last_cl_error = CDA_OK;
char *
cl_make_set(s, split="")
char * s
char * split
PREINIT:
char *set;
int split_mode;
PPCODE:
last_cl_error = CDA_OK;
if (split == NULL || (split[0] != '\0' && split[0] != 's'))
croak("Usage: $feature_set = CWB::CL::make_set($string [, 'split' | 's']);");
split_mode = (split[0] == 's');
set = cl_make_set(s, split_mode);
if (set != NULL) {
XPUSHs(sv_2mortal(newSVpv(set, 0))); /* create Perl string (let Perl compute length) */
free(set); /* <set> was allocated by cl_make_set, so free it again */
}
else {
XSRETURN_UNDEF; /* else return undefined value */
}
char *
cl_set_intersection(s1, s2)
char * s1
char * s2
PREINIT:
static char result[CL_DYN_STRING_SIZE]; /* static buffer for results string */
int ok;
PPCODE:
last_cl_error = CDA_OK;
ok = cl_set_intersection(result, s1, s2);
if (ok) {
XPUSHs(sv_2mortal(newSVpv(result, 0))); /* create Perl string (let Perl compute length) */
}
else {
last_cl_error = cl_errno;
if (strict_mode)
croak_on_error(last_cl_error);
XSRETURN_UNDEF; /* return undefined value */
cl_normalize(corpus, flags, ...)
Corpus* corpus
int flags
PREINIT:
int i, id, size;
// NB 2017-07-02: commented out bits were amended for the new calling convention for cl_string_canonical().
// They can be deleted once we're sure it's working correctly.
//char *s_orig, *s_norm;
char *s_norm;
SV *s_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 2;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
s_arg = ST(i+2);
if (!SvOK(s_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef ID arguments return undef */
}
}
/* else return empty list */
char *
cl_list_attributes(corpus, type)
Corpus* corpus
int type
PREINIT:
cl_string_list names;
int i, size;
PPCODE:
last_cl_error = CDA_OK;
names = cl_corpus_list_attributes(corpus, type);
size = cl_string_list_size(names);
/* never sets an error condition */
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
PUSHs(sv_2mortal(newSVpv(cl_string_list_get(names, i), 0)));
}
}
INIT:
last_cl_error = CDA_OK;
void
cl_id2str(attribute, ...)
PosAttrib attribute
PREINIT:
int i, id, size;
char *s;
SV *id_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
id_arg = ST(i+1);
if (!SvOK(id_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef ID arguments return undef */
}
}
/* else return empty list */
void
cl_str2id(attribute, ...)
PosAttrib attribute
PREINIT:
int i, id, size;
char *s;
SV *s_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
s_arg = ST(i+1);
if (!SvOK(s_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef ID arguments return undef */
}
croak_on_error(last_cl_error);
}
/* else return empty list */
void
cl_id2strlen(attribute, ...)
PosAttrib attribute
PREINIT:
int i, id, len, size;
SV *id_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
id_arg = ST(i+1);
if (!SvOK(id_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef ID arguments return undef */
}
croak_on_error(last_cl_error);
}
/* else return empty list */
void
cl_id2freq(attribute, ...)
PosAttrib attribute
PREINIT:
int i, id, f, size;
SV *id_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
id_arg = ST(i+1);
if (!SvOK(id_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef ID arguments return undef */
}
croak_on_error(last_cl_error);
}
/* else return empty list */
void
cl_cpos2id(attribute, ...)
PosAttrib attribute
PREINIT:
int i, cpos, id, size;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
cpos_arg = ST(i+1);
if (!SvOK(cpos_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef cpos arguments return undef */
}
}
/* else return empty list */
void
cl_cpos2str(attribute, ...)
PosAttrib attribute
PREINIT:
int i, cpos, size;
char *s;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
cpos_arg = ST(i+1);
if (!SvOK(cpos_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef cpos arguments return undef */
}
void
cl_regex2id(attribute, pattern, canonicalize)
PosAttrib attribute
char * pattern
int canonicalize
PREINIT:
int number_of_matches = 0;
int *idlist;
int i;
PPCODE:
last_cl_error = CDA_OK;
idlist = cl_regex2id(attribute, pattern, canonicalize, &number_of_matches);
if (idlist != NULL) {
EXTEND(sp, number_of_matches); /* push IDs on result stack */
for (i=0; i < number_of_matches; i++)
PUSHs(sv_2mortal(newSViv(idlist[i])));
free(idlist);
}
else {
if (strict_mode && cl_errno != CDA_OK)
}
OUTPUT:
RETVAL
void
cl_idlist2cpos(attribute, ...)
PosAttrib attribute
PREINIT:
int i, id, idlist_size, size, errors;
int *idlist, *list;
PPCODE:
last_cl_error = CDA_OK;
idlist_size = items - 1;
if (idlist_size > 0) {
Newx(idlist, idlist_size, int); /* convert argument list to list of integer IDs */
if (!idlist)
croak("Can't allocate temporary array of size %d in idlist2cpos() method\n", idlist_size);
for (i = 0; i < idlist_size; i++) {
if (SvOK(ST(i+1)))
idlist[i] = (int) SvIV(ST(i+1));
else {
Attribute * attribute
INIT:
last_cl_error = CDA_OK;
void
cl_cpos2struc(attribute, ...)
StrucAttrib attribute
PREINIT:
int i, cpos, struc, size;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
cpos_arg = ST(i+1);
if (!SvOK(cpos_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef cpos arguments return undef */
}
}
/* else return empty list */
void
cl_cpos2struc2str(attribute, ...)
StrucAttrib attribute
PREINIT:
int i, cpos, size;
char *s;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
cpos_arg = ST(i+1);
if (!SvOK(cpos_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef cpos arguments return undef */
}
}
/* else return empty list */
void
cl_struc2str(attribute, ...)
StrucAttrib attribute
PREINIT:
int i, struc, size;
char *s;
SV *struc_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
struc_arg = ST(i+1);
if (!SvOK(struc_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef struc arguments return undef */
}
}
/* else return empty list */
void
cl_struc2cpos(attribute, ...)
StrucAttrib attribute
PREINIT:
int i, struc, size, start, end;
int *arguments;
SV *struc_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
/* Return values on stack overwrite function arguments, starting from ST(0). This works in most
* vectorised functions since we push one return value for each argument, i.e. we store the result
* for ST(i+1) in ST(i). Because cl_struc2cpos() returns two values for each argument, we have
* to store all arguments in a locally allocated array first.
*/
Newx(arguments, size, int); /* allocate temporary array to hold arguments (converted to C ints) */
if (!arguments)
}
/* else return empty list */
void
cl_cpos2struc2cpos(attribute, ...)
StrucAttrib attribute
PREINIT:
int i, cpos, size, start, end;
int *arguments;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
/* see above why we need to store arguments in a temporary array of C ints */
Newx(arguments, size, int); /* allocate temporary array to hold arguments (converted to C ints) */
if (!arguments)
croak("Can't allocate temporary array for %d integers", size);
for (i = 0; i < size; i++) {
cpos_arg = ST(i+1);
if (SvOK(cpos_arg)) {
croak_on_error(last_cl_error);
}
/* else return empty list */
void
cl_cpos2boundary(attribute, ...)
StrucAttrib attribute
PREINIT:
int i, cpos, flags, size;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
cpos_arg = ST(i+1);
if (!SvOK(cpos_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef cpos arguments return undef */
}
}
/* else return empty list */
void
cl_cpos2is_boundary(attribute, test_flags, ...)
StrucAttrib attribute
int test_flags
PREINIT:
int i, cpos, flags, is_boundary, size;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 2;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
cpos_arg = ST(i+2);
if (!SvOK(cpos_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef cpos arguments return undef */
}
int
cl_max_alg(attribute)
AlignAttrib attribute
void
cl_cpos2alg(attribute, ...)
AlignAttrib attribute
PREINIT:
int i, cpos, alg, size;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
EXTEND(sp, size);
for (i = 0; i < size; i++) {
cpos_arg = ST(i+1);
if (!SvOK(cpos_arg)) {
last_cl_error = CWB_CL_INVALID_ARG;
PUSHs(sv_newmortal()); /* undef cpos arguments return undef */
}
/* else return empty list */
void
cl_alg2cpos(attribute, ...)
AlignAttrib attribute
PREINIT:
int i, alg, size;
int source_start, source_end, target_start, target_end;
int *arguments;
SV *alg_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
/* Return values on stack overwrite function arguments, starting from ST(0). This works in most
* vectorised functions since we push one return value for each argument, i.e. we store the result
* for ST(i+1) in ST(i). Because cl_alg2cpos() returns four values for each argument, we have
* to store all results in a locally allocated array first.
*/
Newx(arguments, size, int); /* allocate temporary array to hold arguments (converted to C ints) */
if (!arguments)
/* else return empty list */
void
cl_cpos2alg2cpos(attribute, ...)
AlignAttrib attribute
PREINIT:
int i, ok, cpos, alg, size;
int source_start, source_end, target_start, target_end;
int *arguments;
SV *cpos_arg;
PPCODE:
last_cl_error = CDA_OK;
size = items - 1;
if (size > 0) {
/* Return values on stack overwrite function arguments, starting from ST(0). This works in most
* vectorised functions since we push one return value for each argument, i.e. we store the result
* for ST(i+1) in ST(i). Because cl_cpos2alg2cpos() returns four values for each argument, we have
* to store all results in a locally allocated array first.
*/
Newx(arguments, size, int); /* allocate temporary array to hold arguments (converted to C ints) */
if (!arguments)
( run in 0.439 second using v1.01-cache-2.11-cpan-71847e10f99 )