Exemple #1
0
        public static void AnalizeEditions(FragToken root)
        {
            if (root.Number == 6 && root.Kind == Pullenti.Ner.Instrument.InstrumentKind.Subitem)
            {
            }
            if (root.SubNumber == 67)
            {
            }
            if (root.Children.Count > 1 && root.Children[0].Kind == Pullenti.Ner.Instrument.InstrumentKind.Number && root.Children[1].Kind == Pullenti.Ner.Instrument.InstrumentKind.Content)
            {
                if (root.Children[1].BeginToken.IsValue("УТРАТИТЬ", "ВТРАТИТИ") && root.Children[1].BeginToken.Next != null && root.Children[1].BeginToken.Next.IsValue("СИЛА", "ЧИННІСТЬ"))
                {
                    root.IsExpired = true;
                }
            }
            if ((!root.IsExpired && root.Kind == Pullenti.Ner.Instrument.InstrumentKind.Indention && root.BeginToken.IsValue("АБЗАЦ", null)) && root.BeginToken.Next != null && root.BeginToken.Next.IsValue("УТРАТИТЬ", "ВТРАТИТИ"))
            {
                root.IsExpired = true;
            }
            if (root.IsExpired || ((root.Itok != null && root.Itok.IsExpired)))
            {
                root.IsExpired = true;
                if (root.Referents == null)
                {
                    root.Referents = new List <Pullenti.Ner.Referent>();
                }
                for (Pullenti.Ner.Token tt = root.BeginToken; tt != null && tt.EndChar <= root.EndChar; tt = tt.Next)
                {
                    Pullenti.Ner.Decree.DecreeReferent dec = tt.GetReferent() as Pullenti.Ner.Decree.DecreeReferent;
                    if (dec != null)
                    {
                        if (!root.Referents.Contains(dec))
                        {
                            root.Referents.Add(dec);
                        }
                    }
                }
                return;
            }
            int i0;

            for (i0 = 0; i0 < root.Children.Count; i0++)
            {
                FragToken ch = root.Children[i0];
                if (((ch.Kind == Pullenti.Ner.Instrument.InstrumentKind.Comment || ch.Kind == Pullenti.Ner.Instrument.InstrumentKind.Keyword || ch.Kind == Pullenti.Ner.Instrument.InstrumentKind.Number) || ch.Kind == Pullenti.Ner.Instrument.InstrumentKind.Name || ch.Kind == Pullenti.Ner.Instrument.InstrumentKind.Content) || ch.Kind == Pullenti.Ner.Instrument.InstrumentKind.Indention)
                {
                }
                else
                {
                    break;
                }
            }
            if (root.Number > 0)
            {
                FragToken edt1 = _getLastChild(root);
                if (edt1 != null && edt1.Kind == Pullenti.Ner.Instrument.InstrumentKind.Editions && edt1.Tag == null)
                {
                    if (_canBeEditionFor(root, edt1) > 0)
                    {
                        if (root.Referents == null)
                        {
                            root.Referents = edt1.Referents;
                        }
                        else
                        {
                            foreach (Pullenti.Ner.Referent r in edt1.Referents)
                            {
                                if (!root.Referents.Contains(r))
                                {
                                    root.Referents.Add(r);
                                }
                            }
                        }
                        edt1.Tag = edt1;
                    }
                }
            }
            if (i0 >= root.Children.Count)
            {
                foreach (FragToken ch in root.Children)
                {
                    AnalizeEditions(ch);
                }
                return;
            }
            FragToken ch0 = root.Children[i0];
            bool      ok  = false;

            if (_canBeEditionFor(root, ch0) >= 0)
            {
                ok = true;
                if (i0 > 0 && ((root.Children[i0 - 1].Kind == Pullenti.Ner.Instrument.InstrumentKind.Content || root.Children[i0 - 1].Kind == Pullenti.Ner.Instrument.InstrumentKind.Indention)) && ((i0 + 1) < root.Children.Count))
                {
                    if (_canBeEditionFor(root.Children[i0 - 1], ch0) >= 0)
                    {
                        ok = false;
                    }
                }
            }
            if (((i0 + 1) < root.Children.Count) && _canBeEditionFor(root, root.Children[root.Children.Count - 1]) >= 0 && (_canBeEditionFor(root.Children[root.Children.Count - 1], root.Children[root.Children.Count - 1]) < 0))
            {
                ok  = true;
                ch0 = root.Children[root.Children.Count - 1];
            }
            if (ok && ch0.Tag == null)
            {
                if (root.Referents == null)
                {
                    root.Referents = ch0.Referents;
                }
                else
                {
                    foreach (Pullenti.Ner.Referent r in ch0.Referents)
                    {
                        if (!root.Referents.Contains(r))
                        {
                            root.Referents.Add(r);
                        }
                    }
                }
                ch0.Tag = ch0;
            }
            for (int i = 0; i < root.Children.Count; i++)
            {
                FragToken ch   = root.Children[i];
                FragToken edt  = null;
                FragToken edt2 = null;
                if (ch.Number > 0 && i > 0)
                {
                    edt = _getLastChild(root.Children[i - 1]);
                }
                if (((i + 1) < root.Children.Count) && root.Children[i + 1].Kind == Pullenti.Ner.Instrument.InstrumentKind.Editions)
                {
                    edt2 = root.Children[i + 1];
                }
                if (edt != null)
                {
                    if (_canBeEditionFor(ch, edt) < 1)
                    {
                        edt = null;
                    }
                }
                if (edt2 != null)
                {
                    if (_canBeEditionFor(ch, edt2) < 0)
                    {
                        edt2 = null;
                    }
                }
                if (edt != null && edt.Tag == null)
                {
                    if (ch.Referents == null)
                    {
                        ch.Referents = edt.Referents;
                    }
                    else
                    {
                        foreach (Pullenti.Ner.Referent r in edt.Referents)
                        {
                            if (!ch.Referents.Contains(r))
                            {
                                ch.Referents.Add(r);
                            }
                        }
                    }
                    edt.Tag = ch;
                }
                if (edt2 != null && edt2.Tag == null)
                {
                    if (ch.Referents == null)
                    {
                        ch.Referents = edt2.Referents;
                    }
                    else
                    {
                        foreach (Pullenti.Ner.Referent r in edt2.Referents)
                        {
                            if (!ch.Referents.Contains(r))
                            {
                                ch.Referents.Add(r);
                            }
                        }
                    }
                    edt2.Tag = ch;
                }
            }
            foreach (FragToken ch in root.Children)
            {
                AnalizeEditions(ch);
            }
        }
Exemple #2
0
        public static CanonicDecreeRefUri TryCreateCanonicDecreeRefUri(Pullenti.Ner.Token t)
        {
            if (!(t is Pullenti.Ner.ReferentToken))
            {
                return(null);
            }
            Pullenti.Ner.Decree.DecreeReferent dr = t.GetReferent() as Pullenti.Ner.Decree.DecreeReferent;
            CanonicDecreeRefUri res;

            if (dr != null)
            {
                if (dr.Kind == Pullenti.Ner.Decree.DecreeKind.Publisher)
                {
                    return(null);
                }
                res = new CanonicDecreeRefUri(t.Kit.Sofa.Text)
                {
                    Ref = dr, BeginChar = t.BeginChar, EndChar = t.EndChar
                };
                if ((t.Previous != null && t.Previous.IsChar('(') && t.Next != null) && t.Next.IsChar(')'))
                {
                    return(res);
                }
                if ((t as Pullenti.Ner.ReferentToken).MiscAttrs != 0)
                {
                    return(res);
                }
                Pullenti.Ner.ReferentToken rt = t as Pullenti.Ner.ReferentToken;
                if (rt.BeginToken.IsChar('(') && rt.EndToken.IsChar(')'))
                {
                    res = new CanonicDecreeRefUri(t.Kit.Sofa.Text)
                    {
                        Ref = dr, BeginChar = rt.BeginToken.Next.BeginChar, EndChar = rt.EndToken.Previous.EndChar
                    };
                    return(res);
                }
                List <DecreeToken> nextDecreeItems = null;
                if ((t.Next != null && t.Next.IsCommaAnd && (t.Next.Next is Pullenti.Ner.ReferentToken)) && (t.Next.Next.GetReferent() is Pullenti.Ner.Decree.DecreeReferent))
                {
                    nextDecreeItems = DecreeToken.TryAttachList((t.Next.Next as Pullenti.Ner.ReferentToken).BeginToken, null, 10, false);
                    if (nextDecreeItems != null && nextDecreeItems.Count > 1)
                    {
                        for (int i = 0; i < (nextDecreeItems.Count - 1); i++)
                        {
                            if (nextDecreeItems[i].IsNewlineAfter)
                            {
                                nextDecreeItems.RemoveRange(i + 1, nextDecreeItems.Count - i - 1);
                                break;
                            }
                        }
                    }
                }
                bool wasTyp = false;
                bool wasNum = false;
                for (Pullenti.Ner.Token tt = (t as Pullenti.Ner.MetaToken).BeginToken; tt != null && tt.EndChar <= t.EndChar; tt = tt.Next)
                {
                    if (tt.BeginChar == t.BeginChar && tt.IsChar('(') && tt.Next != null)
                    {
                        res.BeginChar = tt.Next.BeginChar;
                    }
                    if (tt.IsChar('(') && tt.Next != null && tt.Next.IsValue("ДАЛЕЕ", null))
                    {
                        if (res.EndChar >= tt.BeginChar)
                        {
                            res.EndChar = tt.Previous.EndChar;
                        }
                        break;
                    }
                    if (tt.EndChar == t.EndChar && tt.IsChar(')'))
                    {
                        res.EndChar = tt.Previous.EndChar;
                        for (Pullenti.Ner.Token tt1 = tt.Previous; tt1 != null && tt1.BeginChar >= res.BeginChar; tt1 = tt1.Previous)
                        {
                            if (tt1.IsChar('(') && tt1.Previous != null)
                            {
                                if (res.BeginChar < tt1.Previous.BeginChar)
                                {
                                    res.EndChar = tt1.Previous.EndChar;
                                }
                            }
                        }
                    }
                    List <DecreeToken> li = DecreeToken.TryAttachList(tt, null, 10, false);
                    if (li != null && li.Count > 0)
                    {
                        for (int ii = 0; ii < (li.Count - 1); ii++)
                        {
                            if (li[ii].Typ == DecreeToken.ItemType.Typ && li[ii + 1].Typ == DecreeToken.ItemType.Terr)
                            {
                                res.TypeWithGeo = Pullenti.Ner.Core.MiscHelper.GetTextValue(li[ii].BeginToken, li[ii + 1].EndToken, Pullenti.Ner.Core.GetTextAttr.FirstNounGroupToNominativeSingle);
                            }
                        }
                        if ((nextDecreeItems != null && nextDecreeItems.Count > 1 && (nextDecreeItems.Count < li.Count)) && nextDecreeItems[0].Typ != DecreeToken.ItemType.Typ)
                        {
                            int d = li.Count - nextDecreeItems.Count;
                            int j;
                            for (j = 0; j < nextDecreeItems.Count; j++)
                            {
                                if (nextDecreeItems[j].Typ != li[d + j].Typ)
                                {
                                    break;
                                }
                            }
                            if (j >= nextDecreeItems.Count)
                            {
                                li.RemoveRange(0, d);
                                res.BeginChar = li[0].BeginChar;
                            }
                        }
                        else if ((nextDecreeItems != null && nextDecreeItems.Count == 1 && nextDecreeItems[0].Typ == DecreeToken.ItemType.Name) && li.Count == 2 && li[1].Typ == DecreeToken.ItemType.Name)
                        {
                            res.BeginChar = li[1].BeginChar;
                            res.EndChar   = li[1].EndChar;
                            break;
                        }
                        else if ((nextDecreeItems != null && nextDecreeItems.Count == 1 && nextDecreeItems[0].Typ == DecreeToken.ItemType.Number) && li[li.Count - 1].Typ == DecreeToken.ItemType.Number)
                        {
                            res.BeginChar = li[li.Count - 1].BeginChar;
                            res.EndChar   = li[li.Count - 1].EndChar;
                        }
                        for (int i = 0; i < li.Count; i++)
                        {
                            DecreeToken l = li[i];
                            if (l.BeginChar > t.EndChar)
                            {
                                li.RemoveRange(i, li.Count - i);
                                break;
                            }
                            if (l.Typ == DecreeToken.ItemType.Name)
                            {
                                if (!wasNum)
                                {
                                    if (dr.Kind == Pullenti.Ner.Decree.DecreeKind.Contract)
                                    {
                                        continue;
                                    }
                                    if (((i + 1) < li.Count) && ((li[i + 1].Typ == DecreeToken.ItemType.Date || li[i + 1].Typ == DecreeToken.ItemType.Number)))
                                    {
                                        continue;
                                    }
                                }
                                int ee = l.BeginToken.Previous.EndChar;
                                if (ee > res.BeginChar && (ee < res.EndChar))
                                {
                                    res.EndChar = ee;
                                }
                                break;
                            }
                            if (l.Typ == DecreeToken.ItemType.Number)
                            {
                                wasNum = true;
                            }
                            if (i == 0)
                            {
                                if (l.Typ == DecreeToken.ItemType.Typ)
                                {
                                    wasTyp = true;
                                }
                                else if (l.Typ == DecreeToken.ItemType.Owner || l.Typ == DecreeToken.ItemType.Org)
                                {
                                    if (((i + 1) < li.Count) && ((li[1].Typ == DecreeToken.ItemType.Date || li[1].Typ == DecreeToken.ItemType.Number)))
                                    {
                                        wasTyp = true;
                                    }
                                }
                                if (wasTyp)
                                {
                                    Pullenti.Ner.Token tt0 = l.BeginToken.Previous;
                                    if (tt0 != null && tt0.IsChar('.'))
                                    {
                                        tt0 = tt0.Previous;
                                    }
                                    if (tt0 != null && ((tt0.IsValue("УТВЕРЖДЕННЫЙ", null) || tt0.IsValue("УТВЕРДИТЬ", null) || tt0.IsValue("УТВ", null))))
                                    {
                                        if (l.BeginChar > res.BeginChar)
                                        {
                                            res.BeginChar = l.BeginChar;
                                            if (res.EndChar < res.BeginChar)
                                            {
                                                res.EndChar = t.EndChar;
                                            }
                                            res.IsAdopted = true;
                                        }
                                    }
                                }
                            }
                        }
                        if (li.Count > 0)
                        {
                            tt = li[li.Count - 1].EndToken;
                            if (tt.IsChar(')'))
                            {
                                tt = tt.Previous;
                            }
                            continue;
                        }
                    }
                    if (wasTyp)
                    {
                        DecreeToken na = DecreeToken.TryAttachName(tt, dr.Typ0, true, false);
                        if (na != null && tt.BeginChar > t.BeginChar)
                        {
                            Pullenti.Ner.Token tt1 = na.EndToken.Next;
                            if (tt1 != null && tt1.IsCharOf(",()"))
                            {
                                tt1 = tt1.Next;
                            }
                            if (tt1 != null && (tt1.EndChar < t.EndChar))
                            {
                                if (tt1.IsValue("УТВЕРЖДЕННЫЙ", null) || tt1.IsValue("УТВЕРДИТЬ", null) || tt1.IsValue("УТВ", null))
                                {
                                    tt = tt1;
                                    continue;
                                }
                            }
                            if (tt.Previous != null && tt.Previous.IsChar(':') && na.EndChar <= res.EndChar)
                            {
                                res.BeginChar = tt.BeginChar;
                                break;
                            }
                            if (tt.Previous.EndChar > res.BeginChar)
                            {
                                res.EndChar = tt.Previous.EndChar;
                                break;
                            }
                        }
                    }
                }
                return(res);
            }
            Pullenti.Ner.Decree.DecreePartReferent dpr = t.GetReferent() as Pullenti.Ner.Decree.DecreePartReferent;
            if (dpr == null)
            {
                return(null);
            }
            if ((t.Previous != null && t.Previous.IsHiphen && (t.Previous.Previous is Pullenti.Ner.ReferentToken)) && (t.Previous.Previous.GetReferent() is Pullenti.Ner.Decree.DecreePartReferent))
            {
                if (Pullenti.Ner.Decree.DecreePartReferent.CreateRangeReferent(t.Previous.Previous.GetReferent() as Pullenti.Ner.Decree.DecreePartReferent, dpr) != null)
                {
                    return(null);
                }
            }
            Pullenti.Ner.Token t1 = t;
            bool hasDiap          = false;

            Pullenti.Ner.ReferentToken DiapRef = null;
            if ((t.Next != null && t.Next.IsHiphen && (t.Next.Next is Pullenti.Ner.ReferentToken)) && (t.Next.Next.GetReferent() is Pullenti.Ner.Decree.DecreePartReferent))
            {
                Pullenti.Ner.Decree.DecreePartReferent diap = Pullenti.Ner.Decree.DecreePartReferent.CreateRangeReferent(dpr as Pullenti.Ner.Decree.DecreePartReferent, t.Next.Next.GetReferent() as Pullenti.Ner.Decree.DecreePartReferent);
                if (diap != null)
                {
                    dpr     = diap;
                    hasDiap = true;
                    t1      = t.Next.Next;
                    DiapRef = t1 as Pullenti.Ner.ReferentToken;
                }
            }
            res = new CanonicDecreeRefUri(t.Kit.Sofa.Text)
            {
                Ref = dpr, BeginChar = t.BeginChar, EndChar = t1.EndChar, IsDiap = hasDiap
            };
            if ((t.Previous != null && t.Previous.IsChar('(') && t1.Next != null) && t1.Next.IsChar(')'))
            {
                return(res);
            }
            for (Pullenti.Ner.Token tt = (t as Pullenti.Ner.MetaToken).BeginToken; tt != null && tt.EndChar <= t.EndChar; tt = tt.Next)
            {
                if (tt.GetReferent() is Pullenti.Ner.Decree.DecreeReferent)
                {
                    if (tt.BeginChar > t.BeginChar)
                    {
                        res.EndChar = tt.Previous.EndChar;
                        if (tt.Previous.Morph.Class.IsPreposition && tt.Previous.Previous != null)
                        {
                            res.EndChar = tt.Previous.Previous.EndChar;
                        }
                    }
                    else if (tt.EndChar < t.EndChar)
                    {
                        res.BeginChar = tt.BeginChar;
                    }
                    break;
                }
            }
            bool hasSameBefore = _hasSameDecree(t, dpr, true);
            bool hasSameAfter  = _hasSameDecree(t, dpr, false);

            PartToken.ItemType ptmin  = PartToken.ItemType.Prefix;
            PartToken.ItemType ptmin2 = PartToken.ItemType.Prefix;
            int max  = 0;
            int max2 = 00;

            foreach (Pullenti.Ner.Slot s in dpr.Slots)
            {
                PartToken.ItemType pt = PartToken._getTypeByAttrName(s.TypeName);
                if (pt == PartToken.ItemType.Prefix)
                {
                    continue;
                }
                int co = PartToken._getRank(pt);
                if (co < 1)
                {
                    if (pt == PartToken.ItemType.Part && dpr.FindSlot(Pullenti.Ner.Decree.DecreePartReferent.ATTR_CLAUSE, null, true) != null)
                    {
                        co = PartToken._getRank(PartToken.ItemType.Paragraph);
                    }
                    else
                    {
                        continue;
                    }
                }
                if (co > max)
                {
                    max2   = max;
                    ptmin2 = ptmin;
                    max    = co;
                    ptmin  = pt;
                }
                else if (co > max2)
                {
                    max2   = co;
                    ptmin2 = pt;
                }
            }
            if (ptmin != PartToken.ItemType.Prefix)
            {
                for (Pullenti.Ner.Token tt = (t as Pullenti.Ner.MetaToken).BeginToken; tt != null && tt.EndChar <= res.EndChar; tt = tt.Next)
                {
                    if (tt.BeginChar >= res.BeginChar)
                    {
                        PartToken pt = PartToken.TryAttach(tt, null, false, false);
                        if (pt != null && pt.Typ == ptmin)
                        {
                            res.BeginChar = pt.BeginChar;
                            res.EndChar   = pt.EndChar;
                            if (pt.Typ == PartToken.ItemType.Appendix && pt.EndToken.IsValue("К", null) && pt.BeginToken != pt.EndToken)
                            {
                                res.EndChar = pt.EndToken.Previous.EndChar;
                            }
                            if (pt.EndChar == t.EndChar)
                            {
                                if ((t.Next != null && t.Next.IsCommaAnd && (t.Next.Next is Pullenti.Ner.ReferentToken)) && (t.Next.Next.GetReferent() is Pullenti.Ner.Decree.DecreePartReferent))
                                {
                                    Pullenti.Ner.Token tt1 = (t.Next.Next as Pullenti.Ner.ReferentToken).BeginToken;
                                    bool ok = true;
                                    if (tt1.Chars.IsLetter)
                                    {
                                        ok = false;
                                    }
                                    if (ok)
                                    {
                                        foreach (PartToken.PartValue v in pt.Values)
                                        {
                                            res.BeginChar = v.BeginChar;
                                            res.EndChar   = v.EndChar;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!hasDiap)
                            {
                                return(res);
                            }
                            break;
                        }
                    }
                }
                if (hasDiap && DiapRef != null)
                {
                    for (Pullenti.Ner.Token tt = DiapRef.BeginToken; tt != null && tt.EndChar <= DiapRef.EndChar; tt = tt.Next)
                    {
                        if (tt.IsChar(','))
                        {
                            break;
                        }
                        if (tt != DiapRef.BeginToken && tt.IsWhitespaceBefore)
                        {
                            break;
                        }
                        res.EndChar = tt.EndChar;
                    }
                    return(res);
                }
            }
            if (((hasSameBefore || hasSameAfter)) && ptmin != PartToken.ItemType.Prefix)
            {
                for (Pullenti.Ner.Token tt = (t as Pullenti.Ner.MetaToken).BeginToken; tt != null && tt.EndChar <= res.EndChar; tt = tt.Next)
                {
                    if (tt.BeginChar >= res.BeginChar)
                    {
                        PartToken pt = (!hasSameBefore ? PartToken.TryAttach(tt, null, false, false) : null);
                        if (pt != null)
                        {
                            if (pt.Typ == ptmin)
                            {
                                foreach (PartToken.PartValue v in pt.Values)
                                {
                                    res.BeginChar = v.BeginChar;
                                    res.EndChar   = v.EndChar;
                                    return(res);
                                }
                            }
                            tt = pt.EndToken;
                            continue;
                        }
                        if ((tt is Pullenti.Ner.NumberToken) && tt.BeginChar == res.BeginChar)
                        {
                            res.EndChar = tt.EndChar;
                            for (; tt != null && tt.Next != null;)
                            {
                                if (!tt.Next.IsChar('.') || tt.IsWhitespaceAfter || tt.Next.IsWhitespaceAfter)
                                {
                                    break;
                                }
                                if (!(tt.Next.Next is Pullenti.Ner.NumberToken))
                                {
                                    break;
                                }
                                tt          = tt.Next.Next;
                                res.EndChar = tt.EndChar;
                            }
                            if (tt.Next != null && tt.Next.IsHiphen)
                            {
                                if (tt.Next.Next is Pullenti.Ner.NumberToken)
                                {
                                    tt          = tt.Next.Next;
                                    res.EndChar = tt.EndChar;
                                    for (; tt != null && tt.Next != null;)
                                    {
                                        if (!tt.Next.IsChar('.') || tt.IsWhitespaceAfter || tt.Next.IsWhitespaceAfter)
                                        {
                                            break;
                                        }
                                        if (!(tt.Next.Next is Pullenti.Ner.NumberToken))
                                        {
                                            break;
                                        }
                                        tt          = tt.Next.Next;
                                        res.EndChar = tt.EndChar;
                                    }
                                }
                                else if (tt.Next.Next != null && (tt.Next.Next.GetReferent() is Pullenti.Ner.Decree.DecreePartReferent) && hasDiap)
                                {
                                    res.EndChar = (tt.Next.Next as Pullenti.Ner.MetaToken).BeginToken.EndChar;
                                }
                            }
                            return(res);
                        }
                        if (Pullenti.Ner.Core.BracketHelper.CanBeStartOfSequence(tt, true, false) && tt.BeginChar == res.BeginChar && hasSameBefore)
                        {
                            Pullenti.Ner.Core.BracketSequenceToken br = Pullenti.Ner.Core.BracketHelper.TryParse(tt, Pullenti.Ner.Core.BracketParseAttr.No, 100);
                            if (br != null && br.EndToken.Previous == tt.Next)
                            {
                                res.EndChar = br.EndChar;
                                return(res);
                            }
                        }
                    }
                }
                return(res);
            }
            if (!hasSameBefore && !hasSameAfter && ptmin != PartToken.ItemType.Prefix)
            {
                for (Pullenti.Ner.Token tt = (t as Pullenti.Ner.MetaToken).BeginToken; tt != null && tt.EndChar <= res.EndChar; tt = tt.Next)
                {
                    if (tt.BeginChar >= res.BeginChar)
                    {
                        List <PartToken> pts = PartToken.TryAttachList(tt, false, 40);
                        if (pts == null || pts.Count == 0)
                        {
                            break;
                        }
                        for (int i = 0; i < pts.Count; i++)
                        {
                            if (pts[i].Typ == ptmin)
                            {
                                res.BeginChar = pts[i].BeginChar;
                                res.EndChar   = pts[i].EndChar;
                                tt            = pts[i].EndToken;
                                if (tt.Next != null && tt.Next.IsHiphen)
                                {
                                    if (tt.Next.Next is Pullenti.Ner.NumberToken)
                                    {
                                        res.EndChar = tt.Next.Next.EndChar;
                                    }
                                    else if (tt.Next.Next != null && (tt.Next.Next.GetReferent() is Pullenti.Ner.Decree.DecreePartReferent) && hasDiap)
                                    {
                                        res.EndChar = (tt.Next.Next as Pullenti.Ner.MetaToken).BeginToken.EndChar;
                                    }
                                }
                                return(res);
                            }
                        }
                    }
                }
            }
            return(res);
        }