LID/resources/lid.py
def createTrigrams(self, text):
		"""Creates tri-grams from characters."""
		self.num = 0                    # storage for the number of trigrams
		self.trigrams = {}              # dictionary storage for trigrams
		text = re.sub(r"\n", " ", text) # replace newlines in text
		text = self.cleanTextSC(text)   # clean trigrams with punctuation marks
		text = re.sub(r"\s+", " ", text) # replace multiple spaces/tabs 
		self.characters = len(text)     # get number of characters

		# go thru list up to one but last word and take
		# the actual word and the following word together
		for i in range(len(text) - 2):
			trigram = text[i:i+3]
			self.num += 1
			if self.trigrams.has_key(trigram):
				# increment the number of this trigram
				self.trigrams[trigram] += 1
			else:
				# append the trigram
				self.trigrams[trigram] = 1
Creates tri-grams from characters.
Creates tri-grams from characters.
Creates tri - grams from characters .
def createTrigrams(self, text):
		self.num = 0                    
		self.trigrams = {}              
		text = re.sub(r"\n", " ", text) 
		text = self.cleanTextSC(text)   
		text = re.sub(r"\s+", " ", text) 
		self.characters = len(text)     
		for i in range(len(text) - 2):
			trigram = text[i:i+3]
			self.num += 1
			if self.trigrams.has_key(trigram):
				self.trigrams[trigram] += 1
			else:
				self.trigrams[trigram] = 1
def createTrigrams ( self , text ) : self . num = 0 self . trigrams = { } text = re . sub ( r"\n" , " " , text ) text = self . cleanTextSC ( text ) text = re . sub ( r"\s+" , " " , text ) self . characters = len ( text ) for i in range ( len ( text ) - 2 ) : trigram = text [ i : i + 3 ] self . num += 1 if self . trigrams . has_key ( trigram ) : self . trigrams [ trigram ] += 1 else : self . trigrams [ trigram ] = 1
Creates tri-grams from characters.
Creates tri - grams from characters .
"""Creates tri-grams from characters.""" # storage for the number of trigrams # dictionary storage for trigrams # replace newlines in text # clean trigrams with punctuation marks # replace multiple spaces/tabs  # get number of characters # go thru list up to one but last word and take # the actual word and the following word together # increment the number of this trigram # append the trigram
self
text