public static DigestOutputResult ExecuteDigestInprocWithLinguisticService(
            XDocument rdf, ICoreferenceInfo coreferenceInfo, ObjectAllocateMethod objectAllocateMethod)
        {
            #region [.check input.]
            rdf.ThrowIfNull("rdf");
            #endregion

            #region [.process.]
            rdf = Algorithms.PreprocessRdf(rdf);

            var opinionMiningResult = OpinionMiningWcfService.ExecuteOpinionMiningInprocWithLinguisticService(
                rdf, false, objectAllocateMethod, coreferenceInfo);

            var inputParams = new DigestInputParams("[NEVER MIND]", InputTextFormat.LinguisticXml)
            {
                ExecuteTonalityMarking = true,
                ObjectAllocateMethod   = objectAllocateMethod,
            };

            var digestTuples = GenerateResult(opinionMiningResult, inputParams.ExecuteTonalityMarking, inputParams);
            #endregion

            #region [.result.]
            return(new DigestOutputResult(digestTuples, opinionMiningResult.OperateRulesNames));

            #endregion
        }
        /*
         * private DigestOutputResult ExecuteDigest__( DigestInputParams inputParams )
         * {
         *  var workingAppDomain = default(AppDomain);
         *  if ( !_WorkingAppDomains.TryGetValue( Thread.CurrentThread.ManagedThreadId, out workingAppDomain ) )
         *  {
         *      workingAppDomain = AppDomain.CreateDomain( Thread.CurrentThread.ManagedThreadId.ToString() );
         *      _WorkingAppDomains.TryAdd( Thread.CurrentThread.ManagedThreadId, workingAppDomain );
         *  }
         *
         *  workingAppDomain.SetData( "inputParams", inputParams );
         *
         *  workingAppDomain.DoCallBack( new CrossAppDomainDelegate( ExecuteDigestInWorkingAppDomain ) );
         *
         *  var bytes = (byte[]) workingAppDomain.GetData( "result" );
         *
         *  using ( var ms = new MemoryStream( bytes ) )
         *  {
         *      var result = (DigestOutputResult) _BinaryFormatter.Deserialize( ms );
         *
         *      return (result);
         *  }
         * }
         *
         * private static readonly System.Collections.Concurrent.ConcurrentDictionary< int, AppDomain > _WorkingAppDomains =
         *                  new System.Collections.Concurrent.ConcurrentDictionary< int, AppDomain >();
         * private static readonly BinaryFormatter _BinaryFormatter = new BinaryFormatter();
         *
         * private static void ExecuteDigestInWorkingAppDomain()
         * {
         *  var currentDomain = AppDomain.CurrentDomain;
         *
         *  var inputParams = (DigestInputParams) currentDomain.GetData("inputParams");
         *  using ( var e = new AutoResetEvent( false ) )
         *  {
         *      var workingThread = new Thread( ThreadRoutine );
         *      workingThread.Priority = ThreadPriority.Highest;
         *      workingThread.TrySetApartmentState( ApartmentState.STA );
         *      workingThread.DisableComObjectEagerCleanup();
         *      workingThread.Start( new object[] { e, inputParams } );
         *
         *      e.WaitOne();
         *      workingThread.Join();
         *  }
         * }
         * private static void ThreadRoutine( object state )
         * {
         *  var e = (AutoResetEvent) ((object[])state)[ 0 ];
         *  e.Set();
         *
         *  var inputParams = (DigestInputParams)((object[])state)[ 1 ];
         *
         *  var result = (new DigestWcfService()).ExecuteDigest__( inputParams );
         *
         *  using ( var ms = new MemoryStream() )
         *  {
         *      _BinaryFormatter.Serialize( ms, result );
         *
         *      var bytes = ms.GetBuffer();
         *
         *      AppDomain.CurrentDomain.SetData( "result", bytes );
         *  }
         * }
         */
        #endregion

        #region [.commented. delegate-BeginInvoke-variant.]

        /*
         * private readonly Func< DigestInputParams, DigestOutputResult > _ExecuteDigestFunc;
         */
        #endregion
        public IAsyncResult BeginExecuteDigestAsync(DigestInputParams inputParams, AsyncCallback callback, object state)
        {
            #region [.commented. task-variant.]

            /*
             * var task = Task.Factory.StartNew< DigestOutputResult >( _ => ExecuteDigest( inputParams ), state, TaskCreationOptions.LongRunning );
             *
             * if ( callback != null )
             * {
             *  task.ContinueWith( (res) => callback( task ) );
             * }
             * return (task);
             */
            #endregion

            #region [.commented. delegate-BeginInvoke-variant.]

            /*
             * var result = _ExecuteDigestFunc.BeginInvoke( inputParams, callback, executeDigestFunc );
             *
             * return (result);
             */
            #endregion

            return(new ExecuteDigestAsyncResult(this, inputParams, callback, state));
        }
        public static OpinionMiningInputParams ToOpinionMiningInputParams(this DigestInputParams inputParams)
        {
            var omParams = new OpinionMiningInputParams(inputParams.InputText, inputParams.InputTextFormat)
            {
                InquiriesSynonyms = inputParams.InquiriesSynonyms,
                //OutputXmlFormat      = OutputXmlFormat.Full, //!IMPORTANT! //inputParams.OutputXmlFormat,
                LanguageType         = inputParams.LanguageType,
                ThemeType            = inputParams.ThemeType,
                ObjectAllocateMethod = inputParams.ObjectAllocateMethod,
            };

            return(omParams);
        }
        public ExecuteDigestAsyncResult(IDigest idigest, DigestInputParams inputParams, AsyncCallback callback, object state)
            : base(callback, state)
        {
            this._IDigest           = idigest;
            this._DigestInputParams = inputParams;

            using (var e = new AutoResetEvent(false))
            {
                var workingThread = new Thread(ThreadRoutine);
                workingThread.Start(e);

                e.WaitOne();
            }
        }
        public DigestOutputResult ExecuteDigest(DigestInputParams inputParams)
        {
            try
            {
                #region [.check input.]
                inputParams.ThrowIfNull("inputParams");
                #endregion

                #region [.process.]
                var stopwatch           = Stopwatch.StartNew();
                var opinionMiningResult = this.ExecuteOpinionMining(inputParams.ToOpinionMiningInputParams());

                var digestTuples = GenerateResult(opinionMiningResult, inputParams.ExecuteTonalityMarking, inputParams);

                #region commented

                /*var digestTuples = default(IEnumerable< DigestTuple >);
                 * if ( inputParams.ExecuteTonalityMarking )
                 * {
                 *  var digestTuplesList = new List< DigestTuple >( opinionMiningResult.Tuples.Count );
                 *  foreach ( var tuple in opinionMiningResult.Tuples )
                 *  {
                 *      if ( tuple.HasObject )
                 *      {
                 *          var tonalityMarkingResult = _TonalityMarking.ExecuteTonalityMarking4DigestWcfService( tuple.Sentence, inputParams );
                 *
                 *          digestTuplesList.Add( tuple.ToDigestTuple( tonalityMarkingResult ) );
                 *      }
                 *      else
                 *      {
                 *          digestTuplesList.Add( tuple.ToDigestTuple( inputParams ) );
                 *      }
                 *  }
                 *  digestTuples = digestTuplesList;
                 * }
                 * else
                 * {
                 *  digestTuples = from tuple in opinionMiningResult.Tuples
                 *                 select tuple.ToDigestTuple( inputParams );
                 * }*/
                #endregion
                stopwatch.Stop();
                #endregion

                #region [.write in log.]
                LOG.InfoEx(MethodBase.GetCurrentMethod().Name, WcfHelper.ClientRemoteAddress, stopwatch.Elapsed, inputParams);
                #endregion

                #region [.result.]
                return(new DigestOutputResult(digestTuples, opinionMiningResult.OperateRulesNames));

                #endregion
            }
            catch (Exception ex)
            {
                #region [.write error in log & rethrow.]
                LOG.ErrorEx(MethodBase.GetCurrentMethod().Name, ex, WcfHelper.ClientRemoteAddress, inputParams);
                throw;
                #endregion
            }
        }
 public IAsyncResult BeginExecuteDigestAsync(DigestInputParams inputParams, AsyncCallback callback, object state)
 {
     throw new NotImplementedException();
 }
 public DigestOutputResult ExecuteDigestAsync(DigestInputParams inputParams)
 {
     return(_DigestClient.ExecuteDigestAsync(inputParams));
 }