"""Doc String""" from string import lower, translate, split, find, join t_t=['',]*256 for i in range(256): if i < 48 or 57 < i < 64: t_t[i] = ' ' else: t_t[i]= chr(i) tt=join(t_t,'') class Splitter: """Doc String""" def __init__(self, insrc, stop_word_dic={}): self.isrc = translate(insrc, tt) tempsrc = split(self.isrc, ' ') stop_words = stop_word_dic.keys() xx=[] for x in tempsrc: if x and len(x) > 1 and not x in stop_words : xx.append(lower(x)) self.src = xx def __getslice__(self, a, b): return self.src[a:b] def __getitem__(self, a): return self.src[a] def __len__(self): return len(self.src) def indexes(self, a): res =[] for i in range(len(self)): if self[i]==a: res.append(i) return res def pos(self, a): i = int(a/2) x = find(self.isrc, self[i]) return (x, x+len(self[i]) )