def get_seman(self, url): if url in self.cache: return self.cache[url] else: self.cache[url] = seaman_maker(url=url) self.last = url return self.cache[url]
def initialize_seman(message): """Initialize the seman translator @param url: (str) database connection url @param name: (str) name under which the initialized seman instance will be stored and accessible. If empty, it will be saved using url @param verbose: (boolean) whether to print queries that are executed, can slow down your program considerably @param language: (str) code of the language of the texts we are processing """ url = str(message.getParam("url")) name = str(message.getParam("name") or url) kwargs = {'url':url} kwargs['verbose'] = bool(message.getParam("verbose")) seman = seaman_maker(surface_dictionary_config=kwargs) if message.getParam("language"): seman.setPersistentParameter("language", str(message.getParam("language"))) Cacher.set_seman(name, seman)