Example #1
0
	def save(self, attribute):
		"""
			Saves the suffix array for `attribute` to the corresponding files.
		"""
		array = self.arrays[attribute]
		array.set_basepath(self.basepath + "." + attribute)
		array.save()
Example #2
0
 def save(self, attribute):
     """
         Saves the suffix array for `attribute` to the corresponding files.
     """
     array = self.arrays[attribute]
     array.set_basepath(self.basepath + "." + attribute)
     array.save()
Example #3
0
	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
Example #4
0
	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
Example #5
0
    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
Example #6
0
    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
Example #7
0
    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
Example #8
0
	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
Example #9
0
 def save(self, attribute):
     array = self.arrays[attribute]
     array.set_basepath(self.basepath + "." + attribute)
     array.save()
Example #10
0
	def save(self, attribute):
		array = self.arrays[attribute]
		array.set_basepath(self.basepath + "." + attribute)
		array.save()