[similarity] Adding an in-memory IDF index for weighted similarities

This commit is contained in:
Al
2015-10-29 12:53:11 -04:00
parent 1c543a5271
commit 5076c0409b
3 changed files with 39 additions and 3 deletions

View File

@@ -197,19 +197,16 @@ class PolygonIndex(object):
polygons.append((feature['properties'], prep(MultiPolygon(polys))))
return polygons
@classmethod
def load_index(cls, d, index_name=None):
raise NotImplementedError('Children must implement')
@classmethod
def load(cls, d, index_name=None, polys_filename=DEFAULT_POLYS_FILENAME):
index = cls.load_index(d, index_name=index_name or cls.INDEX_FILENAME)
polys = cls.load_polygons(os.path.join(d, polys_filename))
return cls(index=index, polygons=polys, save_dir=d)
def get_candidate_polygons(self, lat, lon):
raise NotImplementedError('Children must implement')