Example #1
0
def spellcheck(packet):
    if type(packet) == DisplayPacket or type(packet) == HeaderPacket:
        words = str(PrinterANSI(packet.displayable, False)).decode('utf-8')
        words = ''.join([c if c.isalnum() else ' ' for c in words])
        words = words.split(' ')

        for n, w in enumerate(words):
            if len(w) > 2 and not d.check(w.lower()):
                s = filter(
                    lambda x: len(x) == len(w) and weighted_hamming(x, w) == 0,
                    d.suggest(w.lower()))
                if len(s) > 0:
                    words[n] = case_match(s[0], w)

        words = ' '.join(words)
        for n, c in enumerate(words):
            if c != ' ':
                packet.displayable[n] = ord(c)
Example #2
0
 def to_ansi(self, colour=True):
     return '   P' + self.page_str() + ' ' + str(
         PrinterANSI(self.displayable, colour))
Example #3
0
 def to_ansi(self, colour=True):
     return str(PrinterANSI(self.displayable, colour))
Example #4
0
 def to_ansi(self, colour=True):
     return 'DC=' + str(self.dc) + ' ' + str(
         PrinterANSI(self.displayable, colour))