// 切分结果转换为list public static List <sentenceAnalysis.to.word> toList(string str) { List <sentenceAnalysis.to.word> temp_list = new List <sentenceAnalysis.to.word>(); string[] stringForResult = str.Split(' '); for (int j = 0; j < stringForResult.Length; j++) { if (stringForResult[j] != "" && stringForResult[j] != " ") { string[] temp = stringForResult[j].Split('/'); sentenceAnalysis.to.word single = new sentenceAnalysis.to.word(); single.character = temp[0]; single.position = j; if (temp.Length == 1) { single.speech = null; } else { single.speech = temp[1]; } temp_list.Add(single); } } return(deleteULEword(temp_list)); }
// 词组分析 // 有两种 1 地名词组 2 航母号词组 public static void place_phrase_recog(List <sentenceAnalysis.to.word> list) { place_phrase.Clear(); // 检查连续出现三个以上的地名词 for (int i = 1; i < list.Count; i++) { if (list[i].speech == "nsf" || list[i].speech == "ns" || list[i].speech == "jidi") { sentenceAnalysis.to.word next = null; if (i + 1 < list.Count) { next = list[i + 1]; if (list[i - 1].speech != null && list[i + 1].speech != null && (list[i - 1].speech.Contains("ns") || list[i + 1].speech.Contains("ns") || list[i - 1].speech.Contains("jidi") || list[i + 1].speech.Contains("jidi"))) { // place_phrase.Add(whole_page[i-1].speech == "nsf" || whole_page[i - 1].speech == "ns"? whole_page[i-1] : null); if (list[i - 1].speech == "nsf" || list[i - 1].speech == "ns" || list[i - 1].speech == "jidi") { combinePhrase(list, i - 1); place_phrase.Add(list[i - 1]); list[i - 1].metonymy = 0; if (i + 1 < list.Count) { if (next.speech == "nsf" || next.speech == "ns") { combinePhrase(list, i - 1); place_phrase.Add(list[i - 1]); list[i - 1].metonymy = 0; /* foreach (string coun in Enum.GetNames(typeof(sentenceAnalysis.to.countries))) * { * if (coun == whole_page[i +1 ].character) * whole_page[i + 1].metonymy = 0;//此时不转喻 记录位置 * }*/ } } /* foreach (string coun in Enum.GetNames(typeof(sentenceAnalysis.to.countries))) * { * if (coun == whole_page[i - 1].character) * whole_page[i-1].metonymy = 0 ;//此时不转喻 记录位置 * }*/ } else { if (next.speech == "nsf" || next.speech == "ns" || next.speech == "jidi") { combinePhrase(list, i); place_phrase.Add(list[i]); list[i].metonymy = 0; /* foreach (string coun in Enum.GetNames(typeof(sentenceAnalysis.to.countries))) * { * if (coun == whole_page[i +1 ].character) * whole_page[i + 1].metonymy = 0;//此时不转喻 记录位置 * }*/ } } // place_phrase.Add(list[i]); // list[i].metonymy = 1; /* foreach (string coun in Enum.GetNames(typeof(sentenceAnalysis.to.countries))) * { * if (coun == whole_page[i ].character) * whole_page[i - 1].metonymy = 0;//此时不转喻 记录位置 * }*/ // place_phrase.Add(next.speech == "nsf" || whole_page[i + 1].speech == "ns"? next:null); } } } } // return place_phrase; }