Beispiel #1
0
        /// <summary>
        /// 解析を行う
        /// </summary>
        /// <param name="str">解析対象の文字列へのポインタ</param>
        /// <param name="len">解析対象の文字列の長さ</param>
        /// <returns>解析結果の文字列</returns>
        public unsafe string Parse(char *str, int len)
        {
            MeCabNode n = this.ParseToNode(str, len);

            if (n == null)
            {
                return(null);
            }
            StringBuilder os = new StringBuilder();

            this.writer.Write(os, n);
            return(os.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// 解析を行い結果を確からしいものから順番に取得する
        /// </summary>
        /// <param name="str">解析対象の文字列へのポインタ</param>
        /// <returns>文頭の形態素を確からしい順に取得するための列挙子の公開</returns>
        public unsafe IEnumerable <MeCabNode> ParseNBestToNode(char *str, int len)
        {
            if (this.LatticeLevel == 0)
            {
                throw new InvalidOperationException("Please set one or more to LatticeLevel.");
            }

            MeCabNode      n     = this.ParseToNode(str, len);
            NBestGenerator nBest = new NBestGenerator();

            nBest.Set(n);
            return(nBest.GetEnumerator());
        }
Beispiel #3
0
        public Morpheme(MeCabNode node)
        {
            Surface = node.Surface;
            var features = node.Feature.Split(new[] { ',' }, StringSplitOptions.None);

            // 品詞,品詞細分類1,品詞細分類2,品詞細分類3,活用形,活用型,原形,読み,発音
            PartOfSpeech      = new[] { features[0], features[1], features[2], features[3] };
            TypeOfConjugation = features[4];
            Conjugation       = features[5];
            OriginalForm      = features[6];
            Reading           = features[7];
            Pronunciation     = features[8];
        }