In [1]:
from util.tagsim.flickr_similarity import FlickrContextSim
fcs = FlickrContextSim('train1m')
In [2]:
# compute similarity for a given pair of tags
print fcs.compute('boeing', 'airplane'), fcs.compute('boeing', 'flight'), fcs.compute('boeing', 'street')
In [3]:
# find similar tags in a given vocabulary
vob = fcs.vob
query_tag = 'boeing'
tagscores = [(tag, fcs.compute(tag, query_tag)) for tag in vob]
tagscores.sort(key=lambda v:v[1], reverse=True)
# show the top 10 ranked tags
print tagscores[:10]