/// <summary> /// 解析を行う /// </summary> /// <param name="str">解析対象の文字列へのポインタ</param> /// <param name="len">解析対象の文字列の長さ</param> /// <returns>文頭の形態素</returns> public unsafe MeCabNode ParseToNode(char *str, int len) { this.ThrowIfDisposed(); string orgStr = new string(str, 0, len); string zenStr = Strings.StrConv(orgStr, VbStrConv.Wide, 0x411); MeCabNode nodeOrg; fixed(char *pStr = zenStr) nodeOrg = this.viterbi.Analyze(pStr, len); MeCabNode node = nodeOrg; int index; node = node.Next; while (node != null) { if (node.Feature != "BOS/EOS,*,*,*,*,*,*,*,*") { index = zenStr.IndexOf(node.Surface); if (0 <= index) { node.Surface = orgStr.Substring(index, node.Surface.Length); zenStr = zenStr.Substring(index + node.Surface.Length); orgStr = orgStr.Substring(index + node.Surface.Length); } } node = node.Next; } return(nodeOrg); }
public unsafe IEnumerable <MeCabNode> ParseNBestToNode(char *str, int len) { if (this.LatticeLevel == MeCabLatticeLevel.Zero) { throw new InvalidOperationException("Please set one or more to LatticeLevel."); } MeCabNode node = this.ParseToNode(str, len); NBestGenerator nBestGenerator = new NBestGenerator(); nBestGenerator.Set(node); return(nBestGenerator.GetEnumerator()); }
/// <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 unsafe string Parse(char *str, int len) { MeCabNode meCabNode = this.ParseToNode(str, len); if (meCabNode == null) { return(null); } StringBuilder stringBuilder = new StringBuilder(); this.writer.Write(stringBuilder, meCabNode); return(stringBuilder.ToString()); }
private void PrintMeCabNode(MeCabNode node) { //Debug.WriteLine(""); PrintParameter("Surface", node.Surface); //PrintParameter(node.Alpha); //PrintParameter(node.Beta); //PrintParameter(node.BPos); //PrintParameter(node.CharType); //PrintParameter(node.Cost); //PrintParameter(node.EPos); //PrintParameter(node.Feature); //PrintParameter(node.IsBest); //PrintParameter(node.LCAttr); //PrintParameter(node.Length); //PrintParameter(node.PosId); //PrintParameter(node.Prob); //PrintParameter(node.RCAttr); //PrintParameter(node.RLength); //PrintParameter(node.Stat); //PrintParameter(node.WCost); }