def __init__(self, trainCollection, tpp="lemm", feature="color64+dsift", k=1000, rootpath=ROOT_PATH): self.trainCollection = trainCollection self.k = k self.name = "%s(%s,%s,%s,%d)" % (self.__class__.__name__, self.trainCollection, tpp, feature, k) vobfile = os.path.join(rootpath, trainCollection, "TextData", "wn.%s.txt" % trainCollection) self.vob = set(map(str.strip, open(vobfile).readlines())) printStatus( INFO, 'the vocabulary of %s contains %d tags' % (trainCollection, len(self.vob))) self.gamma = (1.0 / MEDIAN_DISTANCE[feature])**2 self.feat_dir = os.path.join(rootpath, trainCollection, 'FeatureIndex', feature) self.dim = FEATURE_TO_DIM[feature] self.fcs = FlickrContextSim(trainCollection, rootpath) printStatus(INFO, self.name + ' okay')
def __init__(self, collection, useWnVob=1, rootpath=ROOT_PATH): SemanticTagrelLearner.__init__(self, collection, useWnVob, rootpath) self.engine = FlickrContextSim(collection, rootpath)