public void ProcessRequest(HttpContext context) { #region [.log.] if (Log.ProcessViewCommand(context)) { return; } #endregion var text = default(string); try { #region [.anti-bot.] var antiBot = context.ToAntiBot(); if (antiBot.IsNeedRedirectOnCaptchaIfRequestNotValid()) { antiBot.SendGotoOnCaptchaJsonResponse(); return; } #endregion text = context.GetRequestStringParam("text", Config.MAX_INPUTTEXT_LENGTH); var splitBySmiles = context.Request["splitBySmiles"].Try2Bool(true); var html = context.Request["html"].Try2Bool(false); #region [.anti-bot.] antiBot.MarkRequestEx(text); #endregion var words = ConcurrentFactoryHelper.GetConcurrentFactory().Run(text, splitBySmiles); Log.Info(context, text); SendJsonResponse(context, words, text, html); } catch (Exception ex) { Log.Error(context, text, ex); SendJsonResponse(context, ex); } }
// POST api/<controller> public Response Post([FromBody] Request request) { var words = ConcurrentFactoryHelper.GetConcurrentFactory().Run(request.Text, true); List <string> teg; var text = SendJsonResponse(words, request.Text, true, out teg); var names = GetWords(words).Select(__ => new { value = __.Key, type = __.Value }).ToArray(); var classifyInfos = http_context_data.GetConcurrentFactory().MakeClassify(request.Text); string json2 = SendJsonResponse(words, request.Text, false, out teg); string json3 = SendJsonResponse(words, request.Text, true); var resultTemp = new result(classifyInfos, Config.CLASS_THRESHOLD_PERCENT); var categories = resultTemp.classify_infos.Where(__ => (Double.Parse(__.percent.Replace('.', ',')) > 10)).Select(__ => __.class_index); var result = new Response { categories = categories.Take(3).ToArray(), names = names, text = text }; return(result); }
private static string GetResultHtml(LocalParams lp) { var lingvisticsInput = new LingvisticsTextInput() { Text = lp.Text, AfterSpellChecking = false, BaseDate = DateTime.Now, Mode = SelectEntitiesMode.Full, GenerateAllSubthemes = false, }; try { var html = default(string); #region [.result.] switch (lp.ProcessType) { case ProcessTypeEnum.Digest: #region [.code.] { lingvisticsInput.Options = LingvisticsResultOptions.OpinionMiningWithTonality; var lingvisticResult = ConcurrentFactoryHelper.ProcessText(lingvisticsInput); html = ConvertToHtml(lp.Context, lingvisticResult.OpinionMiningWithTonalityResult); } break; #endregion case ProcessTypeEnum.TonalityMarking: #region [.code.] { lingvisticsInput.TonalityMarkingInput = new TonalityMarkingInputParams4InProcess(); if (!lp.InquiryText.IsNullOrWhiteSpace()) { lingvisticsInput.TonalityMarkingInput.InquiriesSynonyms = lp.InquiryText.ToTextList(); } lingvisticsInput.ObjectAllocateMethod = lp.ObjectAllocateMethod.GetValueOrDefault(ObjectAllocateMethod.FirstVerbEntityWithRoleObj); lingvisticsInput.Options = LingvisticsResultOptions.Tonality; var lingvisticResult = ConcurrentFactoryHelper.ProcessText(lingvisticsInput); html = ConvertToHtml(lp.Context, lingvisticResult.TonalityResult, lp.OutputType); } break; #endregion default: throw (new ArgumentException(lp.ProcessType.ToString())); } #endregion if (!lp.TextIsDummy) { LogManager.GetLogger(string.Empty)?.Info($"'{lp.ProcessType}', TEXT: '{lp.Text}'"); } return(html); } catch (Exception ex) { LogManager.GetLogger(string.Empty)?.Error($"'{lp.ProcessType}', TEXT: '{lp.Text}'", ex); throw; } }