Beispiel #1
0
def enter():
    global image
    Letter.enter()



    pass
Beispiel #2
0
def draw():
    global image
    clear_canvas()
    UI.draw()
    Letter.draw()





    update_canvas()
    pass
Beispiel #3
0
 def createNgrams(self, n, indexes):
     ngragms = []  # делаем n-грамы для каждого письма
     for i in indexes:  # перебираем индексы обучающих блоков
         for letter in self.DATASETS[i]:
             subject, text = getLetterNgram(n, letter)
             ngragms.append(Letter.Letter(subject, text, letter.isSpam))
     return ngragms
Beispiel #4
0
def toLetterArray(word):
	#Create a variable for the result to be added to
	result = []
	#Create an array of the chars in the word
	chars = list(word)
	#Loop thourgh each letter in the word
	for l in chars:
		#Append a letter object to the results array with the current letter in the loop
		result.append(Letter.letter(l))
	return result
Beispiel #5
0
def readLetter(file, isSpam):
    f = open(file, 'r')
    subjectLine = f.readline().split()
    line = f.readline()
    letterLine = f.readline().split()
    subjectLine.remove("Subject:")

    subject = [int(x) for x in subjectLine]
    letter = [int(x) for x in letterLine]
    f.close()

    return Letter.Letter(subject.copy(), letter.copy(), isSpam)
Beispiel #6
0
 def __init__(self, inputMatrix):
     self.inputRows = inputMatrix.splitlines()
     self.columnLength = len(self.inputRows)
     if self.columnLength == 0:
         self.rowLength = 0
     else:
         self.rowLength = len(self.inputRows[0])
     self.rowIndices = range(self.columnLength)
     self.columnIndices = range(self.rowLength)
     if self.correctInput():
         self.matrix = [[
             Letter(self.inputRows[row][column], row, column)
             for column in self.columnIndices
         ] for row in self.rowIndices]
     else:
         self.matrix = [[]]
Beispiel #7
0
def get_list_of_word_coordinates(corners):
    AllLetters = []  # Turn letters into objects
    counter = 0
    for bx in corners:
        width = abs(bx[1][0] - bx[0][0])
        height = abs(bx[3][1] - bx[0][1])
        if width * height == 0:
            continue
        #plt.plot([bx[0][0],bx[1][0]],[bx[0][1],bx[1][1]],'g-',linewidth=2)
        #plt.plot([bx[1][0],bx[2][0]],[bx[1][1],bx[2][1]],'g-',linewidth=2)
        #plt.plot([bx[2][0],bx[3][0]],[bx[2][1],bx[3][1]],'g-',linewidth=2)
        #plt.plot([bx[3][0],bx[0][0]],[bx[3][1],bx[0][1]],'g-',linewidth=2)
        newLetter = Letter.Letter([bx[0][0], bx[0][1]], [height, width],
                                  counter)
        AllLetters.append(newLetter)
        counter += 1
    AllLetters.sort(key=lambda letter: letter.getY() + letter.getHeight())
    return AllLetters
Beispiel #8
0
                bestCorner[3][1] = 0

    ###############################################
    # Take letters and turn them into objects
    AllLetters = []
    counter = 0
    for bx in corners:
        width = abs(bx[1][0] - bx[0][0])
        height = abs(bx[3][1] - bx[0][1])
        if width*height == 0:
            continue
        plt.plot([bx[0][0],bx[1][0]],[bx[0][1],bx[1][1]],'g-',linewidth=2)
        plt.plot([bx[1][0],bx[2][0]],[bx[1][1],bx[2][1]],'g-',linewidth=2)
        plt.plot([bx[2][0],bx[3][0]],[bx[2][1],bx[3][1]],'g-',linewidth=2)
        plt.plot([bx[3][0],bx[0][0]],[bx[3][1],bx[0][1]],'g-',linewidth=2)
        newLetter = Letter.Letter([bx[0][0],bx[0][1]],[height,width],counter)
        AllLetters.append(newLetter)
        counter+=1
    plt.imshow(th3,'gray')
    plt.show()
    plt.clf()
    # sort letters
    AllLetters.sort(key=lambda letter: letter.getY()+letter.getHeight())

    #project the y coordinates of the letters on to
    # the y axis
    prjYCoords = []
    for letter in AllLetters:
        prjYCoords.append(letter.getY()+letter.getHeight())
        plt.plot([letter.getX(),letter.getX()+letter.getWidth()],[letter.getY(),letter.getY()],'b-',linewidth=2)
        plt.plot([letter.getX()+letter.getWidth(),letter.getX()+letter.getWidth()],[letter.getY(),letter.getY()+letter.getHeight()],'b-',linewidth=2)
Beispiel #9
0
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator

import Letter

IMG_WIDTH=8
IMG_HEIGHT=16
BATCH_SIZE=52152 - 1

letters = [None] * BATCH_SIZE
counter = 0

with open("sample/letter.data") as file:
  for line_num, line in enumerate(file):
    vals = line.split(" ")
    _output = vals[1]
    _input = [[None] * IMG_WIDTH] * IMG_HEIGHT

    for i in range(0, IMG_HEIGHT)
      for j in range(0, IMG_WIDTH)
        _input[i][j] = vals[(i * IMG_HEIGHT) + j + 6]
    
    letter = Letter(_input, _output)
    letters[counter] = letter;
    counter++


    
    
     
    
Beispiel #10
0
def update():
    Letter.update()
    pass