예제 #1
0
        private TransferItem ReadTerraformingLine(TextLineSection tsl, PageSections sections, Bytemap imageGray, Bytemap imageBinary)
        {
            // Terraforming description is above the first table.
            if (sections.Tables.Count < 1) return null;
            if (tsl.Line.Bounds.Bottom >= sections.Tables[0].Bounds.Top) return null;

            string terraforming = "";
            List<Rectangle> rs = new List<Rectangle>(tsl.Line);
            for (int i = 0; i < tsl.Line.Count; i++)
            {
                if (i > 0 && ImageLetters.IsNewWord(rs, i, true))
                {
                    terraforming += " ";
                }
                terraforming += PredictAsLetterD(imageGray, imageBinary, rs[i]);
            }
            return GuessTerraforming(terraforming);

        }
예제 #2
0
        private TransferItem ReadMiningReservesLine(TextLineSection tsl, PageSections sections, Bytemap imageGray, Bytemap imageBinary)
        {
            bool afterTable = false;
            bool afterDescription = false;
            // Mining reserves are stated between first table and a headline OR immediately after the description..
            if (sections.Tables.Count < 1) return null;
            afterTable = tsl.Line.Bounds.Top > sections.Tables[0].Bounds.Bottom;
            afterDescription = tsl.Line.Bounds.Bottom < sections.Tables[0].Bounds.Top
                && tsl.Line.Bounds.Bottom > sections.Tables[0].Bounds.Top - 50;
            if (!afterTable && !afterDescription) return null;
            int index = sections.AllSections.IndexOf(tsl);
            if (index < 0 || index + 1 >= sections.AllSections.Count) return null;
            if (!afterDescription && !(sections.AllSections[index + 1] is HeadlineSection)) return null;

            string mining = "";
            List<Rectangle> rs = new List<Rectangle>(tsl.Line);
            for (int i = 0; i < tsl.Line.Count; i++)
            {
                if (i > 0 && ImageLetters.IsNewWord(rs, i, true))
                {
                    mining += " ";
                }
                mining += PredictAsLetterD(imageGray, imageBinary, rs[i]);
            }
            return GuessMiningReserves(mining);
        }