Exemplo n.º 1
0
def w2v_ic(word, buckets=20):
    global ic_dict
    if not ic_dict:
        ic_dict = LoadData.load_ic()

    im = [0]*buckets
    cn = [0]*buckets

    if word in ic_dict:
        if ic_dict[word].IMAGEABILITY != None:
            im = bucket(ic_dict[word].IMAGEABILITY, 7., buckets)
	elif word in model:
	    for w2 in model.most_similar(word, topn=20):
		if w2[0] in ic_dict and ic_dict[w2[0]].IMAGEABILITY != None:
		    im = bucket(ic_dict[w2[0]].IMAGEABILITY, 7., buckets)
		    break

        if ic_dict[word].CONCRETENESS != None:
            cn = bucket(ic_dict[word].CONCRETENESS, 5., buckets)
	elif word in model:
	    for w2 in model.most_similar(word, topn=20):
		if w2[0] in ic_dict and ic_dict[w2[0]].CONCRETENESS != None:
		    cn = bucket(ic_dict[w2[0]].CONCRETENESS, 5., buckets)
		    break
    return cn + im
Exemplo n.º 2
0
def ic(word, buckets=5):
    if type(word) == tuple:
	word = word[0]

    global ic_dict
    if not ic_dict:
	ic_dict = LoadData.load_ic() 

    im = [0]*buckets
    cn = [0]*buckets

    if word in ic_dict:
	if ic_dict[word].IMAGEABILITY != None:
	    im = bucket(ic_dict[word].IMAGEABILITY, 7., buckets)
	if ic_dict[word].CONCRETENESS != None:
	    cn = bucket(ic_dict[word].CONCRETENESS, 5., buckets)

    return cn + im