Beispiel #1
0
    def _get_train_stream(self, data):
        """ returns training instances stream from data file name or
		data source"""
        feature_alphabet = self._feature_alphabet
        if isinstance(data, str):
            stream = Source(data,
                            feature_alphabet=feature_alphabet,
                            alphabet_lock=False,
                            alphabet_pop=False,
                            bias=self._bias)
        elif isinstance(data, Source):
            stream = data
        elif callable(data):
            stream = Source(data,
                            feature_alphabet=feature_alphabet,
                            alphabet_lock=False,
                            alphabet_pop=False,
                            bias=self._bias)
        else:
            raise Exception(
                "Error: data is either string for file name or ClassificationSource!"
            )
        # set alphabet from data
        self.set_alphabet(stream.get_alphabet())
        return stream
Beispiel #2
0
	def _get_test_stream( self, data ):
		""" returns test instances stream from data file name or
		data source"""
		if isinstance(data,str):
			stream = Source( data, alphabet_lock=True,\
					 alphabet_pop=False, bias=self._bias )
		elif isinstance(data,Source):
			stream = data
		else:
			raise Exception("Error: data is either string for file name or ClassificationSource!")
		# use model alphabet
		stream.set_alphabet( self.get_alphabet() )
		return stream
Beispiel #3
0
    def _get_test_stream(self, data):
        """ returns test instances stream from data file name or
		data source"""
        if isinstance(data, str):
            stream = Source( data, alphabet_lock=True,\
               alphabet_pop=False, bias=self._bias )
        elif isinstance(data, Source):
            stream = data
        else:
            raise Exception(
                "Error: data is either string for file name or ClassificationSource!"
            )
        # use model alphabet
        stream.set_alphabet(self.get_alphabet())
        return stream
Beispiel #4
0
	def _get_train_stream( self, data ):
		""" returns training instances stream from data file name or
		data source"""
		feature_alphabet = self._feature_alphabet
		if isinstance(data,str):
			stream = Source(data, feature_alphabet=feature_alphabet, alphabet_lock=False, alphabet_pop=False, bias=self._bias)
		elif isinstance(data,Source):
			stream = data
		elif callable(data):
			stream = Source(data, feature_alphabet=feature_alphabet, alphabet_lock=False, alphabet_pop=False, bias=self._bias)
		else:
			raise Exception("Error: data is either string for file name or ClassificationSource!")
		# set alphabet from data
		self.set_alphabet( stream.get_alphabet() )
		return stream