Index: src/natools-smaz-tools.adb ================================================================== --- src/natools-smaz-tools.adb +++ src/natools-smaz-tools.adb @@ -675,10 +675,32 @@ Index := Index + Verbatim_Length + 1; end if; end loop; end Evaluate_Dictionary_Partial; + + procedure Filter_By_Count + (Counter : in out Word_Counter; + Threshold_Count : in String_Count) + is + Position, Next : Word_Maps.Cursor; + begin + Position := Word_Maps.First (Counter.Map); + + while Word_Maps.Has_Element (Position) loop + Next := Word_Maps.Next (Position); + + if Word_Maps.Element (Position) < Threshold_Count then + Word_Maps.Delete (Counter.Map, Position); + end if; + + Position := Next; + end loop; + + pragma Assert (for all Count of Counter.Map => Count >= Threshold_Count); + end Filter_By_Count; + function Simple_Dictionary (Counter : in Word_Counter; Word_Count : in Natural) return String_Lists.List Index: src/natools-smaz-tools.ads ================================================================== --- src/natools-smaz-tools.ads +++ src/natools-smaz-tools.ads @@ -113,10 +113,15 @@ Max_Size : in Positive); -- Add the "words" from Phrase into Counter, with a word being currently -- defined as anything between ASCII blanks or punctuation, -- or in other words [0-9A-Za-z\x80-\xFF]+ + procedure Filter_By_Count + (Counter : in out Word_Counter; + Threshold_Count : in String_Count); + -- Remove from Counter all entries whose count is below the threshold + function Simple_Dictionary (Counter : in Word_Counter; Word_Count : in Natural) return String_Lists.List; -- Return the Word_Count words in Counter that have the highest score,