796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
|
for Cursor in Scored_Word_Sets.Iterate (Set) loop
Result.Append (Scored_Word_Sets.Element (Cursor).Word);
end loop;
return Result;
end Simple_Dictionary;
function To_Scored_Word (Cursor : in Word_Maps.Cursor)
return Scored_Word
is
Word : constant String := Word_Maps.Key (Cursor);
begin
return Scored_Word'
(Size => Word'Length,
Word => Word,
Score => Score_Value (Word_Maps.Element (Cursor)) * Word'Length);
end To_Scored_Word;
end Natools.Smaz.Tools;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
|
for Cursor in Scored_Word_Sets.Iterate (Set) loop
Result.Append (Scored_Word_Sets.Element (Cursor).Word);
end loop;
return Result;
end Simple_Dictionary;
procedure Simple_Dictionary_And_Pending
(Counter : in Word_Counter;
Word_Count : in Natural;
Selected : out String_Lists.List;
Pending : out String_Lists.List)
is
use type Ada.Containers.Count_Type;
Target_Count : constant Ada.Containers.Count_Type
:= Ada.Containers.Count_Type (Word_Count);
Set : Scored_Word_Sets.Set;
begin
for Cursor in Word_Maps.Iterate (Counter.Map) loop
Scored_Word_Sets.Insert (Set, To_Scored_Word (Cursor));
end loop;
Selected := String_Lists.Empty_List;
Pending := String_Lists.Empty_List;
for Cursor in Scored_Word_Sets.Iterate (Set) loop
if String_Lists.Length (Selected) < Target_Count then
Selected.Append (Scored_Word_Sets.Element (Cursor).Word);
else
Pending.Append (Scored_Word_Sets.Element (Cursor).Word);
end if;
end loop;
end Simple_Dictionary_And_Pending;
function To_Scored_Word (Cursor : in Word_Maps.Cursor)
return Scored_Word
is
Word : constant String := Word_Maps.Key (Cursor);
begin
return Scored_Word'
(Size => Word'Length,
Word => Word,
Score => Score_Value (Word_Maps.Element (Cursor)) * Word'Length);
end To_Scored_Word;
end Natools.Smaz.Tools;
|