Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
 public static extern int kiwi_ws_close(KiwiWsHandle result);
Example #4
0
 public static extern float kiwi_ws_pos_score(KiwiWsHandle result, int index);
Example #5
0
 public static extern int kiwi_ws_freq(KiwiWsHandle result, int index);
Example #6
0
 public static extern IntPtr kiwi_ws_form_w(KiwiWsHandle result, int index);