public async Task <HttpResponseMessage> Post() { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); try { NameValueCollection param; string ext = InformationExtractor.request(Request, out param); string query_result; string dataBody = await Request.Content.ReadAsStringAsync(); param.Add("stringJson", dataBody); var result = SPExecutor.ExecuteSp(ext, param, out query_result); if (query_result != null) { response.Content = new StringContent(query_result, Encoding.UTF8, "application/json"); } return(response); } catch (Exception ex) { response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Something Went Wrong"); return(response); } }
/// <summary> /// Get TF-IDF from hubble table base on specified field. /// Text is segmented. /// Text format is like "abc^5^0 news^5^4" or "abc news" /// </summary> /// <param name="tableName">table name</param> /// <param name="fieldName">field name must be tokenized index type</param> /// <param name="formattedText">text segmentd</param> /// <returns>TF IDF List</returns> public HashSet <TFIDF> SP_GetTFIDFWithSegmentedText(string tableName, string fieldName, string segmentdText) { SPExecutor <TFIDF> spExecutor = new SPExecutor <TFIDF>(this); return(spExecutor.ReturnAsHashSet("exec SP_GetTFIDF {0}, {1}, {2}", tableName, fieldName, segmentdText)); }
public HashSet <TableInfo> SP_TableList(string databaseName) { SPExecutor <TableInfo> spExecutor = new SPExecutor <TableInfo>(this); HashSet <TableInfo> result = spExecutor.ReturnAsHashSet("exec SP_TableList {0}", databaseName); foreach (TableInfo tableInfo in result) { tableInfo.TableName = tableInfo.TableName.Substring(databaseName.Trim().Length + 1, tableInfo.TableName.Length - (databaseName.Trim().Length + 1)); } return(result); }
/// <summary> /// Get word info that are analyzed by server. /// </summary> /// <param name="tableName">table name</param> /// <param name="fieldName">field name must be tokenized index type</param> /// <param name="text">text</param> /// <param name="sqlclient">use Analzyer for SqlClient</param> /// <returns>word info List</returns> public IList <WordInfo> SP_FieldAnalyze(string tableName, string fieldName, string text, bool sqlclient) { SPExecutor <WordInfo> spExecutor = new SPExecutor <WordInfo>(this); if (sqlclient) { return(spExecutor.ReturnAsList("exec SP_FieldAnalyze {0}, {1}, {2}", tableName, fieldName, text, "SqlClient")); } else { return(spExecutor.ReturnAsList("exec SP_FieldAnalyze {0}, {1}, {2}", tableName, fieldName, text)); } }
/// <summary> /// Get TF-IDF from hubble table base on specified field. /// Text is not segmented. It is the original input text. /// </summary> /// <param name="tableName">table name</param> /// <param name="fieldName">field name must be tokenized index type</param> /// <param name="text">text</param> /// <returns>TF IDF List</returns> public HashSet <TFIDF> SP_GetTFIDF(string tableName, string fieldName, string text) { SPExecutor <TFIDF> spExecutor = new SPExecutor <TFIDF>(this); StringBuilder segmentdText = new StringBuilder(); foreach (var wordinfo in SP_FieldAnalyze(tableName, fieldName, text)) { segmentdText.AppendFormat("{0}^{1}^{2} ", wordinfo.Word, wordinfo.Rank, wordinfo.Position); } return(SP_GetTFIDFWithSegmentedText(tableName, fieldName, segmentdText.ToString().Trim())); }
/// <summary> /// List all the columns in the table specified. /// </summary> /// <param name="tableName">table name</param> /// <returns>Columns</returns> public HashSet <ColumnInfo> SP_Columns(string tableName) { SPExecutor <ColumnInfo> spExecutor = new SPExecutor <ColumnInfo>(this); return(spExecutor.ReturnAsHashSet("exec SP_Columns {0}", tableName)); }
/// <summary> /// List all the databases /// </summary> /// <returns></returns> public HashSet <DatabaseInfo> SP_DatabaseList() { SPExecutor <DatabaseInfo> spExecutor = new SPExecutor <DatabaseInfo>(this); return(spExecutor.ReturnAsHashSet("exec SP_DatabaseList", null)); }
/// <summary> /// List all the tables in all the database /// </summary> /// <returns></returns> public HashSet <TableInfo> SP_TableList() { SPExecutor <TableInfo> spExecutor = new SPExecutor <TableInfo>(this); return(spExecutor.ReturnAsHashSet("exec SP_TableList", null)); }