Skip to content

Commit 232ee93

Browse files
committed
remove bad rules
1 parent 2569586 commit 232ee93

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

propertysuggester/analyzer/RuleGenerator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from propertysuggester.utils.datamodel import Entity
55

66

7-
def compute_rules(entities):
7+
def compute_rules(entities, min_probability=0.01):
88
"""
99
@type entities: collections.Iterable[Entity]
1010
@return: list[Rule]
@@ -18,7 +18,7 @@ def compute_rules(entities):
1818
for analyzer in analyzers:
1919
analyzer.process(entity)
2020

21-
rules = itertools.chain(*(a.get_rules() for a in analyzers))
21+
rules = filter(lambda rule: rule.probability > min_probability, itertools.chain(*(a.get_rules() for a in analyzers)))
2222
return rules
2323

2424

@@ -47,7 +47,7 @@ def get_rules(self):
4747
for pid2, value in row.iteritems():
4848
if value > 0:
4949
probability = value/float(pid1count)
50-
rules.append(Rule(pid1, None, pid2, pid1count, probability, self.context))
50+
rules.append(Rule(pid1, None, pid2, value, probability, self.context))
5151
return rules
5252

5353

propertysuggester/test/analyzer/test_rule_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def setUp(self):
2727

2828
def test_table_generator(self):
2929
rules = list(RuleGenerator.compute_rules(test_data1))
30-
self.assertThat(rules, ContainsAll([Rule(31, None, 373, 2, 0.5, "item"), Rule(373, None, 31, 1, 1.0, "item")]))
30+
self.assertThat(rules, ContainsAll([Rule(31, None, 373, 1, 0.5, "item"), Rule(373, None, 31, 1, 1.0, "item")]))
3131

3232

3333
def test_table_with_multiple_occurance(self):

0 commit comments

Comments
 (0)