Skip to content

Commit

Permalink
Implemented JavaTrieThresholdRemove and JavaTrieRegexRemove.
Browse files Browse the repository at this point in the history
  • Loading branch information
antononcube committed Jan 28, 2017
1 parent ba82bd9 commit 51d4a83
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions JavaTriesWithFrequencies.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ Mathematica is (C) Copyright 1988-2017 Wolfram Research, Inc.
JavaTrieRootToLeafPaths::usage = "Gives lists of key-value pairs corresponding to the root-to-leaf paths\
in a given trie."

JavaTrieRegexRemove::usage = "Remove nodes that have keys adhering to a regex expression."

JavaTrieShrink::usage = "JavaTrieShrink[ jTr_, sep_String:\"\"] concatenates the \"single path\" nodes\
in the trie jTr using the given separator sep."

JavaTrieThresholdRemove::usage = "Remove nodes that have values below (or above) a threshold."

JavaTrieToJSON::usage = "Converts a Java trie to a corresponding JSON expression."

Begin["`Private`"]
Expand Down Expand Up @@ -296,6 +300,26 @@ Mathematica is (C) Copyright 1988-2017 Wolfram Research, Inc.
Map[{"key", "value"} /. # &,
ImportString[TrieFunctions`pathsToJSON[TrieFunctions`rootToLeafPaths[jTr]], "JSON"], {2}];

Clear[JavaTrieRegexRemove]
JavaTrieRegexRemove[jTr_?JavaObjectQ, regex_String ] :=
TrieFunctions`removeByKeyRegex[jTr, regex];

JavaTrieRegexRemove[jTr_?JavaObjectQ, regex_String, postfix_String ] :=
TrieFunctions`removeByKeyRegex[jTr, regex, postfix];

Clear[JavaTrieThresholdRemove]
JavaTrieThresholdRemove[jTr_?JavaObjectQ, threshold_?NumericQ, belowThresholdQ:(True|False), postfix_String ] :=
TrieFunctions`removeByThreshold[jTr, threshold, belowThresholdQ, postfix];

JavaTrieThresholdRemove[jTr_?JavaObjectQ, threshold_?NumericQ, belowThresholdQ:(True|False) ] :=
TrieFunctions`removeByThreshold[jTr, threshold, belowThresholdQ];

JavaTrieThresholdRemove[jTr_?JavaObjectQ, threshold_?NumericQ] :=
TrieFunctions`removeByThreshold[jTr, threshold];

JavaTrieThresholdRemove[jTr_?JavaObjectQ, threshold_?NumericQ, postfix_String] :=
TrieFunctions`removeByThreshold[jTr, threshold, True, postfix];

End[] (* `Private` *)

EndPackage[]

0 comments on commit 51d4a83

Please sign in to comment.