예제 #1
0
        public static ushort CrfLookupEncode(ushort startCrf, Func <ushort, string> encodeFunc, Func <string, double> getSize)
        {
            // Megabytes!
            double          limit = ArgList.Get(Arg.LIMIT).AsInt() / 1024d;
            double          delta = ArgList.Get(Arg.AUTOLIMIT_DELTA).AsInt() / 1024d;
            LinearCrfLookup bl    = new LinearCrfLookup(limit - delta / 2, startCrf);

            double size   = 0;
            ushort newCrf = 0;

            while (!(limit - size < delta && size < limit))
            {
                newCrf = bl.GetTarget();
                if (newCrf == 0)
                {
                    break;
                }
                string result = encodeFunc(newCrf);
                size = getSize(result);
                bl.AddPoint(newCrf, size);
            }
            return(newCrf);
        }
예제 #2
0
        public static ushort CrfLookupEncode(ushort startCrf, Func<ushort, string> encodeFunc, Func<string, double> getSize)
        {
            // Megabytes!
              double limit = ArgList.Get(Arg.LIMIT).AsInt() / 1024d;
              double delta = ArgList.Get(Arg.AUTOLIMIT_DELTA).AsInt() / 1024d;
              LinearCrfLookup bl = new LinearCrfLookup(limit - delta / 2, startCrf);

              double size = 0;
              ushort newCrf = 0;
              while (!(limit - size < delta && size < limit))
              {
            newCrf = bl.GetTarget();
            if (newCrf == 0)
              break;
            string result = encodeFunc(newCrf);
            size = getSize(result);
            bl.AddPoint(newCrf, size);
              }
              return newCrf;
        }