예제 #1
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());
        }
예제 #2
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());
        }
        public void TestMethod5()
        {
            var node = new MeCabNode()
            {
                Feature = "品詞"
            };

            Assert.AreEqual("品詞", node.GetPartsOfSpeech());
            Assert.IsNull(node.GetPartsOfSpeechSection1());
            Assert.IsNull(node.GetPartsOfSpeechSection2());
            Assert.IsNull(node.GetPartsOfSpeechSection3());
            Assert.IsNull(node.GetConjugatedForm());
            Assert.IsNull(node.GetInflection());
            Assert.IsNull(node.GetOriginalForm());
            Assert.IsNull(node.GetReading());
            Assert.IsNull(node.GetPronounciation());
        }
        public void TestMethod1()
        {
            var node = new MeCabNode()
            {
                Feature = "品詞,品詞細分類1,品詞細分類2,品詞細分類3,活用形,活用型,原形,読み,発音"
            };

            Assert.AreEqual("品詞", node.GetPartsOfSpeech());
            Assert.AreEqual("品詞細分類1", node.GetPartsOfSpeechSection1());
            Assert.AreEqual("品詞細分類2", node.GetPartsOfSpeechSection2());
            Assert.AreEqual("品詞細分類3", node.GetPartsOfSpeechSection3());
            Assert.AreEqual("活用形", node.GetConjugatedForm());
            Assert.AreEqual("活用型", node.GetInflection());
            Assert.AreEqual("原形", node.GetOriginalForm());
            Assert.AreEqual("読み", node.GetReading());
            Assert.AreEqual("発音", node.GetPronounciation());
        }