Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | smaz-tools: new primitive to build a dictionary with pending words |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
214d918405a714db470df05146c6f861 |
| User & Date: | nat 2016-10-25 19:55:08.916 |
Context
|
2016-10-26
| ||
| 20:58 | tools/smaz: refactor dictionary evaluation in a standalone subprogram check-in: d418194c20 user: nat tags: trunk | |
|
2016-10-25
| ||
| 19:55 | smaz-tools: new primitive to build a dictionary with pending words check-in: 214d918405 user: nat tags: trunk | |
|
2016-10-24
| ||
| 19:31 | smaz-tools: new primitive to append a new string value to a dictionary check-in: 5e694df685 user: nat tags: trunk | |
Changes
Changes to src/natools-smaz-tools.adb.
| ︙ | |||
796 797 798 799 800 801 802 803 804 805 806 807 808 809 | 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
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'
|
| ︙ |
Changes to src/natools-smaz-tools.ads.
| ︙ | |||
153 154 155 156 157 158 159 160 161 162 163 164 165 166 | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | + + + + + + + + + |
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,
-- the score being count * length.
procedure Simple_Dictionary_And_Pending
(Counter : in Word_Counter;
Word_Count : in Natural;
Selected : out String_Lists.List;
Pending : out String_Lists.List);
-- Return in Selected the Word_Count words in Counter that have the
-- highest score, and in Pending the remaining words,
-- the score being count * length.
type Dictionary_Counts is
array (Ada.Streams.Stream_Element) of String_Count;
procedure Evaluate_Dictionary
(Dict : in Dictionary;
Corpus : in String_Lists.List;
|
| ︙ |