Natools

Check-in [95e42d23fe]
Login
Overview
Comment:tools/smaz: add a command-line option for a list of forced words
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 95e42d23fee49eb6028b46be37b1ea92dde0c7ce
User & Date: nat on 2017-05-08 21:48:18
Other Links: manifest | tags
Context
2017-05-09
20:45
tools/smaz: implement the new forced words feature check-in: e252a053ef user: nat tags: trunk
2017-05-08
21:48
tools/smaz: add a command-line option for a list of forced words check-in: 95e42d23fe user: nat tags: trunk
2017-05-07
20:27
smaz-tools: new primitive for in-place element replacement check-in: 7fb143f443 user: nat tags: trunk
Changes

Modified tools/smaz.adb from [94617b0aa3] to [390ec3a8af].

99
100
101
102
103
104
105

106
107
108
109
110
111
112
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113







+







         Stat_Output,
         No_Stat_Output,
         Text_List_Input,
         Fast_Text_Input,
         Max_Word_Size,
         Sx_Output,
         No_Sx_Output,
         Force_Word,
         No_Vlen_Verbatim,
         Score_Method,
         Vlen_Verbatim);
   end Options;

   package Getopt is new Natools.Getopt_Long (Options.Id);

128
129
130
131
132
133
134

135
136
137
138
139
140
141
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143







+







      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;
      Check_Roundtrip : Boolean := False;
      Forced_Words : Natools.Smaz_Tools.String_Lists.List;
   end record;

   overriding procedure Option
     (Handler  : in out Callback;
      Id       : in Options.Id;
      Argument : in String);

1239
1240
1241
1242
1243
1244
1245






1246
1247
1248
1249
1250
1251
1252
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260







+
+
+
+
+
+







            Handler.Algorithm := Algorithms.Base_64;

         when Options.Base_4096 =>
            Handler.Algorithm := Algorithms.Base_4096;

         when Options.Check_Roundtrip =>
            Handler.Check_Roundtrip := True;

         when Options.Force_Word =>
            if Argument'Length > 0 then
               Handler.Need_Dictionary := True;
               Handler.Forced_Words.Append (Argument);
            end if;
      end case;
   end Option;


   function Activate_Dictionary (Dict : in Natools.Smaz_256.Dictionary)
     return Natools.Smaz_256.Dictionary
   is
1372
1373
1374
1375
1376
1377
1378

1379
1380
1381
1382
1383
1384
1385
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394







+







      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);
      R.Add_Option ("force-word",         Required_Argument, Force_Word);
      R.Add_Option ("no-vlen-verbatim",   No_Argument,       No_Vlen_Verbatim);
      R.Add_Option ("score-method",       Required_Argument, Score_Method);
      R.Add_Option ("vlen-verbatim",      No_Argument,       Vlen_Verbatim);

      return R;
   end Getopt_Config;

1647
1648
1649
1650
1651
1652
1653








1654
1655
1656
1657
1658
1659
1660
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677







+
+
+
+
+
+
+
+







               Put_Line (Output, Indent & Indent
                 & "Use base-4096 implementation");

            when Options.Check_Roundtrip =>
               New_Line (Output);
               Put_Line (Output, Indent & Indent
                 & "Check roundtrip of compression or decompression");

            when Options.Force_Word =>
               Put_Line (Output, " <word>");
               Put_Line (Output, Indent & Indent
                 & "Force <word> into the dictionary,"
                 & " replacing the worst entry");
               Put_Line (Output, Indent & Indent
                 & "Can be specified multiple times to force many words.");
         end case;
      end loop;
   end Print_Help;


   Opt_Config : constant Getopt.Configuration := Getopt_Config;
   Handler : Callback;