Beispiel #1
0
def createLangDistribution(line, distribution=None):
    if distribution is None:
        flag = True
        distribution = LangDistro()
    else:
        flag = False
    for c in line:
        if standardchar(c):
            distribution.appenddist(c.lower())
        else:
            pass

    if flag:
        distribution.sort()
        distribution.makePercentage()

    return distribution
Beispiel #2
0
print("Loading Model")
model = keras.models.load_model('GRU.h5')
model.summary()

classifications = model.predict(testing_padded)
classifications = classifications.tolist()

sumtests = LangDistro()  # ile testow z danego jezyka bylo
sumfails = LangDistro()  # ile testow nasz algorytm zawalil
# Testujemy!
print("Runing tests...")
counter = 0
for x in range(len(testing_labels)):

    # Zwiekszamy ilosc testow o 1
    sumtests.appenddist(LANGS[testing_labels[x]])
    # Przygotowywujemy licznik do testow oblanych z akrutalnego jezyka
    if LANGS[testing_labels[x]] not in sumfails:
        sumfails[LANGS[testing_labels[x]]] = 0

    result = classifications[counter].index(max(classifications[counter]))

    # Jezeli zly jezyk zwiekszamy liczne porazek
    if LANGS[result] != LANGS[testing_labels[x]]:
        sumfails.appenddist(LANGS[testing_labels[x]])
        #if LANGS[testing_labels[x]] ==  "eng":
        #    print("Example:")
        #    print(x)
        #    print(x_test[counter])
        #    for i in range(len(LANGS)):
        #        print(LANGS[i] + ": " + str(classifications[counter][i]))