示例#1
0
        private static void ForceLoadModel()
        {
            if (LingvisticsWorkInProcessorHelper.IsCreated)
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                lock ( _SyncLockForceLoadModel )
                {
                    if (LingvisticsWorkInProcessorHelper.IsCreated)
                    {
                        return;
                    }

                    try
                    {
                        //---Log.Info( "start 'ForceLoadModel'" );

                        var result = LingvisticsWorkInProcessorHelper.ProcessText(LocalParams.CreateLingvisticsTextInput4TextDummy());
                        Console.WriteLine(((result.IsNotNull() && result.RDF.IsNotNull()) ? result.RDF.Length : 0));

                        //---Log.Info( "end 'ForceLoadModel', IsCreated: " + LingvisticsWorkInProcessorHelper.IsCreated );
                    }
                    catch (Exception ex)
                    {
                        Log.Error("error 'ForceLoadModel'", ex);
                    }
                }
            }, TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness);
        }
示例#2
0
        private static string GetResultHtml(LocalParams lp)
        {
            var lingvisticsInput = new LingvisticsTextInput()
            {
                Text = lp.Text,
                AfterSpellChecking = false,
                BaseDate           = DateTime.Now,
                Mode = SelectEntitiesMode.Full,
                GenerateAllSubthemes = false,
            };

            if (lingvisticsInput.Text.IsNullOrWhiteSpace())
            {
                return("<div style='text-align: center; border: 1px silver solid; border-radius: 2px; background: lightgray; color: darkgray; padding: 15px;'>[INPUT TEXT IS EMPTY]</div>");
            }

            try
            {
                var html = default(string);

                #region [.result.]
                switch (lp.ProcessType)
                {
                case ProcessTypeEnum.Digest:
                    #region [.code.]
                {
                    lingvisticsInput.Options = LingvisticsResultOptions.OpinionMiningWithTonality;

                    var lingvisticResult = LingvisticsWorkInProcessorHelper.ProcessText(lingvisticsInput);

                    html = ConvertToHtml(lp.Context, lingvisticResult.OpinionMiningWithTonalityResult);
                }
                    #endregion
                    break;

                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 = LingvisticsWorkInProcessorHelper.ProcessText(lingvisticsInput);

                    html = ConvertToHtml(lp.Context, lingvisticResult.TonalityResult, lp.OutputType);
                }
                    #endregion
                    break;

                default:
                    throw (new ArgumentException(lp.ProcessType.ToString()));
                }
                #endregion

                if (!lp.IsTextDummy)
                {
                    Log.Info(ref lp);
                }

                return(html);
            }
            catch (Exception ex)
            {
                Log.Error(ref lp, ex);
                throw;
            }
        }