libuproc
1.2.0
|
Evolutionary Curve. More...
Data Structures | |
struct | uproc_ecurve_suffixentry |
Pair of suffix and family. More... | |
struct | uproc_ecurve |
Evolutionary Curve. More... | |
Enumerations | |
enum | uproc_ecurve_format { UPROC_ECURVE_PLAIN, UPROC_ECURVE_BINARY } |
Storage format. More... | |
enum | { UPROC_ECURVE_EXACT, UPROC_ECURVE_INEXACT, UPROC_ECURVE_OOB } |
Lookup return codes. More... | |
Functions | |
uproc_ecurve * | uproc_ecurve_create (const char *alphabet, size_t suffix_count) |
Create ecurve object. More... | |
void | uproc_ecurve_destroy (uproc_ecurve *ecurve) |
Destroy ecurve object. More... | |
int | uproc_ecurve_add_prefix (uproc_ecurve *ecurve, uproc_prefix pfx, uproc_list *suffixes) |
Add a prefix entry. More... | |
int | uproc_ecurve_finalize (uproc_ecurve *ecurve) |
Finalize ecurve. More... | |
int | uproc_ecurve_lookup (const uproc_ecurve *ecurve, const struct uproc_word *word, struct uproc_word *lower_neighbour, uproc_family *lower_class, struct uproc_word *upper_neighbour, uproc_family *upper_class) |
Find the closest neighbours of a word in the ecurve. More... | |
uproc_alphabet * | uproc_ecurve_alphabet (const uproc_ecurve *ecurve) |
Return the internal alphabet. More... | |
uproc_ecurve * | uproc_ecurve_loads (enum uproc_ecurve_format format, uproc_io_stream *stream) |
Load ecurve from stream. More... | |
uproc_ecurve * | uproc_ecurve_load (enum uproc_ecurve_format format, enum uproc_io_type iotype, const char *pathfmt,...) |
Load ecurve from file. More... | |
uproc_ecurve * | uproc_ecurve_loadp (enum uproc_ecurve_format format, enum uproc_io_type iotype, void(*progress)(double), const char *pathfmt,...) |
Load ecurve from file. More... | |
uproc_ecurve * | uproc_ecurve_loadv (enum uproc_ecurve_format format, enum uproc_io_type iotype, const char *pathfmt, va_list ap) |
Load ecurve from file. More... | |
uproc_ecurve * | uproc_ecurve_loadpv (enum uproc_ecurve_format format, enum uproc_io_type iotype, void(*progress)(double), const char *pathfmt, va_list ap) |
Load ecurve from file. More... | |
int | uproc_ecurve_stores (const uproc_ecurve *ecurve, enum uproc_ecurve_format format, uproc_io_stream *stream) |
Store ecurve to stream. More... | |
int | uproc_ecurve_storeps (const uproc_ecurve *ecurve, enum uproc_ecurve_format format, void(*progress)(double), uproc_io_stream *stream) |
Store ecurve to stream. More... | |
int | uproc_ecurve_store (const uproc_ecurve *ecurve, enum uproc_ecurve_format format, enum uproc_io_type iotype, const char *pathfmt,...) |
Store ecurve to file. More... | |
int | uproc_ecurve_storep (const uproc_ecurve *ecurve, enum uproc_ecurve_format format, enum uproc_io_type iotype, void(*progress)(double), const char *pathfmt,...) |
Store ecurve to file. More... | |
int | uproc_ecurve_storev (const uproc_ecurve *ecurve, enum uproc_ecurve_format format, enum uproc_io_type iotype, const char *pathfmt, va_list ap) |
Store ecurve to file. More... | |
int | uproc_ecurve_storepv (const uproc_ecurve *ecurve, enum uproc_ecurve_format format, enum uproc_io_type iotype, void(*progress)(double), const char *pathfmt, va_list ap) |
Store ecurve to file. More... | |
uproc_ecurve * | uproc_ecurve_mmap (const char *pathfmt,...) |
Map a file to an ecurve. More... | |
uproc_ecurve * | uproc_ecurve_mmapv (const char *pathfmt, va_list ap) |
Store ecurve to file. More... | |
void | uproc_ecurve_munmap (uproc_ecurve *ecurve) |
Release mapping and close the underlying file descriptor. More... | |
int | uproc_ecurve_mmap_store (const uproc_ecurve *ecurve, const char *pathfmt,...) |
Store ecurve in a format suitable for uproc_ecurve_mmap() More... | |
int | uproc_ecurve_mmap_storev (const uproc_ecurve *ecurve, const char *pathfmt, va_list ap) |
Store ecurve to mmap file. More... | |
Evolutionary Curve.
enum uproc_ecurve_format |
anonymous enum |
uproc_ecurve* uproc_ecurve_create | ( | const char * | alphabet, |
size_t | suffix_count | ||
) |
Create ecurve object.
alphabet | string to initialize the ecurve's alphabet (see uproc_alphabet_init()) |
suffix_count | number of entries in the suffix table |
void uproc_ecurve_destroy | ( | uproc_ecurve * | ecurve | ) |
Destroy ecurve object.
int uproc_ecurve_add_prefix | ( | uproc_ecurve * | ecurve, |
uproc_prefix | pfx, | ||
uproc_list * | suffixes | ||
) |
Add a prefix entry.
Adds the prefix pfx
and the suffix/family pairs in the suffixes
list to the ecurve.
The argument to ecurve
must be an ecurve fulfilling the following conditions:
0
as the second argument to uproc_ecurve_create() Because building is done incrementally, the pfx
argument needs to be greater than it was in the previous call to this function.
The suffixes
argument must be a List with at least one element of type uproc_ecurve_suffixentry.
Example
int uproc_ecurve_finalize | ( | uproc_ecurve * | ecurve | ) |
Finalize ecurve.
Finalizes an ecurve that was built using uproc_ecurve_add_prefix(). This function must be called on a newly-constructed ecurve before it can be used.
int uproc_ecurve_lookup | ( | const uproc_ecurve * | ecurve, |
const struct uproc_word * | word, | ||
struct uproc_word * | lower_neighbour, | ||
uproc_family * | lower_class, | ||
struct uproc_word * | upper_neighbour, | ||
uproc_family * | upper_class | ||
) |
Find the closest neighbours of a word in the ecurve.
NOTE: ecurve
may not be empty.
If word
was found exactly as it it in the ecurve, UPROC_ECURVE_EXACT will be returned; if word
is "outside" of the ecurve (i.e. its prefix is less than than the smalles or greater than the largest stored non-empty prefix), UPROC_ECURVE_OOB will be returned. In both cases, the objects pointed to by upper_neighbour
and upper_class
will be set equal to their lower_
... counterparts.
In case of an inexact match, UPROC_ECURVE_INEXACT will be returned, lower_
... and their upper_
... counterparts will differ.
ecurve | ecurve object |
word | word to search |
lower_neighbour | OUT: lower neighbour word |
lower_class | OUT: class of the lower neighbour |
upper_neighbour | OUT: upper neighbour word |
upper_class | OUT: class of the upper neighbour |
uproc_alphabet* uproc_ecurve_alphabet | ( | const uproc_ecurve * | ecurve | ) |
Return the internal alphabet.
uproc_ecurve* uproc_ecurve_loads | ( | enum uproc_ecurve_format | format, |
uproc_io_stream * | stream | ||
) |
Load ecurve from stream.
Similar to uproc_ecurve_load(), but reads the data from an already opened file stream.
uproc_ecurve* uproc_ecurve_load | ( | enum uproc_ecurve_format | format, |
enum uproc_io_type | iotype, | ||
const char * | pathfmt, | ||
... | |||
) |
Load ecurve from file.
Opens a file for reading, allocates a new uproc_ecurve object and parses the data in the file using the given format.
If libecurve is compiled on a system that supports mmap(), calling this function with UPROC_ECURVE_BINARY as the format
argument is equivalent to using uproc_ecurve_mmap().
format | format to use, see uproc_ecurve_format |
iotype | IO type, see uproc_io_type |
pathfmt | printf format string for file path |
... | format string arguments |
uproc_ecurve* uproc_ecurve_loadp | ( | enum uproc_ecurve_format | format, |
enum uproc_io_type | iotype, | ||
void(*)(double) | progress, | ||
const char * | pathfmt, | ||
... | |||
) |
Load ecurve from file.
Like uproc_ecurve_load(), but periodically calls progress
to report the current progress (in percent).
uproc_ecurve* uproc_ecurve_loadv | ( | enum uproc_ecurve_format | format, |
enum uproc_io_type | iotype, | ||
const char * | pathfmt, | ||
va_list | ap | ||
) |
Load ecurve from file.
Like uproc_ecurve_load(), but with a va_list
instead of a variable number of arguments.
uproc_ecurve* uproc_ecurve_loadpv | ( | enum uproc_ecurve_format | format, |
enum uproc_io_type | iotype, | ||
void(*)(double) | progress, | ||
const char * | pathfmt, | ||
va_list | ap | ||
) |
Load ecurve from file.
Like uproc_ecurve_loadp(), but with a va_list
instead of a variable number of arguments.
int uproc_ecurve_stores | ( | const uproc_ecurve * | ecurve, |
enum uproc_ecurve_format | format, | ||
uproc_io_stream * | stream | ||
) |
Store ecurve to stream.
Similar to uproc_ecurve_store(), but writes the data to an already opened file stream.
int uproc_ecurve_storeps | ( | const uproc_ecurve * | ecurve, |
enum uproc_ecurve_format | format, | ||
void(*)(double) | progress, | ||
uproc_io_stream * | stream | ||
) |
Store ecurve to stream.
Similar to uproc_ecurve_storep(), but writes the data to an already opened file stream.
int uproc_ecurve_store | ( | const uproc_ecurve * | ecurve, |
enum uproc_ecurve_format | format, | ||
enum uproc_io_type | iotype, | ||
const char * | pathfmt, | ||
... | |||
) |
Store ecurve to file.
Stores a uproc_ecurve object to a file using the given format.
If libecurve is compiled on a system that supports mmap(), calling this function with UPROC_ECURVE_BINARY as the format
argument is equivalent to using uproc_ecurve_mmap_store().
ecurve | pointer to ecurve to store |
format | format to use, see uproc_ecurve_format |
iotype | IO type, see uproc_io_type |
pathfmt | printf format string for file path |
... | format string arguments |
int uproc_ecurve_storep | ( | const uproc_ecurve * | ecurve, |
enum uproc_ecurve_format | format, | ||
enum uproc_io_type | iotype, | ||
void(*)(double) | progress, | ||
const char * | pathfmt, | ||
... | |||
) |
Store ecurve to file.
Like uproc_ecurve_store(), but periodically calls progress
to report the current progress (in percent).
int uproc_ecurve_storev | ( | const uproc_ecurve * | ecurve, |
enum uproc_ecurve_format | format, | ||
enum uproc_io_type | iotype, | ||
const char * | pathfmt, | ||
va_list | ap | ||
) |
Store ecurve to file.
Like uproc_ecurve_store(), but with a va_list
instead of a variable number of arguments.
int uproc_ecurve_storepv | ( | const uproc_ecurve * | ecurve, |
enum uproc_ecurve_format | format, | ||
enum uproc_io_type | iotype, | ||
void(*)(double) | progress, | ||
const char * | pathfmt, | ||
va_list | ap | ||
) |
Store ecurve to file.
Like uproc_ecurve_storep(), but with a va_list
instead of a variable number of arguments.
uproc_ecurve* uproc_ecurve_mmap | ( | const char * | pathfmt, |
... | |||
) |
Map a file to an ecurve.
The file must have been created by uproc_ecurve_mmap_store(), preferably on the same machine.
pathfmt | printf format string for file path |
... | format string arguments |
uproc_ecurve* uproc_ecurve_mmapv | ( | const char * | pathfmt, |
va_list | ap | ||
) |
Store ecurve to file.
Like uproc_ecurve_store(), but with a va_list
instead of a variable number of arguments.
void uproc_ecurve_munmap | ( | uproc_ecurve * | ecurve | ) |
Release mapping and close the underlying file descriptor.
ecurve | ecurve mapped with uproc_mmap_map() |
int uproc_ecurve_mmap_store | ( | const uproc_ecurve * | ecurve, |
const char * | pathfmt, | ||
... | |||
) |
Store ecurve in a format suitable for uproc_ecurve_mmap()
Identical to uproc_ecurve_store() with UPROC_ECURVE_BINARY
ecurve | ecurve to store |
pathfmt | printf format string for file path |
... | format string arguments |
int uproc_ecurve_mmap_storev | ( | const uproc_ecurve * | ecurve, |
const char * | pathfmt, | ||
va_list | ap | ||
) |
Store ecurve to mmap file.
Like uproc_ecurve_mmap_store(), but with a va_list
instead of a variable number of arguments.