/// <summary> /// 将句子解析出来 /// </summary> /// <returns></returns> public List<string> Parser() { items = new List<string>(); Analyzer analyzer = new Lucene.China.ChineseAnalyzer(Server.MapPath("dll")); StringReader sr = new StringReader(Chinese); TokenStream stream = analyzer.TokenStream(null, sr); Token t = stream.Next(); string t1 = ""; while (t != null) { t1 = t.ToString(); //显示格式: (关键词,0,2) ,需要处理 t1 = t1.Replace("(", ""); char[] separator = { ',' }; t1 = t1.Split(separator)[0]; items.Add(t1); t = stream.Next(); } return items; }
/// <summary> /// 将句子解析出来 /// </summary> /// <returns></returns> public List <string> Parser() { items = new List <string>(); Analyzer analyzer = new Lucene.China.ChineseAnalyzer(Server.MapPath("dll")); StringReader sr = new StringReader(Chinese); TokenStream stream = analyzer.TokenStream(null, sr); Token t = stream.Next(); string t1 = ""; while (t != null) { t1 = t.ToString(); //显示格式: (关键词,0,2) ,需要处理 t1 = t1.Replace("(", ""); char[] separator = { ',' }; t1 = t1.Split(separator)[0]; items.Add(t1); t = stream.Next(); } return(items); }
private void RetriveTokenFromText(string sourceText, int fileIndex) { List <string> dataTableItem = new List <string>(); string curNewToken = ""; Analyzer analyzer = new Lucene.China.ChineseAnalyzer(); StringReader sr = new StringReader(sourceText); TokenStream stream = analyzer.TokenStream(null, sr); Token nextToken = stream.Next(); while (nextToken != null) { curNewToken = nextToken.ToString(); //显示格式: (关键词,0,2) ,需要处理 curNewToken = curNewToken.Replace("(", ""); char[] separator = { ',' }; curNewToken = curNewToken.Split(separator)[0]; //StoreTokenIntoList(curNewToken, fileIndex); dataTableItem.Add(curNewToken); nextToken = stream.Next(); } this.dataTable.Add(dataTableItem); }
private void RetriveTokenFromText(string sourceText, int fileIndex) { List<string> dataTableItem = new List<string>(); string curNewToken = ""; Analyzer analyzer = new Lucene.China.ChineseAnalyzer(); StringReader sr = new StringReader(sourceText); TokenStream stream = analyzer.TokenStream(null, sr); Token nextToken = stream.Next(); while (nextToken != null) { curNewToken = nextToken.ToString(); //显示格式: (关键词,0,2) ,需要处理 curNewToken = curNewToken.Replace("(", ""); char[] separator = { ',' }; curNewToken = curNewToken.Split(separator)[0]; //StoreTokenIntoList(curNewToken, fileIndex); dataTableItem.Add(curNewToken); nextToken = stream.Next(); } this.dataTable.Add(dataTableItem); }