(self, candidate_phrase, 
                                          max_phrase_len=25)
return True
按照严格规则筛选候选短语，严格限制在名词短语
按照严格规则筛选候选短语，严格限制在名词短语
按照严格规则筛选候选短语，严格限制在名词短语
def _stricted_candidate_phrases_rules(self, candidate_phrase, 
                                          max_phrase_len=25):
        ''' 按照严格规则筛选候选短语，严格限制在名词短语 '''
        # 条件一：一个短语不能超过 12个 token
        if len(candidate_phrase) > 12:
            return False

        # 条件二：一个短语不能超过 25 个 char
        if len(''.join([item[0] for item in candidate_phrase])) > max_phrase_len:
            return False

        # 条件三：短语必须是名词短语，不能有停用词
        for idx, item in enumerate(candidate_phrase):
            if item[1] not in self.stricted_pos_name:
                return False
            if idx == 0:  # 初始词汇不可以是动词
                if item[1] in ['v', 'vd', 'vx']:  # 动名词不算在内
                    return False
            if idx == len(candidate_phrase) - 1:  # 结束词必须是名词
                if item[1] in ['a', 'ad', 'vd', 'vx', 'v']:
                    return False

        # 条件四：短语中不可以有停用词
        #for item in candidate_phrase:
        #    if item[0] in self.stop_words and item[1] not in self.stricted_pos_name:
        #        return False
        return True
def _stricted_candidate_phrases_rules ( self , candidate_phrase , max_phrase_len = 25 ) : # 条件一：一个短语不能超过 12个 token if len ( candidate_phrase ) > 12 : return False # 条件二：一个短语不能超过 25 个 char if len ( '' . join ( [ item [ 0 ] for item in candidate_phrase ] ) ) > max_phrase_len : return False # 条件三：短语必须是名词短语，不能有停用词 for idx , item in enumerate ( candidate_phrase ) : if item [ 1 ] not in self . stricted_pos_name : return False if idx == 0 : # 初始词汇不可以是动词 if item [ 1 ] in [ 'v' , 'vd' , 'vx' ] : # 动名词不算在内 return False if idx == len ( candidate_phrase ) - 1 : # 结束词必须是名词 if item [ 1 ] in [ 'a' , 'ad' , 'vd' , 'vx' , 'v' ] : return False # 条件四：短语中不可以有停用词 #for item in candidate_phrase: #    if item[0] in self.stop_words and item[1] not in self.stricted_pos_name: #        return False return True