当前位置: 首页>>代码示例>>Python>>正文


Python State.find_ne方法代码示例

本文整理汇总了Python中state.State.find_ne方法的典型用法代码示例。如果您正苦于以下问题:Python State.find_ne方法的具体用法?Python State.find_ne怎么用?Python State.find_ne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在state.State的用法示例。


在下文中一共展示了State.find_ne方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import find_ne [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()
开发者ID:urvashik,项目名称:ner_project,代码行数:33,代码来源:controller.py

示例2: __init__

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import find_ne [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)
开发者ID:ZhouYii,项目名称:NE_Recognizer,代码行数:46,代码来源:controller.py


注:本文中的state.State.find_ne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。