Overview
Comment: | smaz-tools: add dictionary-independent scoring functions |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ebefb3c8324f6ce55268cd09d4d32154 |
User & Date: | nat on 2016-11-18 22:43:41 |
Other Links: | manifest | tags |
Context
2016-11-19
| ||
21:35 | smaz-tools: refactor scoring in To_Scored_Word check-in: 25e91595e4 user: nat tags: trunk | |
2016-11-18
| ||
22:43 | smaz-tools: add dictionary-independent scoring functions check-in: ebefb3c832 user: nat tags: trunk | |
2016-11-17
| ||
21:23 | smaz_tests: new tests suite for instantiated Smaz packages check-in: 769ae2dc25 user: nat tags: trunk | |
Changes
Modified src/natools-smaz-tools.ads from [52958dca03] to [c61bcb756f].
︙ | ︙ | |||
198 199 200 201 202 203 204 205 206 207 208 | Counts : in Dictionary_Counts; Method : in Methods.Enum) return Ada.Streams.Stream_Element; -- Return the element with worst score type Score_Value is range 0 .. 2 ** 31 - 1; function Length (Dict : in Dictionary; E : in Ada.Streams.Stream_Element) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | < < < | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | Counts : in Dictionary_Counts; Method : in Methods.Enum) return Ada.Streams.Stream_Element; -- Return the element with worst score type Score_Value is range 0 .. 2 ** 31 - 1; function Score_Encoded (Count : in String_Count; Length : in Positive) return Score_Value is (Score_Value (Count) * Score_Value (Length)); -- Score value using the amount of encoded data by the element function Score_Frequency (Count : in String_Count; Length : in Positive) return Score_Value is (Score_Value (Count)); -- Score value using the number of times the element was used function Score_Gain (Count : in String_Count; Length : in Positive) return Score_Value is (Score_Value (Count) * (Score_Value (Length) - 1)); -- Score value using the number of bytes saved using the element function Score (Count : in String_Count; Length : in Positive; Method : in Methods.Enum) return Score_Value is (case Method is when Methods.Encoded => Score_Encoded (Count, Length), when Methods.Frequency => Score_Frequency (Count, Length), when Methods.Gain => Score_Gain (Count, Length)); -- Scare value with dynamically chosen method function Length (Dict : in Dictionary; E : in Ada.Streams.Stream_Element) return Positive is (Natools.Smaz.Dict_Entry (Dict, E)'Length); -- Length of a dictionary entry function Score_Encoded (Dict : in Dictionary; Counts : in Natools.Smaz.Tools.Dictionary_Counts; E : Ada.Streams.Stream_Element) return Score_Value is (Score_Encoded (Counts (E), Length (Dict, E))); -- Score value using the amount of encoded data using E function Score_Frequency (Dict : in Dictionary; Counts : in Natools.Smaz.Tools.Dictionary_Counts; E : Ada.Streams.Stream_Element) return Score_Value is (Score_Frequency (Counts (E), Length (Dict, E))); -- Score value using the number of times E was used function Score_Gain (Dict : in Dictionary; Counts : in Natools.Smaz.Tools.Dictionary_Counts; E : Ada.Streams.Stream_Element) return Score_Value is (Score_Gain (Counts (E), Length (Dict, E))); -- Score value using the number of bytes saved using E function Score (Dict : in Dictionary; Counts : in Natools.Smaz.Tools.Dictionary_Counts; E : in Ada.Streams.Stream_Element; Method : in Methods.Enum) return Score_Value is (Score (Counts (E), Length (Dict, E), Method)); -- Scare value with dynamically chosen method private package Word_Maps is new Ada.Containers.Indefinite_Ordered_Maps (String, String_Count); |
︙ | ︙ |