Beispiel #1
0
        void ParseRealtiesByAntlr(string ownTypeByColumn, string cellText, Person person)
        {
            var parser = new AntlrStrictParser();

            foreach (var item in parser.Parse(cellText))
            {
                RealtyFromText realty = (RealtyFromText)item;
                if (realty.RealtyType != null && realty.RealtyType.Length > 0)
                {
                    RealEstateProperty realEstateProperty = new RealEstateProperty();
                    realEstateProperty.Text         = realty.GetSourceText();
                    realEstateProperty.type_raw     = realty.RealtyType;
                    realEstateProperty.square       = realty.Square;
                    realEstateProperty.country_raw  = realty.Country;
                    realEstateProperty.own_type_raw = realty.OwnType;
                    //???  = realty.RealtyShare; // nowhere to write to
                    realEstateProperty.own_type_by_column = ownTypeByColumn;
                    person.RealEstateProperties.Add(realEstateProperty);
                }
            }
        }
Beispiel #2
0
        public void ParseStatePropertySingleRow(string statePropTypeStr, string statePropOwnershipTypeStr,
                                                string statePropSquareStr, string statePropCountryStr, Person person)
        {
            statePropTypeStr = statePropTypeStr.Trim();
            if (DataHelper.IsEmptyValue(statePropTypeStr))
            {
                return;
            }
            RealEstateProperty stateProperty = new RealEstateProperty();

            statePropTypeStr          = statePropTypeStr.Trim(' ', '-');
            stateProperty.Text        = statePropTypeStr.NormSpaces();
            stateProperty.type_raw    = statePropTypeStr.NormSpaces();
            stateProperty.square      = DataHelper.ParseSquare(statePropSquareStr);;
            stateProperty.square_raw  = ParserBase.NormalizeRawDecimalForTest(statePropSquareStr);
            stateProperty.country_raw = DataHelper.ParseCountry(statePropCountryStr).NormSpaces();
            if (statePropOwnershipTypeStr != "" && statePropOwnershipTypeStr != null)
            {
                stateProperty.own_type_raw = statePropOwnershipTypeStr.NormSpaces();
            }
            stateProperty.own_type_by_column = StateString;
            person.RealEstateProperties.Add(stateProperty);
        }
Beispiel #3
0
        void ParseTypeAndCountry(DataRow currRow, DeclarationField realtyType, string ownTypeByColumn, Person person)
        {
            var        typeAndCountry   = new TRealtyCell(currRow.GetDeclarationField(realtyType));
            var        cellSquareField  = (realtyType == DeclarationField.OwnedRealEstateTypeAndCountry) ? DeclarationField.OwnedRealEstateSquare : DeclarationField.StatePropertySquare;
            var        squareCell       = new TRealtyCell(currRow.GetDeclarationField(cellSquareField));
            List <int> linesWithNumbers = TRealtyCellSpan.GetLinesStaringWithNumbers(squareCell.DataCell.GetText(true));

            if (linesWithNumbers.Count > 0)
            {
                typeAndCountry.ParseByEmptyLines(linesWithNumbers);
                squareCell.ParseByEmptyLines(linesWithNumbers);
            }
            for (int i = 0; i < squareCell.ParsedItems.Count; ++i)
            {
                var typeAndCountryStr = typeAndCountry.GetParsedItem(i);
                var type       = typeAndCountryStr;
                var countryStr = "";

                if (typeAndCountryStr.Contains('('))
                {
                    int bracket = typeAndCountryStr.IndexOf('(');
                    type       = typeAndCountryStr.Substring(0, bracket).Trim();
                    countryStr = typeAndCountryStr.Substring(bracket).Trim(' ', '\n', '(', ')');
                }
                var squareRaw = squareCell.GetParsedItem(i);

                RealEstateProperty realEstateProperty = new RealEstateProperty();
                realEstateProperty.Text               = type;
                realEstateProperty.type_raw           = type;
                realEstateProperty.square             = DataHelper.ParseSquare(squareRaw);
                realEstateProperty.square_raw         = ParserBase.NormalizeRawDecimalForTest(squareRaw);
                realEstateProperty.country_raw        = DataHelper.ParseCountry(countryStr).NormSpaces();
                realEstateProperty.own_type_by_column = ownTypeByColumn;
                person.RealEstateProperties.Add(realEstateProperty);
            }
        }
Beispiel #4
0
        void ParseRealtiesDistributedByColumns(string ownTypeByColumn, string realtyTypeFromColumnTitle, string cellText, Person person)
        {
            // each realty type in a separate column
            foreach (var bulletText in FindBullets(cellText))
            {
                RealEstateProperty realEstateProperty = new RealEstateProperty();
                realEstateProperty.Text               = bulletText;
                realEstateProperty.type_raw           = realtyTypeFromColumnTitle;
                realEstateProperty.own_type_by_column = ownTypeByColumn;
                var match = Regex.Match(bulletText, ".*\\s(\\d+[.,]\\d+)\\sкв.м", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    realEstateProperty.square = DataHelper.ConvertSquareFromString(match.Groups[1].ToString());
                }

                decimal?square = DataHelper.ParseSquare(bulletText);
                if (square.HasValue)
                {
                    realEstateProperty.square = square;
                }

                person.RealEstateProperties.Add(realEstateProperty);
            }
        }
Beispiel #5
0
        private void ParseRealEstateTable(Table table, PublicServant person, string ownTypeByColumn)
        {
            var    rows = table.Descendants <TableRow>().ToList().Skip(1);
            string currentRealEstateType = "";

            foreach (var row in rows)
            {
                var cells           = row.Descendants <TableCell>().ToList();
                var gridSpan        = cells[0].TableCellProperties.GetFirstChild <GridSpan>();
                var mergedColsCount = (gridSpan == null) ? 1 : (int)gridSpan.Val;
                var text            = cells[0].InnerText;

                if (mergedColsCount > 1)
                {
                    currentRealEstateType = text;
                    continue;
                }

                var textStr = cells[1].InnerText;
                if (textStr.OnlyRussianLowercase() == "неимеет")
                {
                    continue;
                }
                var areaStr    = cells[2].InnerText;
                var countryStr = cells[3].InnerText;
                var ownerStr   = cells[4].InnerText;

                var owners = ownerStr.Split(",").ToList();
                var shares = owners.Where(x => x.Contains(" доля") || x.Contains(" доли")).ToList();
                owners = owners.Where(x => !(x.Contains(" доля") || x.Contains(" доли"))).ToList();

                if (shares.Count != owners.Count && shares.Count > 0)
                {
                    throw new SmartParserException("shares.Count != owners.Count in SovetFederaciiDocxScheme");
                }

                if (shares.Count < owners.Count)
                {
                    shares = Enumerable.Repeat <string>(null, owners.Count - shares.Count).ToList();
                }

                var zippedOwners = owners.Zip(shares);

                foreach (var pair in zippedOwners)
                {
                    var owner = pair.First;
                    var share = pair.Second;
                    var realEstateProperty = new RealEstateProperty
                    {
                        Text               = textStr,
                        square             = DataHelper.ParseSquare(areaStr),
                        type_raw           = currentRealEstateType,
                        square_raw         = ParserBase.NormalizeRawDecimalForTest(areaStr),
                        country_raw        = DataHelper.ParseCountry(countryStr),
                        own_type_by_column = ownTypeByColumn
                    };

                    if (share != default)
                    {
                        realEstateProperty.own_type_raw = share;
                    }

                    var relationType = DataHelper.ParseRelationType(owner, false);
                    if (DataHelper.IsRelativeInfo(owner))
                    {
                        var relative = GetPersonRelative(person, relationType);
                        relative.RealEstateProperties.Add(realEstateProperty);
                    }
                    else
                    {
                        person.RealEstateProperties.Add(realEstateProperty);
                    }
                }
            }
        }