Debugf() публичный статический Метод

Вывод диагностического сообщения
public static Debugf ( string which, string fmt ) : void
which string может быть: info, warn, error, iodetail, training-detail
fmt string строка форматирования вида: {0}
Результат void
Пример #1
0
        public void Init(params string[] books)
        {
            bool   retrain    = PGetb("retrain");
            bool   randomize  = PGetb("randomize");
            string cbookstore = PGet("cbookstore");

            bookstores.Clear();
            all_lines.Clear();
            cseg_variant = "cseg.gt";
            text_variant = "gt";
            if (retrain)
            {
                cseg_variant = "cseg";
                text_variant = "";
            }

            int nbooks = books.Length;

            bookstores.Resize(nbooks);
            int totalNumberOfPages = 0;

            for (int i = 0; i < nbooks; i++)
            {
                bookstores[i] = ComponentCreator.MakeComponent <IBookStore>(cbookstore);
                bookstores[i].SetPrefix(books[i].Trim());
                Global.Debugf("info", "{0}: {1} pages", books[i], bookstores[i].NumberOfPages());
                totalNumberOfPages += bookstores[i].NumberOfPages();
            }
            //CHECK_ARG(totalNumberOfPages > 0, "totalNumberOfPages > 0");

            // compute a list of all lines
            Intarray triple = new Intarray(3);

            for (int i = 0; i < nbooks; i++)
            {
                for (int j = 0; j < bookstores[i].NumberOfPages(); j++)
                {
                    for (int k = 0; k < bookstores[i].LinesOnPage(j); k++)
                    {
                        triple[0] = i;
                        triple[1] = j;
                        triple[2] = k;
                        NarrayRowUtil.RowPush(all_lines, triple);
                    }
                }
            }
            Global.Debugf("info", "got {0} lines", all_lines.Dim(0));

            // randomly permute it so that we train in random order
            if (randomize)
            {
                Shuffle();
            }

            index = 0;
        }
Пример #2
0
 public override void SetPrefix(string prefix)
 {
     if (DirPattern.Exist(prefix, @"[0-9][0-9][0-9][0-9]", @"([0-9][0-9][0-9][0-9])\.png"))
     {
         Global.Debugf("info", "selecting OldBookStore");
         p = new OldBookStore();
     }
     else
     {
         Global.Debugf("info", "selecting (new) BookStore");
         p = new BookStore();
     }
     p.SetPrefix(prefix);
 }
Пример #3
0
        public override void SetPrefix(string s)
        {
            prefix = s;
            int ndirs = GetMaxPage("[0-9][0-9][0-9][0-9]");
            int npngs = GetMaxPage("([0-9][0-9][0-9][0-9]).png");

            if (!(ndirs < 10000 && npngs < 10000))
            {
                throw new Exception("CHECK: ndirs < 10000 && npngs < 10000");
            }
            int npages = Math.Max(ndirs, npngs);

            lines.Resize(npages);
            for (int i = 0; i < npages; i++)
            {
                lines[i] = new Intarray();
                GetLinesOfPage(lines[i], i);
                Global.Debugf("bookstore", "page {0} #lines {1}", i, lines[i].Length());
            }
        }
Пример #4
0
        public override string PathFile(int page, int line = -1, string variant = null, string extension = null)
        {
            char   dirSepar = System.IO.Path.DirectorySeparatorChar;
            string file     = String.Format("{0}/{1:0000}", prefix, page);

            if (line >= 0)
            {
                file += String.Format("/{0:0000}", line);
            }
            if (!String.IsNullOrEmpty(variant))
            {
                file += String.Format(".{0}", variant);
            }
            if (!String.IsNullOrEmpty(extension))
            {
                file += String.Format(".{0}", extension);
            }
            file = file.Replace('/', dirSepar);
            Global.Debugf("bookstore", "(path: {0})", file);

            return(file);
        }