Natools

Check-in [2ee60631e6]
Login
Overview
Comment:tools/smaz: new command line option for maximum pending list size
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2ee60631e6664ef327ea5bc05b1854774cfa02b0
User & Date: nat on 2016-11-03 20:20:49
Other Links: manifest | tags
Context
2016-11-04
22:42
tools/smaz: fix the letter of latest command line option check-in: 03959c30d5 user: nat tags: trunk
2016-11-03
20:20
tools/smaz: new command line option for maximum pending list size check-in: 2ee60631e6 user: nat tags: trunk
2016-11-02
20:55
smaz-tools: add a size limit for the simple dictionary pending list check-in: c61c547bb8 user: nat tags: trunk
Changes

Modified tools/smaz.adb from [b0e0c5a5df] to [d42e5642d7].

71
72
73
74
75
76
77

78
79
80
81
82
83
84
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85







+







         Filter_Threshold,
         Output_Hash,
         Job_Count,
         Help,
         Sx_Dict_Output,
         Min_Sub_Size,
         Max_Sub_Size,
         Max_Pending,
         Stat_Output,
         No_Stat_Output,
         Text_List_Input,
         Fast_Text_Input,
         Max_Word_Size,
         Sx_Output,
         No_Sx_Output,
92
93
94
95
96
97
98


99
100
101
102
103
104
105
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108







+
+







      Need_Dictionary : Boolean := False;
      Stat_Output : Boolean := False;
      Sx_Output : Boolean := False;
      Sx_Dict_Output : Boolean := False;
      Min_Sub_Size : Positive := 1;
      Max_Sub_Size : Positive := 3;
      Max_Word_Size : Positive := 10;
      Max_Pending : Ada.Containers.Count_Type
        := Ada.Containers.Count_Type'Last;
      Job_Count : Natural := 0;
      Filter_Threshold : Natools.Smaz.Tools.String_Count := 0;
      Score_Method : Methods.Enum := Methods.Encoded;
      Action : Actions.Enum := Actions.Nothing;
      Ada_Dictionary : Ada.Strings.Unbounded.Unbounded_String;
      Hash_Package : Ada.Strings.Unbounded.Unbounded_String;
      Dict_Source : Dict_Sources.Enum := Dict_Sources.S_Expression;
307
308
309
310
311
312
313



314
315
316
317
318
319
320
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326







+
+
+








         when Options.Filter_Threshold =>
            Handler.Filter_Threshold
              := Natools.Smaz.Tools.String_Count'Value (Argument);

         when Options.Score_Method =>
            Handler.Score_Method := Methods.Enum'Value (Argument);

         when Options.Max_Pending =>
            Handler.Max_Pending := Ada.Containers.Count_Type'Value (Argument);
      end case;
   end Option;


   procedure Evaluate_Dictionary
     (Job_Count : in Natural;
      Dict : in Natools.Smaz.Dictionary;
364
365
366
367
368
369
370

371
372
373
374
375
376
377
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384







+







      R.Add_Option ("filter",        'F', Required_Argument, Filter_Threshold);
      R.Add_Option ("help",          'h', No_Argument,       Help);
      R.Add_Option ("hash-pkg",      'H', Required_Argument, Output_Hash);
      R.Add_Option ("jobs",          'j', Required_Argument, Job_Count);
      R.Add_Option ("sx-dict",       'L', No_Argument,       Sx_Dict_Output);
      R.Add_Option ("min-substring", 'm', Required_Argument, Min_Sub_Size);
      R.Add_Option ("max-substring", 'M', Required_Argument, Max_Sub_Size);
      R.Add_Option ("max-pending",   'M', Required_Argument, Max_Pending);
      R.Add_Option ("stats",         's', No_Argument,       Stat_Output);
      R.Add_Option ("no-stats",      'S', No_Argument,       No_Stat_Output);
      R.Add_Option ("text-list",     't', No_Argument,       Text_List_Input);
      R.Add_Option ("fast-text-list", 'T', No_Argument,       Fast_Text_Input);
      R.Add_Option ("max-word-len",  'W', Required_Argument, Max_Word_Size);
      R.Add_Option ("s-expr",        'x', No_Argument,       Sx_Output);
      R.Add_Option ("no-s-expr",     'X', No_Argument,       No_Sx_Output);
736
737
738
739
740
741
742






743
744
745
746
747
748
749
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762







+
+
+
+
+
+







                 & "substrings whose count is below the threshold.");

            when Options.Score_Method =>
               Put_Line (Output, " <method>");
               Put_Line (Output, Indent & Indent
                 & "Select heuristic method to replace dictionary items"
                 & " during optimization");

            when Options.Max_Pending =>
               Put_Line (Output, " <count>");
               Put_Line (Output, Indent & Indent
                 & "Maximum size of candidate list"
                 & " when building a dictionary");
         end case;
      end loop;
   end Print_Help;


   function To_Dictionary
     (Handler : in Callback'Class;
778
779
780
781
782
783
784
785

786
787
788
789
790
791
792
791
792
793
794
795
796
797

798
799
800
801
802
803
804
805







-
+







               end if;

               if Handler.Dict_Source = Dict_Sources.Text_List then
                  declare
                     Selected, Pending : Natools.Smaz.Tools.String_Lists.List;
                  begin
                     Natools.Smaz.Tools.Simple_Dictionary_And_Pending
                       (Counter, 254, Selected, Pending);
                       (Counter, 254, Selected, Pending, Handler.Max_Pending);

                     return Optimize_Dictionary
                       (Natools.Smaz.Tools.To_Dictionary (Selected, True),
                        Pending,
                        Input,
                        Handler.Job_Count,
                        Handler.Score_Method);