Skip to content

Commit

Permalink
Bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
antononcube committed Aug 19, 2019
1 parent 5b77318 commit 1b746e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions JavaTriesWithFrequencies.m
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ Mathematica is (C) Copyright 1988-2017 Wolfram Research, Inc.
Block[{res, dval = OptionValue[JavaTrieClassify, "Default"]},
res = JavaTrieLeafProbabilities[JavaTrieRetrieve[tr, record], "Normalized"->True];
If[Length[res] == 0, <|dval -> 0|>,
res = AssociationThread[res[[All, 2, 2]] -> res[[All, 1, 2]]];
res = AssociationThread[res[[All, 1, 2]] -> res[[All, 2, 2]]];
res = ReverseSort[Association[Rule @@@ res]]
]
];
Expand All @@ -531,13 +531,13 @@ Mathematica is (C) Copyright 1988-2017 Wolfram Research, Inc.
First @* Keys @* TakeLargest[1] /@ JavaTrieClassify[tr, records, "Probabilities", opts];

JavaTrieClassify[tr_, records:(_Dataset|{_List..}), "Probability" -> class_, opts : OptionsPattern[]] :=
Map[Lookup[#, class, 0]&, JavaTrieClassify[tr, records, "Probabilities", opts] ];
Map[ Lookup[#, class, 0]&, JavaTrieClassify[tr, records, "Probabilities", opts] ];

JavaTrieClassify[tr_, records:(_Dataset|{_List..}), "TopProbabilities", opts : OptionsPattern[]] :=
Map[ Select[#, # > 0 &]&, JavaTrieClassify[tr, records, "Probabilities", opts] ];

JavaTrieClassify[tr_, records:(_Dataset|{_List..}), "TopProbabilities" -> n_Integer, opts : OptionsPattern[]] :=
Map[TakeLargest[#, UpTo[n]]&, JavaTrieClassify[tr, records, "Probabilities", opts] ];
Map[ TakeLargest[#, UpTo[n]]&, JavaTrieClassify[tr, records, "Probabilities", opts] ];

JavaTrieClassify[tr_, records:(_Dataset|{_List..}), "Probabilities", opts:OptionsPattern[] ] :=
Block[{clRes, classLabels, stencil},
Expand Down

0 comments on commit 1b746e3

Please sign in to comment.