private void OnNShortPath(List <int[]> paths, RowFirstDynamicArray <ChainContent> segGraph) { List <ChainItem <ChainContent> > list = segGraph.ToListItems(); string theWord; int[] aPath; StringBuilder sb = new StringBuilder(); for (int i = 0; i < paths.Count; i++) { aPath = paths[i]; for (int j = 0; j < aPath.Length; j++) { theWord = list[aPath[j]].Content.sWord; if (theWord == "未##人" || theWord == "未##地" || theWord == "未##数" || theWord == "未##时" || theWord == "未##串") { for (int k = list[aPath[j]].row; k < list[aPath[j]].col; k++) { sb.Append(atomSegment[k].sWord); } sb.Append(", "); } else { sb.Append(string.Format("{0}, ", list[aPath[j]].Content.sWord)); } } sb.Append("\r\n"); } SendEvents(new SegmentEventArgs(SegmentStage.NShortPath, sb.ToString())); }
//==================================================================== // 将BiPath转换为LinkedArray // 例如“他说的确实在理” // BiPath:(0, 1, 2, 3, 6, 9, 11, 12) // 0 1 2 3 4 5 6 7 8 9 10 11 12 // 始##始 他 说 的 的确 确 确实 实 实在 在 在理 理 末##末 //==================================================================== private static WordLinkedArray BiPath2LinkedArray(int[] biPath, RowFirstDynamicArray <ChainContent> segGraph, List <AtomNode> atomSegment) { List <ChainItem <ChainContent> > list = segGraph.ToListItems(); StringBuilder sb = new StringBuilder(); WordLinkedArray result = new WordLinkedArray(); for (int i = 0; i < biPath.Length; i++) { WordNode node = new WordNode(); node.row = list[biPath[i]].row; node.col = list[biPath[i]].col; node.sWordInSegGraph = list[biPath[i]].Content.sWord; node.theWord = new WordResult(); if (node.sWordInSegGraph == "未##人" || node.sWordInSegGraph == "未##地" || node.sWordInSegGraph == "未##数" || node.sWordInSegGraph == "未##时" || node.sWordInSegGraph == "未##串") { sb.Remove(0, sb.Length); for (int j = node.row; j < node.col; j++) { sb.Append(atomSegment[j].sWord); } node.theWord.sWord = sb.ToString(); } else { node.theWord.sWord = list[biPath[i]].Content.sWord; } node.theWord.nPOS = list[biPath[i]].Content.nPOS; node.theWord.dValue = list[biPath[i]].Content.eWeight; result.AppendNode(node); } return(result); }