示例#1
0
        public override string ToString(bool shortVariant, Pullenti.Morph.MorphLang lang = null, int lev = 0)
        {
            StringBuilder res     = new StringBuilder();
            DecreeKind    ki      = Kind;
            bool          outPart = false;
            string        nam     = Name;

            if (Typ != null)
            {
                if ((nam != null && !nam.StartsWith("О") && nam.Contains(Typ)) && ki != DecreeKind.Standard)
                {
                    res.Append(Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(nam));
                    nam = null;
                }
                else if (ki == DecreeKind.Standard && (Typ.Length < 6))
                {
                    res.Append(Typ);
                }
                else
                {
                    res.Append(Pullenti.Ner.Core.MiscHelper.ConvertFirstCharUpperAndOtherLower(Typ));
                }
            }
            else
            {
                res.Append("?");
            }
            bool outSrc = true;

            if (ki == DecreeKind.Contract && this.FindSlot(ATTR_SOURCE, null, true) != null)
            {
                List <string> srcs = new List <string>();
                foreach (Pullenti.Ner.Slot s in Slots)
                {
                    if (s.TypeName == ATTR_SOURCE)
                    {
                        srcs.Add(s.Value.ToString());
                    }
                }
                if (srcs.Count > 1)
                {
                    for (int ii = 0; ii < srcs.Count; ii++)
                    {
                        if (ii > 0 && ((ii + 1) < srcs.Count))
                        {
                            res.Append(", ");
                        }
                        else if (ii > 0)
                        {
                            res.Append(" и ");
                        }
                        else
                        {
                            res.Append(" между ");
                        }
                        res.Append(srcs[ii]);
                        outSrc = false;
                    }
                }
            }
            string num = Number;

            if (num != null)
            {
                res.AppendFormat(" № {0}", num);
                foreach (Pullenti.Ner.Slot s in Slots)
                {
                    if (s.TypeName == ATTR_NUMBER)
                    {
                        string nn = s.Value.ToString();
                        if (nn != num)
                        {
                            res.AppendFormat("/{0}", nn);
                        }
                    }
                }
            }
            if ((((num = CaseNumber))) != null)
            {
                res.AppendFormat(" по делу № {0}", num);
            }
            if (this.GetStringValue(ATTR_DATE) != null)
            {
                res.AppendFormat(" {0}{1}", (ki == DecreeKind.Program ? "" : "от "), this.GetStringValue(ATTR_DATE));
            }
            if (outSrc && this.GetSlotValue(ATTR_SOURCE) != null)
            {
                res.AppendFormat("; {0}", this.GetStringValue(ATTR_SOURCE));
            }
            if (!shortVariant)
            {
                string s = this.GetStringValue(ATTR_GEO);
                if (s != null)
                {
                    res.AppendFormat("; {0}", s);
                }
                if (nam != null)
                {
                    s = this._getShortName();
                    if (s != null)
                    {
                        res.AppendFormat("; \"{0}\"", s);
                    }
                }
            }
            return(res.ToString().Trim());
        }
示例#2
0
        internal bool CheckCorrection(bool nounIsDoubtful)
        {
            string typ = Typ0;

            if (typ == null)
            {
                return(false);
            }
            if (typ == "КОНСТИТУЦИЯ" || typ == "КОНСТИТУЦІЯ")
            {
                return(true);
            }
            if (Typ == "ЕДИНЫЙ ОТРАСЛЕВОЙ СТАНДАРТ ЗАКУПОК")
            {
                return(true);
            }
            if ((typ == "КОДЕКС" || typ == "ОСНОВЫ ЗАКОНОДАТЕЛЬСТВА" || typ == "ПРОГРАММА") || typ == "ОСНОВИ ЗАКОНОДАВСТВА" || typ == "ПРОГРАМА")
            {
                if (this.FindSlot(ATTR_NAME, null, true) == null)
                {
                    return(false);
                }
                if (this.FindSlot(ATTR_GEO, null, true) != null)
                {
                    return(true);
                }
                return(!nounIsDoubtful);
            }
            if (typ.StartsWith("ОСНОВ"))
            {
                if (this.FindSlot(ATTR_GEO, null, true) != null)
                {
                    return(true);
                }
                return(false);
            }
            if (typ.Contains("ЗАКОН"))
            {
                if (this.FindSlot(ATTR_NAME, null, true) == null && Number == null)
                {
                    return(false);
                }
                return(true);
            }
            if ((((typ.Contains("ОПРЕДЕЛЕНИЕ") || typ.Contains("РЕШЕНИЕ") || typ.Contains("ПОСТАНОВЛЕНИЕ")) || typ.Contains("ПРИГОВОР") || typ.Contains("ВИЗНАЧЕННЯ")) || typ.Contains("РІШЕННЯ") || typ.Contains("ПОСТАНОВА")) || typ.Contains("ВИРОК"))
            {
                if (Number != null)
                {
                    if (this.FindSlot(ATTR_DATE, null, true) != null || this.FindSlot(ATTR_SOURCE, null, true) != null || this.FindSlot(ATTR_NAME, null, true) != null)
                    {
                        return(true);
                    }
                }
                else if (this.FindSlot(ATTR_DATE, null, true) != null && this.FindSlot(ATTR_SOURCE, null, true) != null)
                {
                    return(true);
                }
                return(false);
            }
            DecreeKind ty = Pullenti.Ner.Decree.Internal.DecreeToken.GetKind(typ);

            if (ty == DecreeKind.Ustav)
            {
                if (this.FindSlot(ATTR_SOURCE, null, true) != null)
                {
                    return(true);
                }
            }
            if (ty == DecreeKind.Konvention)
            {
                if (this.FindSlot(ATTR_NAME, null, true) != null)
                {
                    if (typ != "ДОГОВОР" && typ != "ДОГОВІР")
                    {
                        return(true);
                    }
                }
            }
            if (ty == DecreeKind.Standard)
            {
                if (Number != null && Number.Length > 4)
                {
                    return(true);
                }
            }
            if (Number == null)
            {
                if (this.FindSlot(ATTR_NAME, null, true) == null || this.FindSlot(ATTR_SOURCE, null, true) == null || this.FindSlot(ATTR_DATE, null, true) == null)
                {
                    if (ty == DecreeKind.Contract && this.FindSlot(ATTR_SOURCE, null, true) != null && this.FindSlot(ATTR_DATE, null, true) != null)
                    {
                    }
                    else if (this.FindSlot(ATTR_NAME, "ПРАВИЛА ДОРОЖНОГО ДВИЖЕНИЯ", true) != null)
                    {
                    }
                    else if (this.FindSlot(ATTR_NAME, "ПРАВИЛА ДОРОЖНЬОГО РУХУ", true) != null)
                    {
                    }
                    else if (Kind == DecreeKind.Project && this.FindSlot(ATTR_NAME, null, true) != null)
                    {
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if ((typ == "ПАСПОРТ" || typ == "ГОСТ" || typ == "ПБУ") || typ == "ФОРМА")
                {
                    return(true);
                }
                if (this.FindSlot(ATTR_SOURCE, null, true) == null && this.FindSlot(ATTR_DATE, null, true) == null && this.FindSlot(ATTR_NAME, null, true) == null)
                {
                    return(false);
                }
            }
            return(true);
        }
示例#3
0
        bool _CanBeEquals(Pullenti.Ner.Referent obj, Pullenti.Ner.Core.ReferentsEqualType typ, bool ignoreGeo)
        {
            DecreeReferent dr = obj as DecreeReferent;

            if (dr == null)
            {
                return(false);
            }
            if (dr.Typ0 != null && Typ0 != null)
            {
                if (dr.Typ0 != Typ0)
                {
                    return(false);
                }
            }
            int numEq = 0;

            if (Number != null || dr.Number != null)
            {
                if (Number != null && dr.Number != null)
                {
                    List <string> di1 = this._allNumberDigits();
                    List <string> di2 = dr._allNumberDigits();
                    foreach (string d1 in di1)
                    {
                        if (di2.Contains(d1))
                        {
                            numEq = 1;
                            break;
                        }
                    }
                    if (numEq == 0 && !IsLaw)
                    {
                        return(false);
                    }
                    foreach (Pullenti.Ner.Slot s in Slots)
                    {
                        if (s.TypeName == ATTR_NUMBER)
                        {
                            if (dr.FindSlot(s.TypeName, s.Value, true) != null)
                            {
                                numEq = 2;
                                break;
                            }
                        }
                    }
                    if (numEq == 0)
                    {
                        return(false);
                    }
                }
            }
            if (CaseNumber != null && dr.CaseNumber != null)
            {
                if (CaseNumber != dr.CaseNumber)
                {
                    return(false);
                }
            }
            if (this.FindSlot(ATTR_GEO, null, true) != null && dr.FindSlot(ATTR_GEO, null, true) != null)
            {
                if (this.GetStringValue(ATTR_GEO) != dr.GetStringValue(ATTR_GEO))
                {
                    return(false);
                }
            }
            bool srcEq    = false;
            bool srcNotEq = false;

            Pullenti.Ner.Slot src = this.FindSlot(ATTR_SOURCE, null, true);
            if (src != null && dr.FindSlot(ATTR_SOURCE, null, true) != null)
            {
                if (dr.FindSlot(src.TypeName, src.Value, true) == null)
                {
                    srcNotEq = true;
                }
                else
                {
                    srcEq = true;
                }
            }
            bool   dateNotEq  = false;
            bool   dateIsEqu  = false;
            bool   yearsIsEqu = false;
            string date1      = this.GetStringValue(ATTR_DATE);
            string date2      = dr.GetStringValue(ATTR_DATE);

            if (date1 != null || date2 != null)
            {
                if (IsLaw)
                {
                    List <int> ys1 = this._allYears();
                    List <int> ys2 = dr._allYears();
                    foreach (int y1 in ys1)
                    {
                        if (ys2.Contains(y1))
                        {
                            yearsIsEqu = true;
                            break;
                        }
                    }
                    if (yearsIsEqu)
                    {
                        List <DateTime> dts1 = this._allDates();
                        List <DateTime> dts2 = dr._allDates();
                        foreach (DateTime d1 in dts1)
                        {
                            if (dts2.Contains(d1))
                            {
                                dateIsEqu = true;
                                break;
                            }
                        }
                    }
                    if (!dateIsEqu)
                    {
                        if (Typ == "КОНСТИТУЦИЯ")
                        {
                            return(false);
                        }
                        if (Date != null && dr.Date != null)
                        {
                            dateNotEq = true;
                        }
                    }
                }
                else if (date1 == date2 || ((Date != null && dr.Date != null && Date == dr.Date)))
                {
                    if (numEq > 1)
                    {
                        return(true);
                    }
                    dateIsEqu = true;
                }
                else if (Date != null && dr.Date != null)
                {
                    if (Date.Value.Year != dr.Date.Value.Year)
                    {
                        return(false);
                    }
                    if (numEq >= 1)
                    {
                        if (srcEq)
                        {
                            return(true);
                        }
                        if (srcNotEq)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts || Kind == DecreeKind.Publisher)
                {
                    dateNotEq = true;
                }
            }
            if (this.FindSlot(ATTR_NAME, null, true) != null && dr.FindSlot(ATTR_NAME, null, true) != null)
            {
                foreach (Pullenti.Ner.Slot s in Slots)
                {
                    if (s.TypeName == ATTR_NAME)
                    {
                        if (dr.FindSlot(s.TypeName, s.Value, true) != null)
                        {
                            return(true);
                        }
                        foreach (Pullenti.Ner.Slot ss in dr.Slots)
                        {
                            if (ss.TypeName == s.TypeName)
                            {
                                string n0 = s.Value.ToString();
                                string n1 = ss.Value.ToString();
                                if (n0.StartsWith(n1) || n1.StartsWith(n0))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
                if (dateNotEq)
                {
                    return(false);
                }
                if (IsLaw && !dateIsEqu)
                {
                    return(false);
                }
                if (numEq > 0)
                {
                    if (srcEq)
                    {
                        return(true);
                    }
                    if (srcNotEq && typ == Pullenti.Ner.Core.ReferentsEqualType.DifferentTexts)
                    {
                        return(false);
                    }
                    else if ((!srcNotEq && numEq > 1 && Date == null) && dr.Date == null)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            else if (IsLaw && dateNotEq)
            {
                return(false);
            }
            if (dateNotEq)
            {
                return(false);
            }
            string ty = Typ;

            if (ty == null)
            {
                return(numEq > 0);
            }
            DecreeKind t = Pullenti.Ner.Decree.Internal.DecreeToken.GetKind(ty);

            if (t == DecreeKind.Ustav || ty == "КОНСТИТУЦИЯ")
            {
                return(true);
            }
            if (numEq > 0)
            {
                return(true);
            }
            if (this.ToString() == obj.ToString())
            {
                return(true);
            }
            return(false);
        }