Last active
October 11, 2015 13:57
-
-
Save tbbooher/ffff9e6a5d4cc63da00a to your computer and use it in GitHub Desktop.
This file contains 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
MITIE_EXPORT char** mitie_tokenize ( | |
const char* text | |
); | |
/*! | |
requires | |
- text == a valid pointer to a NULL terminated C string | |
ensures | |
- returns an array that contains a tokenized copy of the input text. | |
- The returned array is an array of pointers to NULL terminated C strings. The | |
array itself is terminated with a NULL. So for example, if text was "some text" | |
then the returned array, TOK, would contain: | |
- TOK[0] == "some" | |
- TOK[1] == "text" | |
- TOK[2] == NULL | |
- It is the responsibility of the caller to free the returned array. You free | |
it by calling mitie_free() once on the entire array. So to use the above | |
nomenclature, you call mitie_free(TOK). DO NOT CALL FREE ON ELEMENTS OF TOK. | |
- If something prevents this function from succeeding then a NULL is returned. | |
!*/ |
This file contains 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
require 'ffi' | |
module FfiCustomTest | |
extend FFI::Library | |
ffi_lib 'c' | |
ffi_lib '/Users/christinebooher/Sites/MITIE/mitielib/libmitie.so' | |
# attach_function :mitie_get_num_possible_ner_tags, [:string], :string | |
attach_function :mitie_tokenize, [:string], :string | |
end | |
puts FfiCustomTest.mitie_tokenize('this is a simple sentence, it should be tonkenizeable') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
result:
➜ ffi ruby test.rb
��+��