File pattern.lua
Functions
buildSimpleTrieFromPatternFile (file) | Build a simple trie from a pattern file. |
calcPatternStatistics (trie, wfile) | Calculate the effectiveness of a trie (number of matches per pattern) against a word list file. |
showPatternStatistics (patternstat, wordlimit) | Output pattern statistics. |
Functions
- buildSimpleTrieFromPatternFile (file)
-
Build a simple trie from a pattern file. Input format is a file with exactly one pattern per line (nothing else).
Parameters:
-
file
: Pattern file.
Return value:
- A simple trie. The value associated with an identified pattern is the pattern itself.
-
- calcPatternStatistics (trie, wfile)
-
Calculate the effectiveness of a trie (number of matches per pattern) against a word list file. This function may require huge amounts of memory and run for a long time.
Parameters:
-
trie
: A pattern trie. -
wfile
: A word list file.
Return value:
- A table with pattern statistics. Keys are patterns and values are tables of the form { count = /number/, words = /array/ }. Key count contains the total number of times a pattern was identified in the word list file. Key words is an array with all matching words as keys (and value true).
-
- showPatternStatistics (patternstat, wordlimit)
-
Output pattern statistics.
Parameters:
-
patternstat
: A table with pattern statistics as provided by function calcPatternStatistics(). -
wordlimit
: Maximum number of words to output per pattern.
-