def main(category_name):
    reload(sys)
    sys.setdefaultencoding("utf-8")

    # 获取规则模版(同义词,偏序关系,推导词,组合关系,情感词,歧义词)
    category_synonyms_dict = rule_base.getSynonym("rule_template/synonym.rule")
    partial_dict, indicator_set = rule_base.getPartial("rule_template/partial.rule")
    combine_dict = rule_base.getCombine("rule_template/combine.rule")
    comment_category_set = rule_base.getCommenCategorySet("rule_template/comment.rule")
    ambiguation_dict = rule_base.getDisambiguation("rule_template/disambiguation.rule")

    # 从规则库中构建类目关系树
    category_parent_dict, category_child_dict, category_synonyms_dict = rule_base.createCategoryTree(
        partial_dict, combine_dict, category_synonyms_dict
    )

    # 标签推荐
    recommendTag(
        category_name,
        category_parent_dict,
        category_child_dict,
        category_synonyms_dict,
        indicator_set,
        comment_category_set,
        ambiguation_dict,
    )
def main():
	reload(sys)
	sys.setdefaultencoding('utf-8')

	#获取规则模版(同义词,偏序关系,组合关系)
	category_synonyms_dict = rule_base.getSynonym('../../category/rule/rule_template/synonym.rule')
	partial_dict,indicator_set = rule_base.getPartial('../../category/rule/rule_template/partial.rule')
	combine_dict = rule_base.getCombine('../../category/rule/rule_template/combine.rule')

	#从规则库中构建类目关系树
	category_parent_dict,category_child_dict,category_synonyms_dict = rule_base.createCategoryTree(partial_dict,combine_dict,category_synonyms_dict)

	#转成json格式
	tree = convertToJsonTree(category_parent_dict,category_synonyms_dict,indicator_set)

	#输出json	
	encodedjson = json.dumps(tree[u"根节点"])
	outfile = open('data.json','wb')
	outfile.write(encodedjson)

	outfile = open("synonym.csv","wb")
	outfile.write("delegate,synonym_set\r\n")
	delegate_handle_set = set([])
	for category in category_synonyms_dict.keys():
		if "(" in category and ")" in category:
			continue
		delegate = category_synonyms_dict[category][0]
		if delegate not in delegate_handle_set:
			outfile.write(delegate+","+" ".join(category_synonyms_dict[category][1])+"\r\n")
			delegate_handle_set |= set([delegate])
Example #3
0
def main(category_name):
	reload(sys)
	sys.setdefaultencoding('utf-8')

	#获取规则模版(同义词,偏序关系,推导词,组合关系,情感词,歧义词)
	category_synonyms_dict = rule_base.getSynonym('rule_template/synonym.rule')
	partial_dict,indicator_set = rule_base.getPartial('rule_template/partial.rule')
	combine_dict = rule_base.getCombine('rule_template/combine.rule')
	comment_category_set = rule_base.getCommenCategorySet('rule_template/comment.rule')
	ambiguation_dict = rule_base.getDisambiguation('rule_template/disambiguation.rule')

	#从规则库中构建类目关系树
	category_parent_dict,category_child_dict,category_synonyms_dict = rule_base.createCategoryTree(partial_dict,combine_dict,category_synonyms_dict)


	classify(category_name,category_parent_dict,category_child_dict,category_synonyms_dict,indicator_set,comment_category_set,ambiguation_dict)
Example #4
0
def main(category_name):
    reload(sys)
    sys.setdefaultencoding('utf-8')

    #获取规则模版(同义词,偏序关系,推导词,组合关系,情感词,歧义词)
    category_synonyms_dict = rule_base.getSynonym(
        '../rule/rule_template/synonym.rule')
    partial_dict, indicator_set = rule_base.getPartial(
        '../rule/rule_template/partial.rule')
    combine_dict = rule_base.getCombine('../rule/rule_template/combine.rule')
    comment_category_set = rule_base.getCommenCategorySet(
        '../rule/rule_template/comment.rule')
    ambiguation_dict = rule_base.getDisambiguation(
        '../rule/rule_template/disambiguation.rule')

    query_set = category_synonyms_dict[query][1]
    createCorpus(category_name, query_set)
Example #5
0
def main():
    reload(sys)
    sys.setdefaultencoding('utf-8')

    #获取规则模版(同义词,偏序关系,组合关系)
    category_synonyms_dict = rule_base.getSynonym(
        '../../category/rule/rule_template/synonym.rule')
    partial_dict, indicator_set = rule_base.getPartial(
        '../../category/rule/rule_template/partial.rule')
    combine_dict = rule_base.getCombine(
        '../../category/rule/rule_template/combine.rule')

    #从规则库中构建类目关系树
    category_parent_dict, category_child_dict, category_synonyms_dict = rule_base.createCategoryTree(
        partial_dict, combine_dict, category_synonyms_dict)

    #转成json格式
    tree = convertToJsonTree(category_parent_dict, category_synonyms_dict,
                             indicator_set)

    #输出json
    encodedjson = json.dumps(tree[u"根节点"])
    outfile = open('data.json', 'wb')
    outfile.write(encodedjson)

    outfile = open("synonym.csv", "wb")
    outfile.write("delegate,synonym_set\r\n")
    delegate_handle_set = set([])
    for category in category_synonyms_dict.keys():
        if "(" in category and ")" in category:
            continue
        delegate = category_synonyms_dict[category][0]
        if delegate not in delegate_handle_set:
            outfile.write(delegate + "," +
                          " ".join(category_synonyms_dict[category][1]) +
                          "\r\n")
            delegate_handle_set |= set([delegate])