Created
June 19, 2019 05:31
-
-
Save samidarko/484b1aff74815edee281c7c2fc571f3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SingletonIndex(object): | |
singleton = None | |
def __new__(cls, *args, **kwargs): | |
if not cls.singleton: | |
cls.singleton = object.__new__(SingletonIndex) | |
return cls.singleton | |
def __init__(self, path): | |
self.index = similarities.Similarity.load(path) | |
def get(self): | |
return self.index | |
class SingletonDictionary(object): | |
singleton = None | |
def __new__(cls, *args, **kwargs): | |
if not cls.singleton: | |
cls.singleton = object.__new__(SingletonDictionary) | |
return cls.singleton | |
def __init__(self, path): | |
self.dictionary = corpora.Dictionary.load(path) | |
def get(self): | |
return self.dictionary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment