Natools

Check-in [52b491f017]
Login
Overview
Comment:smaz-tools: add a trie-based search compatible with Dictionary.Hash
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 52b491f01727e081e0bb56cf0d8fdbb0c737b1f3
User & Date: nat on 2016-10-18 21:47:15
Other Links: manifest | tags
Context
2016-10-19
20:24
tools/smaz: use the new trie-based search in dictionary evaluation check-in: 105a5395c6 user: nat tags: trunk
2016-10-18
21:47
smaz-tools: add a trie-based search compatible with Dictionary.Hash check-in: 52b491f017 user: nat tags: trunk
2016-10-17
20:48
smaz-tools: add a trie-based dynamic dictionary lookup check-in: 34d16d2c19 user: nat tags: trunk
Changes

Modified src/natools-smaz-tools.adb from [2f6aac0df0] to [5167279c60].

512
513
514
515
516
517
518












519
520
521
522
523
524
525
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537







+
+
+
+
+
+
+
+
+
+
+
+







      Dictionary_Maps.Clear (Search_Map);

      for I in Dict.Offsets'Range loop
         Dictionary_Maps.Insert (Search_Map, Dict_Entry (Dict, I), I);
      end loop;
   end Set_Dictionary_For_Map_Search;


   procedure Set_Dictionary_For_Trie_Search (Dict : in Dictionary) is
   begin
      Initialize (Trie_For_Search, Dict);
   end Set_Dictionary_For_Trie_Search;


   function Trie_Search (Value : String) return Natural is
   begin
      return Search (Trie_For_Search, Value);
   end Trie_Search;



   -------------------
   -- Word Counting --
   -------------------

   procedure Add_Substrings

Modified src/natools-smaz-tools.ads from [b5741ecb56] to [5b71d7ec1d].

76
77
78
79
80
81
82





83
84
85
86
87
88
89
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94







+
+
+
+
+







      --  ordered map, that can be used with Dictionary.Hash.

   type Search_Trie is private;
   procedure Initialize (Trie : out Search_Trie; Dict : in Dictionary);
   function Search (Trie : in Search_Trie; Value : in String) return Natural;
      --  Trie-based search in a dynamic dictionary, for lookup whose
      --  speed-vs-memory is even more skewed towards speed.

   procedure Set_Dictionary_For_Trie_Search (Dict : in Dictionary);
   function Trie_Search (Value : String) return Natural;
      --  Function and data source for trie-based search that can be
      --  used with Dictionary.Hash.

   type String_Count is range 0 .. 2 ** 31 - 1;
      --  Type for a number of substring occurrences

   type Word_Counter is private;
      --  Accumulate frequency/occurrence counts for a set of strings

183
184
185
186
187
188
189
190


191
188
189
190
191
192
193
194
195
196
197
198








+
+

   overriding procedure Adjust (Node : in out Trie_Node);
   overriding procedure Finalize (Node : in out Trie_Node);

   type Search_Trie is record
      Not_Found : Natural;
      Root : Trie_Node (False);
   end record;

   Trie_For_Search : Search_Trie;

end Natools.Smaz.Tools;