Esempio n. 1
0
        public static List <(string word, string tag)> JiebaTags2StringList(ref JiebaTags words)
        {
            var ret = new List <(string word, string tag)>();

            for (int i = 0; i < words.Count; ++i)
            {
                var wordPtrEntryInArray = IntPtr.Add(words.Words, IntPtr.Size * i);
                var tagPtrEntryInArray  = IntPtr.Add(words.Tags, IntPtr.Size * i);
                var wordPtr             = Marshal.PtrToStructure <IntPtr>(wordPtrEntryInArray);
                var tagPtr = Marshal.PtrToStructure <IntPtr>(tagPtrEntryInArray);
                var word   = Marshal.PtrToStringUTF8(wordPtr);
                var tag    = Marshal.PtrToStringUTF8(tagPtr);
                ret.Add((word, tag));
            }

            return(ret);
        }
Esempio n. 2
0
 public static extern uint jieba_cut_with_tag(IntPtr ctx, [MarshalAs(UnmanagedType.LPUTF8Str)] string sentence, ref JiebaTags result);
Esempio n. 3
0
 public static extern void jieba_tags_free(ref JiebaTags t);