Index: tools/smaz.adb ================================================================== --- tools/smaz.adb +++ tools/smaz.adb @@ -58,10 +58,11 @@ Min_Sub_Size, Max_Sub_Size, Stat_Output, No_Stat_Output, Word_List_Input, + Max_Word_Size, Sx_Output, No_Sx_Output); end Options; package Getopt is new Natools.Getopt_Long (Options.Id); @@ -72,10 +73,11 @@ 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; 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; end record; @@ -174,10 +176,13 @@ when Options.Min_Sub_Size => Handler.Min_Sub_Size := Positive'Value (Argument); when Options.Max_Sub_Size => Handler.Max_Sub_Size := Positive'Value (Argument); + + when Options.Max_Word_Size => + Handler.Max_Word_Size := Positive'Value (Argument); end case; end Option; function Getopt_Config return Getopt.Configuration is @@ -195,10 +200,11 @@ 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 ("stats", 's', No_Argument, Stat_Output); R.Add_Option ("no-stats", 'S', No_Argument, No_Stat_Output); R.Add_Option ("word-list", 'w', No_Argument, Word_List_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); return R; end Getopt_Config; @@ -333,10 +339,15 @@ when Options.Max_Sub_Size => New_Line (Output); Put_Line (Output, Indent & Indent & "Maximum substring size when building a dictionary"); + + when Options.Max_Word_Size => + New_Line (Output); + Put_Line (Output, Indent & Indent + & "Maximum word size when building a dictionary"); end case; end loop; end Print_Help; function To_Dictionary @@ -353,12 +364,16 @@ Counter : Natools.Smaz.Tools.Word_Counter; begin for S of Input loop Natools.Smaz.Tools.Add_Substrings (Counter, S, Handler.Min_Sub_Size, Handler.Max_Sub_Size); - Natools.Smaz.Tools.Add_Words - (Counter, S, Handler.Max_Sub_Size + 1, 10); + + if Handler.Max_Word_Size > Handler.Max_Sub_Size then + Natools.Smaz.Tools.Add_Words + (Counter, S, + Handler.Max_Sub_Size + 1, Handler.Max_Word_Size); + end if; end loop; return Natools.Smaz.Tools.To_Dictionary (Natools.Smaz.Tools.Simple_Dictionary (Counter, 254), True);