Esempio n. 1
0
def main():
    t = {}
    for k, v in NAME2ID.iteritems():
        t[name_tidy(k)] = v
    print "#coding: utf-8"
    print "NAME2ID = ",
    pprint(t)
Esempio n. 2
0
def main():
    t = {}
    for k,v in NAME2ID.iteritems():
        t[name_tidy(k)] = v
    print "#coding: utf-8"
    print "NAME2ID = ",
    pprint(t)
#coding:utf-8

import _env
from json import loads
from zhihu_topic_data_with_follow import ZHIHU_TOPIC
from name2id import NAME2ID
from zdata.tag.name_tidy import name_tidy
from zhihu_topic_url2id import ID2MY
from itertools import chain
from zhihu_question_load import zhihu_to_dump

id2topic = dict([(i[1], i[0]) for i in ZHIHU_TOPIC])

myidset = set(NAME2ID.itervalues())
myiddict = dict([(k, v) for v, k in NAME2ID.iteritems()])


def tag_id_list_by_str_list(tags):
    tag_list = []

    for tag in tags:
        id = tag_to_id(tag)
        if not id:
            continue
        else:
            tag_list.append(id)

    return tag_list


def tag_to_id(tag):
Esempio n. 4
0
#coding:utf-8
import _env
from name2id import NAME2ID
from zkit.txt_cleanup import sp_txt
from collections import defaultdict
from zkit.pprint import pprint

sp2id = defaultdict(list)

for k, v in NAME2ID.iteritems():
    for i in sp_txt(k):
        sp2id[i].append(k)

word_parent = defaultdict(set)

for k, v in NAME2ID.iteritems():
    for i in sp_txt(k):
        for j in sp2id[i]:
            if j != k and k in j:
                #print k, j
                word_parent[NAME2ID[j]].add(NAME2ID[k])

id2name = dict((k, v) for v, k in NAME2ID.iteritems())

#for id, pid_list in word_parent.iteritems():
#    print id2name[id]
#    for i in pid_list:
#        print id2name[i],
#    print "\n" 

word_parent = dict((k, tuple(v)) for k, v in word_parent.iteritems())
Esempio n. 5
0
#coding:utf-8
import _env
from name2id import NAME2ID
from zkit.txt_cleanup import sp_txt
from collections import defaultdict
from zkit.pprint import pprint

sp2id = defaultdict(list)

for k, v in NAME2ID.iteritems():
    for i in sp_txt(k):
        sp2id[i].append(k)

word_parent = defaultdict(set)

for k, v in NAME2ID.iteritems():
    for i in sp_txt(k):
        for j in sp2id[i]:
            if j != k and k in j:
                #print k, j
                word_parent[NAME2ID[j]].add(NAME2ID[k])

id2name = dict((k, v) for v, k in NAME2ID.iteritems())

#for id, pid_list in word_parent.iteritems():
#    print id2name[id]
#    for i in pid_list:
#        print id2name[i],
#    print "\n"

word_parent = dict((k, tuple(v)) for k, v in word_parent.iteritems())
#coding:utf-8

import _env
from json import loads
from zhihu_topic_data_with_follow import ZHIHU_TOPIC
from name2id import NAME2ID
from zdata.tag.name_tidy import name_tidy
from zhihu_topic_url2id import ID2MY
from itertools import chain
from zhihu_question_load import zhihu_to_dump

id2topic = dict([(i[1], i[0]) for i in ZHIHU_TOPIC])

myidset = set(NAME2ID.itervalues())
myiddict = dict([(k, v) for v, k in NAME2ID.iteritems()])

def tag_id_list_by_str_list(tags):
    tag_list = []

    for tag in tags:
        id = tag_to_id(tag)
        if not id:
            continue
        else:
            tag_list.append(id)

    return tag_list

def tag_to_id(tag):
    tag = str(tag)
    id = id2topic.get(tag, 0)
Esempio n. 7
0
def main():
    for k, v in NAME2ID.iteritems():
        alias, id = k, v
        #        autocomplete_tag.append(alias, id)
        tag_alias_new(alias=alias, id=id)