public TonalityMarkingOutputResult4Blogs Processing(TonalityMarkingInputParams4Blogs inputParams)
        {
            //1.
            var bps = new BlogsProcessingStructureTPL(inputParams);

            //2.
            ProcessingRecurrent(PairTPL.Create(bps));

            //3.
            var result = new TonalityMarkingOutputResult4Blogs
                         (
                bps.Tuples,
                RuleBase.GetOperateRulesNamesDebugInfoOutput()
                         );

            return(result);
        }
        private void ProcessingRecurrent(PairTPL p)
        {
            if (p == null)
            {
                Debugger.Break();
            }

            var posts = ((p.pps.Level == 0)
                        ? p.bps.InputParams4Blogs.InputXml.GetMultiNodes(p.pps.Xpath4SelectPosts)
                        : p.bps.InputParams4Blogs.InputXml.XPathSelectElements(p.pps.Xpath4SelectPosts)).ToArray();

            Parallel.ForEach
            (
                posts,
                () => p, //p.CreateCopy,
                PostProcessing,
                (_) => { }
            );
        }
        private PairTPL PostProcessing(XElement post, ParallelLoopState loopstate, PairTPL p)
        {
            if (p == null)
            {
                Debugger.Break();
            }

            //1. - paralell
            var body = post.GetSingleNode(BlogsConsts.BODY).Value;

            if (body.IsEmptyOrNull())
            {
                return(p);
            }

            var continueProcessing = true;
            var tmResult           = _TonalityMarking.ExecuteTonalityMarking(p.bps.CreateTMInputParamsYesInquiries(body));

            if (tmResult.InquiryAllocateStatus == InquiryAllocateStatus.NotAllocated)
            {
                if (p.pps.Level == 0)
                {
                    return(p);
                }

                tmResult = _TonalityMarking.ExecuteTonalityMarking(p.bps.CreateTMInputParamsNoInquiries(tmResult));
                if (tmResult.InquiryAllocateStatus == InquiryAllocateStatus.NotAllocated)
                {
                    return(p);
                }
                continueProcessing = false;
            }

            //2.
            var outputXml = default(string);

            switch (p.bps.InputParams4Blogs.OutputBlogsFormat)
            {
            case OutputBlogsFormat.LinguisticXml:
                outputXml = tmResult.OutputXml;
                break;

            case OutputBlogsFormat.Offsets:
                var offsetsProcessor = new OffsetsProcessor(/*body*/);
                var offsets          = offsetsProcessor.CreateOffsetsString(tmResult.GetOutputXDocument().Root);
                outputXml = offsets;
                break;

            default: throw (new ArgumentException(p.bps.InputParams4Blogs.OutputBlogsFormat.ToString()));
            }

            //3.
            var id = post.GetSingleNode(BlogsConsts.ID).Value;
            //var parent = post.GetSingleNode( BlogsConsts.PARENT ).Value;
            //var level  = post.GetSingleNode( BlogsConsts.LEVEL  ).Value;
            var tuple = new TonalityMarkingTuple4Blogs
                        (
                id,
                outputXml,
                p.bps.InputParams4Blogs.OutputBlogsFormat,
                tmResult.AuthorTonalityMarkingTuple.Positive,
                tmResult.AuthorTonalityMarkingTuple.Negative,
                tmResult.AuthorTonalityMarkingTuple.Objects //GetOutputXmlXDocument().ExtractObjects()
                        );

            p.bps.Tuples.Add(tuple);

            //4.
            if (continueProcessing)
            {
                ProcessingRecurrent(p.Create(id));
            }

            return(p);
        }