public ExtractedWord[] ExtractAddWords(Reader reader, int minCnt = 5, int maxWordLen = 10, float minScore = 0.1f, float posThreshold = -3) { GCHandle handle = GCHandle.Alloc(this); this.reader = reader; readItem = null; KiwiWsHandle ret = KiwiCAPI.kiwi_builder_extract_add_words_w(inst, readerInst, (IntPtr)handle, minCnt, maxWordLen, minScore, posThreshold); handle.Free(); if (inst == IntPtr.Zero) { throw new KiwiException(Marshal.PtrToStringAnsi(KiwiCAPI.kiwi_error())); } ExtractedWord[] words = KiwiCAPI.ToExtractedWord(ret); KiwiCAPI.kiwi_ws_close(ret); return(words); }
public static ExtractedWord[] ToExtractedWord(KiwiWsHandle kiwiresult) { int resCount = kiwi_ws_size(kiwiresult); if (resCount < 0) { throw new KiwiException(Marshal.PtrToStringAnsi(kiwi_error())); } ExtractedWord[] ret = new ExtractedWord[resCount]; for (int i = 0; i < resCount; ++i) { ret[i].word = Marshal.PtrToStringUni(kiwi_ws_form_w(kiwiresult, i)); ret[i].score = kiwi_ws_score(kiwiresult, i); ret[i].posScore = kiwi_ws_pos_score(kiwiresult, i); ret[i].freq = kiwi_ws_freq(kiwiresult, i); } return(ret); }
public static extern int kiwi_ws_close(KiwiWsHandle result);
public static extern float kiwi_ws_pos_score(KiwiWsHandle result, int index);
public static extern int kiwi_ws_freq(KiwiWsHandle result, int index);
public static extern IntPtr kiwi_ws_form_w(KiwiWsHandle result, int index);