summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--monkey/patterns.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/monkey/patterns.py b/monkey/patterns.py
index e22c39b..051544d 100644
--- a/monkey/patterns.py
+++ b/monkey/patterns.py
@@ -132,6 +132,7 @@ def get_patterns(tree):
yield pat, selected
# yield patterns for variable-literal / literal-literal pairs
+ # yield patterns for singleton literals
# (only within a topmost compound / binop / unop)
def patterns_with_literals(node):
if not isinstance(node, Tree):
@@ -139,7 +140,9 @@ def get_patterns(tree):
if node.label() in {'compound', 'binop', 'unop'}:
vars = [n for n in node.subtrees() if n.label() == 'variable']
lits = [n for n in node.subtrees() if n.label() == 'literal']
- for selected in chain(combinations(lits, 2), product(lits, vars)):
+ for selected in chain(combinations(lits, 1),
+ combinations(lits, 2),
+ product(lits, vars)):
pat = pattern(clause, selected)
if pat:
yield pat, selected
@@ -203,7 +206,7 @@ if __name__ == '__main__':
attrs = []
with open('data/attributes-{:03}.tab'.format(pid), 'w') as pattern_file:
for i, (pat, count) in enumerate(patterns.most_common()):
- if count < 1:
+ if count < 5:
break
attrs.append(pat)
print('a{}\t{}'.format(i, pat), file=pattern_file)