本文整理汇总了Python中state.State.promote_rules方法的典型用法代码示例。如果您正苦于以下问题:Python State.promote_rules方法的具体用法?Python State.promote_rules怎么用?Python State.promote_rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state.State
的用法示例。
在下文中一共展示了State.promote_rules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import promote_rules [as 别名]
class Controller :
def __init__(self) :
self.state = State()
#Can define halting condition based on extraction count
def get_ne_types(self) :
return self.state.get_ne_types()
def find_rules(self) :
for ne in self.state.ne_recent.keys() :
rules = []
for doc in self.state.corpus :
rules_i = doc.find_rules([ne])
if len(rules_i) > 0 :
rules.extend(rules_i)
self.state.log_rules(ne, rules)
def promote_rules(self, threshold, max) :
return self.state.promote_rules(threshold, max)
def promote_ne(self, threshold, max) :
return self.state.promote_ne(threshold, max)
def find_ne(self):
#print self.state.rules_recent
self.state.find_ne()
#Reset candidates for next iteration.
def end_iteration(self) :
self.state.candidate_rules = dict()
self.state.candidate_ne = dict()
示例2: __init__
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import promote_rules [as 别名]
class Controller :
def __init__(self) :
self.state = State()
def find_rules_tok(self) :
for doc in self.state.corpus :
for ne in self.state.ne.keys() :
candidates = doc.find_rules(ne)
'''
prune rules
'''
candidates.extend(rules)
self.state.add_candidate_rules(ne, candidates)
def find_ne_tok(self) :
for doc in self.state.corpus :
for rule in self.state.rules :
candidates = doc.find_ne(rule)
if len(candidates) == 0 :
continue
for ne in candidates :
self.insert_candidate_ne(ne, rule)
def promote_rules(self, threshold, max) :
return self.state.promote_rules(threshold, max)
def promote_ne(self, threshold, max) :
return self.state.promote_ne(threshold, max)
def find_ne(self):
self.state.find_ne()
def end_iteration(self) :
self.state.candidate_rules = dict()
self.state.candidate_ne = dict()
def insert_candidate_ne(self, ne, rule) :
candidate_dict = self.state.candidate_ne
rule_dict = self.state.rules
rule_type = rule_dict[rule].get_type()
rule_score = rule_dict[rule].get_max_score()
if ne not in candidate_dict.keys() :
candidate_dict[ne] = Scorekeeper()
candidate_dict[ne].positive_scoring(rule_type, rule_score)