Skip to content

Instantly share code, notes, and snippets.

@tbbooher
Last active October 11, 2015 13:57
Show Gist options
  • Save tbbooher/ffff9e6a5d4cc63da00a to your computer and use it in GitHub Desktop.
Save tbbooher/ffff9e6a5d4cc63da00a to your computer and use it in GitHub Desktop.
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.
!*/
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')
@tbbooher
Copy link
Author

result:
➜ ffi ruby test.rb
��+��

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment