Instantly share code, notes, and snippets.

Embed
What would you like to do?
FastText C-style bindings for .NET
public static class FastTextWrapper
{
[return: MarshalAs(UnmanagedType.Bool)]
[UnmanagedFunctionPointer(callingConvention: CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public delegate bool FastTextNNCallback(StringBuilder word, Single score, IntPtr data);
[DllImport(dllName: "fasttext.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool fasttext_new(out IntPtr ft);
[DllImport(dllName: "fasttext.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool fasttext_release(IntPtr ft);
[DllImport(dllName: "fasttext.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool fasttext_nn2(IntPtr ft, IntPtr mx, string[] positive, string[] negative, int count, FastTextNNCallback callback, IntPtr data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment