コード例 #1
0
            public static Table Sum(List <Table> list)
            {
                var groups = new Dictionary <string, List <TransparencyStats> >();
                var sum    = new Table();

                foreach (var table in list)
                {
                    foreach (var row in table.Rows)
                    {
                        List <TransparencyStats> group;
                        if (!groups.TryGetValue(row.Key, out group))
                        {
                            var srow = new Row();
                            srow.Key = row.Key;
                            sum.Rows.Add(srow);
                            groups[row.Key] = group = new List <TransparencyStats>();
                        }
                        group.Add(row.Stats);
                    }
                }
                foreach (var row in sum.Rows)
                {
                    row.Stats = TransparencyStats.Sum(groups[row.Key]);
                }
                return(sum);
            }
コード例 #2
0
 public static byte[] ExtractorNormalized(string key, SampleFingerprint fp)
 {
     return(PersistentCache.Get(Path.Combine("normalized-extractor-transparency-files", key), ExtractorPath(key, fp), () =>
     {
         return SerializationUtils.Normalize(TransparencyStats.ExtractorRow(fp, key).Mime, Extractor(key, fp));
     }));
 }
コード例 #3
0
            public static Table Of(string key, string mime, byte[] data)
            {
                var row = new Row();

                row.Key   = key;
                row.Stats = TransparencyStats.Of(mime, data);
                var table = new Table();

                table.Rows.Add(row);
                return(table);
            }
コード例 #4
0
        public static TransparencyStats Of(string mime, byte[] data)
        {
            var stats = new TransparencyStats();

            stats.Mime  = mime;
            stats.Count = 1;
            stats.Size  = data.Length;
            var normalized = SerializationUtils.Normalize(mime, data);

            stats.SizeNormalized = normalized.Length;
            stats.Hash           = DataHash.Of(normalized);
            return(stats);
        }
コード例 #5
0
 static void Main(string[] args)
 {
     Log.Logger = new LoggerConfiguration()
                  .WriteTo.Console(outputTemplate: "{Level:u1} {Message:lj}{NewLine}{Exception}")
                  .CreateLogger();
     if (args.Length != 1)
     {
         return;
     }
     switch (args[0])
     {
     case "extractor-transparency-stats":
         TransparencyStats.Report(TransparencyStats.ExtractorTable());
         break;
     }
 }
コード例 #6
0
        public static TransparencyStats Sum(List <TransparencyStats> list)
        {
            var sum = new TransparencyStats();

            sum.Mime = list[0].Mime;
            var hash = new DataHash();

            foreach (var stats in list)
            {
                sum.Count          += stats.Count;
                sum.Size           += stats.Size;
                sum.SizeNormalized += stats.SizeNormalized;
                hash.Add(stats.Hash);
            }
            sum.Hash = hash.Compute();
            return(sum);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: erenche/sourceafis-net
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console(outputTemplate: "{Message:lj}{NewLine}{Exception}")
                         .CreateLogger();
            if (args.Length < 1)
            {
                return;
            }
            switch (args[0])
            {
            case "footprint":
                TemplateFootprint.Report();
                break;

            case "accuracy":
                ScalarAccuracy.Report();
                break;

            case "extractor-transparency-stats":
                TransparencyStats.Report(TransparencyStats.ExtractorTable());
                break;

            case "extractor-transparency-files":
                if (args.Length < 2)
                {
                    return;
                }
                TransparencyFile.Extractor(args[1]);
                break;

            case "normalized-extractor-transparency-files":
                if (args.Length < 2)
                {
                    return;
                }
                TransparencyFile.ExtractorNormalized(args[1]);
                break;
            }
        }
コード例 #8
0
 static string ExtractorPath(string key, SampleFingerprint fp)
 {
     return(fp.Path + Extension(TransparencyStats.ExtractorRow(fp, key).Mime));
 }
コード例 #9
0
 public void Add(TransparencyStats stats)
 {
     Count += stats.Count;
     Size  += stats.Size;
     Hasher.AppendData(stats.Hash);
 }