Пример #1
0
        public static List <Pullenti.Ner.ReferentToken> CreateReferents(DateExToken et)
        {
            if (!et.IsDiap || et.ItemsTo.Count == 0)
            {
                List <Pullenti.Ner.ReferentToken> li = _createRefs(et.ItemsFrom);
                if (li == null || li.Count == 0)
                {
                    return(null);
                }
                return(li);
            }
            List <Pullenti.Ner.ReferentToken> liFr = _createRefs(et.ItemsFrom);
            List <Pullenti.Ner.ReferentToken> liTo = _createRefs(et.ItemsTo);

            Pullenti.Ner.Date.DateRangeReferent ra = new Pullenti.Ner.Date.DateRangeReferent();
            if (liFr.Count > 0)
            {
                ra.DateFrom = liFr[0].Tag as Pullenti.Ner.Date.DateReferent;
            }
            if (liTo.Count > 0)
            {
                ra.DateTo = liTo[0].Tag as Pullenti.Ner.Date.DateReferent;
            }
            List <Pullenti.Ner.ReferentToken> res = new List <Pullenti.Ner.ReferentToken>();

            res.AddRange(liFr);
            res.AddRange(liTo);
            res.Add(new Pullenti.Ner.ReferentToken(ra, et.BeginToken, et.EndToken));
            if (res.Count == 0)
            {
                return(null);
            }
            res[0].Tag = ra;
            return(res);
        }
Пример #2
0
        public static void AppendToString2(Pullenti.Ner.Date.DateRangeReferent dr, StringBuilder res)
        {
            DateTime dt0;
            DateTime dt1;
            DateTime cur = (Pullenti.Ner.ProcessorService.DebugCurrentDateTime == null ? DateTime.Now : Pullenti.Ner.ProcessorService.DebugCurrentDateTime.Value);

            if (!DateRelHelper.CalculateDateRange2(dr, cur, out dt0, out dt1, 0))
            {
                return;
            }
            _appendDates(cur, dt0, dt1, res);
        }
Пример #3
0
        public static bool CalculateDateRange2(Pullenti.Ner.Date.DateRangeReferent dr, DateTime now, out DateTime from, out DateTime to, int tense)
        {
            from = DateTime.MinValue;
            to   = DateTime.MaxValue;
            DateTime dt0;
            DateTime dt1;

            if (dr.DateFrom == null)
            {
                if (dr.DateTo == null)
                {
                    return(false);
                }
                if (!CalculateDateRange(dr.DateTo, now, out dt0, out dt1, tense))
                {
                    return(false);
                }
                to = dt1;
                return(true);
            }
            else if (dr.DateTo == null)
            {
                if (!CalculateDateRange(dr.DateFrom, now, out dt0, out dt1, tense))
                {
                    return(false);
                }
                from = dt0;
                return(true);
            }
            if (!CalculateDateRange(dr.DateFrom, now, out dt0, out dt1, tense))
            {
                return(false);
            }
            from = dt0;
            DateTime dt2;
            DateTime dt3;

            if (!CalculateDateRange(dr.DateTo, now, out dt2, out dt3, tense))
            {
                return(false);
            }
            to = dt3;
            return(true);
        }