Created
July 28, 2018 00:48
-
-
Save tonylambiris/b86267f61660516ea9209488353e86a0 to your computer and use it in GitHub Desktop.
gposttl shared library tokenizer test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <dlfcn.h> | |
| int (*initialize_tagger)(char *envp); | |
| void (*destroy_tagger)(void); | |
| char *(*Tokenizer)(char *buff); | |
| char *(*tag)(char *buf, int enhanced_penntag); | |
| int main(int argc, char **argv) { | |
| int i; | |
| char *token; | |
| void *handle; | |
| char *error; | |
| char *words = "My name is The Plauge."; | |
| handle = dlopen ("/usr/lib/libgposttl.so.0.0.0", RTLD_GLOBAL|RTLD_LAZY); | |
| if (!handle) { | |
| fputs (dlerror(), stderr); | |
| exit(1); | |
| } | |
| initialize_tagger = dlsym(handle, "initialize_tagger"); | |
| if ((error = dlerror()) != NULL) { | |
| fputs(error, stderr); | |
| exit(1); | |
| } | |
| destroy_tagger = dlsym(handle, "destroy_tagger"); | |
| if ((error = dlerror()) != NULL) { | |
| fputs(error, stderr); | |
| exit(1); | |
| } | |
| Tokenizer = dlsym(handle, "Tokenizer"); | |
| if ((error = dlerror()) != NULL) { | |
| fputs(error, stderr); | |
| exit(1); | |
| } | |
| tag = dlsym(handle, "tag"); | |
| if ((error = dlerror()) != NULL) { | |
| fputs(error, stderr); | |
| exit(1); | |
| } | |
| i = initialize_tagger("/usr/share/gposttl"); | |
| if(i == -1) { | |
| fputs("Error in tagger init", stderr); | |
| exit(1); | |
| } | |
| token = tag(Tokenizer(words), 1); | |
| if(token == NULL) { | |
| fputs("Error in tokenizer", stderr); | |
| exit(1); | |
| } | |
| puts(token); | |
| destroy_tagger(); | |
| dlclose(handle); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment