public string predictAccentsWithMultiMatches(string sentence, int nResults, bool getWeight = true) { LinkedHashMap <string, double> output = new LinkedHashMap <string, double>(); string @in = Utils.normaliseString(sentence); string lowercaseIn = @in.ToLower(); string[] words = ("0 " + lowercaseIn + " 0").Split(' '); Graph graph = new VariableGraph(); Dictionary <int, string> idxWordMap = new Dictionary <int, string>(); int index = 0; int[] numberP = new int[words.Length]; string[,] possibleChange = new string[words.Length, maxp]; int[,] indices = new int[words.Length, maxp]; int nVertex = 0; index = buildGraph(words, graph, idxWordMap, index, numberP, possibleChange, indices, nVertex); //Yen Algorithm for kShortestPaths YenTopKShortestPathsAlg yenAlg = new YenTopKShortestPathsAlg(graph); List <Accent.KShortestPaths.Model.Path> shortest_paths_list = yenAlg.get_shortest_paths(graph.get_vertex(0), graph.get_vertex(index - 1), nResults); foreach (Accent.KShortestPaths.Model.Path path in shortest_paths_list) { List <BaseVertex> pathVertex = path.get_vertices(); string text = ""; for (int i = 1; i < pathVertex.Count - 1; i++) { BaseVertex vertext = pathVertex[i]; text += idxWordMap[vertext.get_id()] + " "; if (text.Contains("đầm dáng")) { text.Replace("đầm dáng", "đảm đang"); } if (text.Contains("chào bán")) { text = Regex.Replace(text, "chào bán", "chào bạn"); } if (text.Contains("bị đầu tay")) { text = Regex.Replace(text, "bị đầu tay", "bị đau tay"); } if (text.Contains("tay tôi bị đầu")) { text = Regex.Replace(text, "tay tôi bị đầu", "tay tôi bị đau"); } } output.Add(processOutput(@in, text.Trim()), path.get_weight()); } // Không lấy trọng số đo lường cho các trường hợp thêm dấu. if (!getWeight) { return(output.ToString2()); } return(output.ToString()); }