Overview
Comment: | tools/smaz: first draft of CLI interface for Evaluate_Dictionary |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a27f42e127e69e36816aa033fcec1568 |
User & Date: | nat on 2016-10-07 16:01:52 |
Other Links: | manifest | tags |
Context
2016-10-08
| ||
15:38 | string_escapes: new package with helper functions to escape strings check-in: e266afb5fe user: nat tags: trunk | |
2016-10-07
| ||
16:01 | tools/smaz: first draft of CLI interface for Evaluate_Dictionary check-in: a27f42e127 user: nat tags: trunk | |
2016-10-06
| ||
17:26 | smaz-tools: add a procedure to help evaluate and improve dictionaries check-in: 3c8fd02a5c user: nat tags: trunk | |
Changes
Modified tools/smaz.adb from [abe2a95020] to [3d7f94da33].
︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | + - + + + | ------------------------------------------------------------------------------ -- Command Line Interface for primitives in Natools.Smaz.Tools. -- ------------------------------------------------------------------------------ with Ada.Characters.Latin_1; with Ada.Command_Line; with Ada.Streams; with Ada.Strings.Fixed; with Ada.Strings.Unbounded; with Ada.Text_IO.Text_Streams; with Natools.Getopt_Long; with Natools.S_Expressions.Parsers; with Natools.S_Expressions.Printers; with Natools.Smaz.Tools; with Natools.Smaz.Tools.GNAT; procedure Smaz is function To_SEA (S : String) return Ada.Streams.Stream_Element_Array renames Natools.S_Expressions.To_Atom; package Actions is type Enum is (Nothing, Decode, |
︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | + + + + | Handler.Need_Dictionary := True; Handler.Action := Actions.Decode; when Options.Encode => Handler.Need_Dictionary := True; Handler.Action := Actions.Encode; when Options.Evaluate => Handler.Need_Dictionary := True; Handler.Action := Actions.Evaluate; when Options.No_Stat_Output => Handler.Stat_Output := False; when Options.No_Sx_Output => Handler.Sx_Output := False; when Options.Output_Ada_Dict => |
︙ | |||
190 191 192 193 194 195 196 197 198 199 200 201 202 203 | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | + | use Options; R : Getopt.Configuration; begin R.Add_Option ("ada-dict", 'A', Optional_Argument, Output_Ada_Dict); R.Add_Option ("decode", 'd', No_Argument, Decode); R.Add_Option ("dict", 'D', No_Argument, Dictionary_Input); R.Add_Option ("encode", 'e', No_Argument, Encode); R.Add_Option ("evaluate", 'E', No_Argument, Evaluate); R.Add_Option ("help", 'h', No_Argument, Help); R.Add_Option ("hash-pkg", 'H', Required_Argument, Output_Hash); 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 ("stats", 's', No_Argument, Stat_Output); R.Add_Option ("no-stats", 'S', No_Argument, No_Stat_Output); |
︙ | |||
342 343 344 345 346 347 348 349 350 351 352 353 354 355 | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | + + + + + | 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"); when Options.Evaluate => New_Line (Output); Put_Line (Output, Indent & Indent & "Evaluate the dictionary on the input given corpus"); end case; end loop; end Print_Help; function To_Dictionary (Handler : in Callback'Class; Input : in Natools.Smaz.Tools.String_Lists.List) |
︙ | |||
547 548 549 550 551 552 553 554 555 556 | 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Base64_Total := Base64_Total + Base64_Size; end; end loop; Print_Line (Original_Total, Output_Total, Base64_Total); end; end if; when Actions.Evaluate => declare Total_Size : Ada.Streams.Stream_Element_Count; Counts : Natools.Smaz.Tools.Dictionary_Counts; begin Natools.Smaz.Tools.Evaluate_Dictionary (Dictionary, Input_Data, Total_Size, Counts); if Handler.Sx_Output then Sx_Output.Open_List; Sx_Output.Append_String (Ada.Strings.Fixed.Trim (Ada.Streams.Stream_Element_Count'Image (Total_Size), Ada.Strings.Both)); for E in Dictionary.Offsets'Range loop Sx_Output.Open_List; Sx_Output.Append_Atom ((0 => E)); Sx_Output.Append_String (Natools.Smaz.Dict_Entry (Dictionary, E)); Sx_Output.Append_String (Ada.Strings.Fixed.Trim (Natools.Smaz.Tools.String_Count'Image (Counts (E)), Ada.Strings.Both)); Sx_Output.Close_List; end loop; Sx_Output.Close_List; end if; if Handler.Stat_Output then Ada.Text_IO.Put_Line ("Not implemented yet"); end if; end; end case; end Build_Dictionary; end Smaz; |