def load(self, attribute): """ Load an attribute from the corresponding index files. If the attribute is of the form `a1+a2` and the corresponding file does not exist, creates a new suffix array fusing the arrays for attributes `a1` and `a2`. """ if self.arrays.has_key(attribute): return self.arrays[attribute] verbose("Loading corpus files for attribute \"%s\"." % attribute) array = SuffixArray() path = self.basepath + "." + attribute array.set_basepath(path) try: array.load() except IOError, err: # If attribute is composed, fuse the corresponding suffix arrays. if '+' in attribute: attr1, attr2 = attribute.rsplit('+', 1) verbose("Fusing suffix arrays for %s and %s..." % (attr1, attr2)) array = fuse_suffix_arrays(self.load(attr1), self.load(attr2)) array.set_basepath(path) array.build_suffix_array() array.save() else: raise err
def load(self, attribute): """ Load an attribute from the corresponding index files. If the attribute is of the form `a1+a2` and the corresponding file does not exist, creates a new suffix array fusing the arrays for attributes `a1` and `a2`. """ #pdb.set_trace() if self.arrays.has_key(attribute): return self.arrays[attribute] if not self.array_file_exists(attribute): if '+' in attribute: self.make_fused_array(attribute.split('+')) else: warn("Cannot load attribute %s; index files not present." % attribute) return None verbose("Loading corpus files for attribute \"%s\"." % attribute) array = SuffixArray() path = self.basepath + "." + attribute array.set_basepath(path) array.load() self.arrays[attribute] = array return array
def load(self, attribute): """ Load an attribute from the corresponding index files. If the attribute is of the form `a1+a2` and the corresponding file does not exist, creates a new suffix array fusing the arrays for attributes `a1` and `a2`. """ # pdb.set_trace() if self.arrays.has_key(attribute): return self.arrays[attribute] if not self.array_file_exists(attribute): if "+" in attribute: self.make_fused_array(attribute.split("+")) else: warn("Cannot load attribute %s; index files not present." % attribute) return None verbose('Loading corpus files for attribute "%s".' % attribute) array = SuffixArray() path = self.basepath + "." + attribute array.set_basepath(path) array.load() self.arrays[attribute] = array return array
def load(self, attribute): if self.arrays.has_key(attribute): return self.arrays[attribute] verbose("Loading corpus files for attribute \"%s\"." % attribute) array = SuffixArray() path = self.basepath + "." + attribute array.set_basepath(path) try: array.load() except IOError, err: # If attribute is composed, fuse the corresponding suffix arrays. if '+' in attribute: attr1, attr2 = attribute.rsplit('+', 1) array = fuse_suffix_arrays(self.load(attr1), self.load(attr2)) array.set_basepath(path) array.build_suffix_array() array.save() else: raise err